#+TITLE: KyleKrein's GNU Emacs Config #+STARTUP: showeverything #+OPTIONS: toc:2 #+PROPERTY: header-args:emacs-lisp :lexical t * Table of contents :toc: - [[#important-programs-to-load-first][IMPORTANT PROGRAMS TO LOAD FIRST]] - [[#evil-mode][Evil Mode]] - [[#recent-files][Recent Files]] - [[#general-keybindings][General Keybindings]] - [[#fonts][Fonts]] - [[#zooming-inout][Zooming In/Out]] - [[#graphical-user-interface-tweaks][GRAPHICAL USER INTERFACE TWEAKS]] - [[#disable-menubar-toolbars-and-scrollbars][Disable Menubar, Toolbars and Scrollbars]] - [[#display-line-numbers-and-truncated-lines][Display Line Numbers and Truncated Lines]] - [[#org-mode][ORG MODE]] - [[#enabling-table-of-contents][Enabling Table of Contents]] - [[#enabling-org-bullets][Enabling Org Bullets]] - [[#disable-electric-indent][Disable Electric Indent]] - [[#source-code-block-tag-expansion][Source Code Block Tag Expansion]] - [[#rainbow-mode][RAINBOW MODE]] - [[#shells-and-terminals][SHELLS AND TERMINALS]] - [[#eshell][Eshell]] - [[#vterm][Vterm]] - [[#vterm-toggle][Vterm-Toggle]] - [[#sudo-edit][SUDO EDIT]] - [[#nerd-icons][Nerd Icons]] - [[#nerd-icons-completion][Nerd Icons Completion]] - [[#buffer-move][Buffer Move]] - [[#vertico][Vertico]] - [[#descriptions][Descriptions]] - [[#theme][Theme]] - [[#theme-loading][Theme loading]] - [[#which-key][WHICH-KEY]] * IMPORTANT PROGRAMS TO LOAD FIRST ** Evil Mode #+begin_src emacs-lisp :lexical t (use-package evil :ensure t :init ;; tweak evil's configuration before loading it (setq evil-want-integration t) ;; This is optional since it's already set to t by default. (setq evil-want-keybinding nil) (setq evil-vsplit-window-right t) (setq evil-split-window-below t) (evil-mode)) (use-package evil-collection :ensure t :after evil :config (setq evil-collection-mode-list '(dashboard dired ibuffer)) (evil-collection-init)) (use-package evil-tutor :ensure t) #+end_src ** Recent Files #+begin_src emacs-lisp (recentf-mode t) #+end_src ** General Keybindings #+begin_src emacs-lisp (use-package general :ensure t :config (general-evil-setup) ) (require 'general) ;; If i do this in :config, it says that function is wrong ;; set up 'SPC' as the global leader key (general-create-definer kylekrein/leader-keys :states '(normal insert visual emacs) :keymaps 'override :prefix "SPC" ;; set leader :global-prefix "M-SPC") ;; access leader in insert mode (kylekrein/leader-keys "." '(find-file :wk "Find file") "f r" '(recentf-open :wk "Open recent file") "TAB TAB" '(comment-line :wk "Comment lines")) (kylekrein/leader-keys "b" '(:ignore t :wk "buffer") "b b" '(switch-to-buffer :wk "Switch buffer") "b i" '(ibuffer :wk "Ibuffer") "b k" '(kill-this-buffer :wk "Kill this buffer") "b n" '(next-buffer :wk "Next buffer") "b p" '(previous-buffer :wk "Previous buffer") "b r" '(revert-buffer :wk "Reload buffer")) (kylekrein/leader-keys "e" '(:ignore t :wk "Evaluate") "e b" '(eval-buffer :wk "Evaluate elisp in buffer") "e d" '(eval-defun :wk "Evaluate defun containing or after point") "e e" '(eval-expression :wk "Evaluate and elisp expression") "e l" '(eval-last-sexp :wk "Evaluate elisp expression before point") "e r" '(eval-region :wk "Evaluate elisp in region")) (kylekrein/leader-keys "h" '(:ignore t :wk "Help") "h f" '(describe-function :wk "Describe function") "h v" '(describe-variable :wk "Describe variable")) ;;"h r r" '((lambda () (interactive) (load-file "~/.config/emacs/init.el")) :wk "Reload emacs config")) ;;"h r r" '(reload-init-file :wk "Reload emacs config")) (kylekrein/leader-keys "t" '(:ignore t :wk "Toggle") "t l" '(display-line-numbers-mode :wk "Toggle line numbers") "t t" '(visual-line-mode :wk "Toggle truncated lines")) (kylekrein/leader-keys "w" '(:ignore t :wk "Windows") ;; Window splits "w c" '(evil-window-delete :wk "Close window") "w n" '(evil-window-new :wk "New window") "w s" '(evil-window-split :wk "Horizontal split window") "w v" '(evil-window-vsplit :wk "Vertical split window") ;; Window motions "w h" '(evil-window-left :wk "Window left") "w j" '(evil-window-down :wk "Window down") "w k" '(evil-window-up :wk "Window up") "w l" '(evil-window-right :wk "Window right") "w w" '(evil-window-next :wk "Goto next window") ;; Move Windows "w H" '(buf-move-left :wk "Buffer move left") "w J" '(buf-move-down :wk "Buffer move down") "w K" '(buf-move-up :wk "Buffer move up") "w L" '(buf-move-right :wk "Buffer move right")) #+end_src * Fonts Defining the various fonts that Emacs will use. #+begin_src emacs-lisp (set-face-attribute 'default nil :font "JetBrains Mono" :height 110 :weight 'medium) (set-face-attribute 'variable-pitch nil :font "Ubuntu" :height 120 :weight 'medium) (set-face-attribute 'fixed-pitch nil :font "JetBrains Mono" :height 110 :weight 'medium) ;; Makes commented text and keywords italics. ;; This is working in emacsclient but not emacs. ;; Your font must have an italic face available. (set-face-attribute 'font-lock-comment-face nil :slant 'italic) (set-face-attribute 'font-lock-keyword-face nil :slant 'italic) ;; This sets the default font on all graphical frames created after restarting Emacs. ;; Does the same thing as 'set-face-attribute default' above, but emacsclient fonts ;; are not right unless I also add this method of setting the default font. (add-to-list 'default-frame-alist '(font . "JetBrains Mono-11")) ;; Uncomment the following line if line spacing needs adjusting. (setq-default line-spacing 0.12) #+end_src ** Zooming In/Out You can use the bindings CTRL plus =/- for zooming in/out. You can also use CTRL plus the mouse wheel for zooming in/out. #+begin_src emacs-lisp (global-set-key (kbd "C-=") 'text-scale-increase) (global-set-key (kbd "C--") 'text-scale-decrease) (global-set-key (kbd "") 'text-scale-increase) (global-set-key (kbd "") 'text-scale-decrease) #+end_src * GRAPHICAL USER INTERFACE TWEAKS Let's make GNU Emacs look a little better. ** Disable Menubar, Toolbars and Scrollbars #+begin_src emacs-lisp (menu-bar-mode -1) (tool-bar-mode -1) (scroll-bar-mode -1) #+end_src ** Display Line Numbers and Truncated Lines #+begin_src emacs-lisp (global-display-line-numbers-mode 1) (global-visual-line-mode t) #+end_src * ORG MODE ** Enabling Table of Contents #+begin_src emacs-lisp (use-package toc-org :ensure t :commands toc-org-enable :init (add-hook 'org-mode-hook 'toc-org-enable)) #+end_src ** Enabling Org Bullets Org-bullets gives us attractive bullets rather than asterisks. #+begin_src emacs-lisp (add-hook 'org-mode-hook 'org-indent-mode) (use-package org-bullets :ensure t) (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))) #+end_src ** Disable Electric Indent Org mode source blocks have some really weird and annoying default indentation behavior. I think this has to do with electric-indent-mode, which is turned on by default in Emacs. So let's turn it OFF! #+begin_src emacs-lisp (electric-indent-mode -1) #+end_src ** Source Code Block Tag Expansion Org-tempo is not a separate package but a module within org that can be enabled. Org-tempo allows for '