add emacs config

This commit is contained in:
zongor 2023-04-06 21:24:21 -04:00
parent d23f37c6c4
commit 93052e2d02
1 changed files with 282 additions and 0 deletions

282
.emacs Executable file
View File

@ -0,0 +1,282 @@
;;------------------------------------------------------------------------------
;; ᚳᚻᚪᚱᛚᛖᛋ ᛣᚱᚪᛚᚪᛈᛈ ᛖᛗᚪᚳᛋ ᛋᛖᛏᛏᛁᛝᛋ
;; * Зонгор * ᛣᚩᛝᚩᚱ *
;;------------------------------------------------------------------------------
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-install 'use-package))
;; install packages automatically if not already present on your
;; system to be global for all packages
(require 'use-package-ensure)
(setq use-package-always-ensure t)
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)
(defun move-to-previous-window ()
"Move to previous window."
(interactive)
(if (= (count-windows) 1)
(other-frame 1)
(select-window (previous-window))))
(defun move-to-next-window ()
"Move to next window."
(interactive)
(if (= (count-windows) 1)
(other-frame 1)
(select-window (next-window))))
(defun comment-eclipse ()
(interactive)
(let ((start (line-beginning-position))
(end (line-end-position)))
(when (or (not transient-mark-mode) (region-active-p))
(setq start (save-excursion
(goto-char (region-beginning))
(beginning-of-line)
(point))
end (save-excursion
(goto-char (region-end))
(end-of-line)
(point))))
(comment-or-uncomment-region start end)))
(use-package evil
:ensure t
:init
(setq evil-want-keybinding nil)
(setq evil-want-integration t) ;; This is optional since it's already set to t by default.
:config
(evil-mode 1)
;; :q should kill the current buffer rather than quitting emacs entirely
(evil-ex-define-cmd "q" 'kill-this-buffer)
;; Need to type out :quit to close emacs
(evil-ex-define-cmd "quit" 'evil-quit)
(define-key evil-normal-state-map (kbd "C-\\") 'comment-eclipse)
(define-key evil-normal-state-map (kbd "q") 'undo-tree-redo)
(define-key evil-normal-state-map (kbd "w") 'evil-backward-word-begin)
(define-key evil-normal-state-map (kbd "H") 'evil-first-non-blank)
(define-key evil-normal-state-map (kbd "L") 'evil-end-of-line)
(define-key evil-normal-state-map (kbd "K") 'backward-paragraph)
(define-key evil-normal-state-map (kbd "J") 'forward-paragraph)
(define-key evil-normal-state-map (kbd "C-x l") 'list-buffers)
(define-key evil-normal-state-map (kbd "M-/") 'dabbrev-expand)
(define-key evil-normal-state-map (kbd "C-,") 'move-to-previous-window)
(define-key evil-normal-state-map (kbd "C-.") 'move-to-next-window)
(define-key evil-normal-state-map (kbd "C-M-\\") 'format-all-buffer)
;; (evil-define-key 'normal Buffer-menu-mode-map (kbd "RET") )
(evil-define-key 'normal neotree-mode-map (kbd "TAB") 'neotree-enter)
(evil-define-key 'normal neotree-mode-map (kbd "SPC") 'neotree-quick-look)
(evil-define-key 'normal neotree-mode-map (kbd "q") 'neotree-hide)
(evil-define-key 'normal neotree-mode-map (kbd "RET") 'neotree-enter)
(evil-define-key 'normal neotree-mode-map (kbd "g") 'neotree-refresh)
(evil-define-key 'normal neotree-mode-map (kbd "n") 'neotree-next-line)
(evil-define-key 'normal neotree-mode-map (kbd "p") 'neotree-previous-line)
(evil-define-key 'normal neotree-mode-map (kbd "A") 'neotree-stretch-toggle)
(evil-define-key 'normal neotree-mode-map (kbd "H") 'neotree-hidden-file-toggle))
(use-package evil-org
:ensure t
:after org evil
:config
(add-hook 'org-mode-hook 'evil-org-mode)
(add-hook 'evil-org-mode-hook
(lambda ()
(evil-org-set-key-theme)))
(require 'evil-org-agenda)
(evil-org-agenda-set-keys))
(use-package doom-themes
:ensure t
:config
;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
(load-theme 'doom-monokai-classic t)
;; Enable custom neotree theme (all-the-icons must be installed!)
(doom-themes-neotree-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config))
(use-package all-the-icons
:if (display-graphic-p))
(use-package neotree
:config
(global-set-key [f8] 'neotree-toggle))
(use-package undo-tree
:config (global-undo-tree-mode 1)
:diminish undo-tree-mode)
(use-package eaf
:straight (eaf
:type git
:host github
:repo "emacs-eaf/emacs-application-framework"
:files ("*.el" "*.py" "core" "app" "*.json")
:includes (eaf-browser eaf-terminal) ; Straight won't try to search for these packages when we make further use-package invocations for them
:pre-build (("python3" "install-eaf.py" "--install" "browser" "terminal" "--ignore-sys-deps"))
)
:init (evil-set-initial-state 'eaf-mode 'emacs)) ; Evil mode doesn't work well with eaf keybindings.
(use-package eaf-browser
:custom
(eaf-browser-continue-where-left-off t)
(eaf-browser-enable-adblocker t)
(eaf-browser-dark-mode "force"))
(use-package eaf-terminal)
(use-package format-all
:hook
(
(format-all-mode-hook . format-all-ensure-formatter)
)
)
(use-package dumb-jump)
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate)
(use-package elfeed
:config
(global-set-key (kbd "C-x w") 'elfeed))
(use-package restclient)
(use-package markdown-mode
:ensure t
:mode ("README\\.md\\'" . gfm-mode)
:init (setq markdown-command "multimarkdown"))
(use-package docker
:ensure t
:bind ("C-c d" . docker))
(use-package docker-compose-mode)
(use-package go-mode)
(use-package rust-mode)
(use-package cargo)
(use-package lsp-mode
:commands (lsp lsp-deferred)
:init
(setq lsp-keymap-prefix "C-c l")
:hook
((go-mode) . lsp)
((rust-mode) . lsp))
(use-package lsp-ui
:hook (lsp-mode . lsp-ui-mode)
:config
(setq lsp-ui-doc-enable t))
(use-package ccls
:ensure t
:init (setq ccls-executable "/usr/bin/ccls"))
(use-package dash)
(use-package column-enforce-mode)
(use-package desktop)
(use-package git)
(use-package ripgrep)
(use-package projectile)
(use-package ivy)
(use-package git-gutter
:ensure t
:init (global-git-gutter-mode t))
(let ((alist '((33 . ".\\(?:\\(?:\\(?:!\\.\\|!\\)\\|\\(?:==\\|=\\)\\)\\)") ;; !
(35 . ".\\(?:\\(?:[!(:={]\\|\\(?:#\\(?:##\\|#\\)\\|#\\)\\|\\?\\|\\[\\|\\(?:_(\\|_\\)\\)\\)") ;; #
(36 . ".\\(?:>\\)") ;; $
(37 . ".\\(?:%\\)") ;; %
(38 . ".\\(?:&\\)") ;; &
(42 . ".\\(?:\\(?:[/>]\\|\\(?:\\*\\*\\|\\*\\)\\)\\)") ;; *
(43 . ".\\(?:\\(?:\\(?:\\+\\+\\|\\+\\)\\|>\\)\\)") ;; +
(45 . ".\\(?:\\(?:[|~]\\|\\(?:-\\(?:-\\|>\\)\\|-\\)\\|\\(?:<<\\|<\\)\\|\\(?:>>\\|>\\)\\)\\)") ;; -
(46 . ".\\(?:\\(?:-\\|\\(?:\\.\\(?:\\.\\|<\\)\\|\\.\\)\\|=\\|\\?\\)\\)") ;; .
(47 . ".\\(?:\\(?:[>\\]\\|\\*\\|\\(?://\\|/\\)\\|\\(?:==\\|=\\)\\)\\)") ;; /
(48 . ".\\(?:x[0-9A-Fa-f]\\)") ;; 0
(58 . ".\\(?:\\(?:[<->]\\|\\(?::[:=]\\|:\\)\\)\\)") ;; :
(59 . ".\\(?:;\\)") ;; ;
(60 . ".\\(?:\\(?:[:>]\\|!--\\|\\(?:\\$>\\|\\$\\)\\|\\(?:\\*>\\|\\*\\)\\|\\(?:\\+>\\|\\+\\)\\|\\(?:-\\(?:[<>|]\\|-\\)\\|-\\)\\|\\(?:/>\\|/\\)\\|\\(?:<\\(?:[<=]\\|-\\)\\|<\\)\\|\\(?:=\\(?:[<>|]\\|\\(?:=>\\|=\\)\\)\\|=\\)\\|\\(?:|\\(?:>\\|\\(?:||\\||\\)\\)\\||\\)\\|\\(?:~[>~]\\|~\\)\\)\\)") ;; <
(61 . ".\\(?:\\(?:!=\\|/=\\|:=\\|<<\\|\\(?:=[=>]\\|=\\)\\|\\(?:>>\\|>\\)\\)\\)") ;; =
(62 . ".\\(?:\\(?:\\(?:->\\|-\\)\\|:\\|\\(?:=>\\|=\\)\\|\\(?:>\\(?:[=>]\\|-\\)\\|>\\)\\)\\)") ;; >
(63 . ".\\(?:\\(?:[:=]\\|\\.\\|\\?\\)\\)") ;; ?
(70 . ".\\(?:l\\)") ;; F
(84 . ".\\(?:l\\)") ;; T
(91 . ".\\(?:\\(?::]\\||\\)\\)") ;; [
(92 . ".\\(?:/\\)") ;; \
(93 . ".\\(?:#\\)") ;; ]
(94 . ".\\(?:=\\)") ;; ^
(95 . ".\\(?:\\(?:_\\||_\\)\\)") ;; _
(102 . ".\\(?:l\\)") ;; f
(119 . ".\\(?:ww\\)") ;; w
(123 . ".\\(?:|\\)") ;; {
(124 . ".\\(?:\\(?:[>}]\\|\\(?:->\\|-\\)\\|\\(?:=>\\|=\\)\\|]\\|\\(?:|\\(?:[=>]\\|-\\||>\\)\\||\\)\\)\\)") ;; |
(126 . ".\\(?:\\(?:[=>@]\\|-\\|\\(?:~>\\|~\\)\\)\\)"))))
(dolist (char-regexp alist)
(set-char-table-range composition-function-table (car char-regexp)
`([,(cdr char-regexp) 0 font-shape-gstring]))))
(set-frame-font "Fira Code 11")
;; Auto-insert braces. Has some counter-intuitive behaviour, unfortunately.
(electric-pair-mode 1)
(setf electric-pair-skip-self nil)
(global-set-key [f11] 'toggle-frame-fullscreen)
(global-set-key (kbd "C-s") 'ripgrep-regexp)
(global-set-key (kbd "C-,") 'move-to-previous-window)
(global-set-key (kbd "C-.") 'move-to-next-window)
(global-set-key (kbd "M-i") 'xref-find-definitions)
(global-set-key (kbd "C-M-i") 'xref-pop-marker-stack)
(global-column-enforce-mode)
(global-linum-mode)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
(show-paren-mode 1)
(blink-cursor-mode 0)
(set-cursor-color "#ffffff")
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(inhibit-startup-screen t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)