From 7cee70abbac34381c41a57589430af233f8ba443 Mon Sep 17 00:00:00 2001 From: Aleksandr Lebedev Date: Tue, 28 Jan 2025 16:47:15 +0100 Subject: [PATCH] Made emacs more useful --- config.org | 409 ++++++++++++++++++++++++++++++++++++++++++++++++++-- package.nix | 1 + 2 files changed, 396 insertions(+), 14 deletions(-) diff --git a/config.org b/config.org index 5db4887..d1928d4 100644 --- a/config.org +++ b/config.org @@ -3,6 +3,35 @@ #+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 @@ -24,22 +53,75 @@ (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) - ;; set up 'SPC' as the global leader key - (general-create-definer leader-keys - :states '(normal insert visual emacs) - :keymaps 'override - :prefix "SPC" ;; set leader - :global-prefix "M-SPC") ;; access leader in insert mode - (leader-keys - "." '(find-file :wk "Find file") - "TAB TAB" '(comment-line :wk "Comment lines")) - ) + (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 @@ -75,6 +157,17 @@ Defining the various fonts that Emacs will use. (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. @@ -107,7 +200,295 @@ Org-bullets gives us attractive bullets rather than asterisks. (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 '