From e459041e925d1faaf0d224ff29247d14901a1161 Mon Sep 17 00:00:00 2001 From: Aleksandr Lebedev Date: Thu, 30 Jan 2025 12:42:20 +0100 Subject: [PATCH] Emacs level up --- config.org | 225 ++++++++++++++++++++++++++++++++-------------------- package.nix | 1 + 2 files changed, 142 insertions(+), 84 deletions(-) diff --git a/config.org b/config.org index b3d12dd..0e55594 100644 --- a/config.org +++ b/config.org @@ -11,17 +11,16 @@ - [[#startup-time][Startup Time]] - [[#app-launcher][App Launcher]] - [[#standalone-run][Standalone run]] +- [[#backup-files-tilda-files][Backup files (tilda files)]] - [[#company][Company]] - [[#dashboard][Dashboard]] - [[#diminish][Diminish]] - [[#dired-file-manager][DIRED (File manager)]] +- [[#ediff][EDIFF]] - [[#flycheck][FLYCHECK]] - [[#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]] - - [[#disable-gui-elements][Disable GUI elements]] +- [[#sane-defaults][Sane defaults]] - [[#battery-info][Battery info]] - [[#magit][MAGIT]] - [[#minibuffer-escape][Minibuffer escape]] @@ -32,7 +31,6 @@ - [[#org-mode][ORG MODE]] - [[#enabling-table-of-contents][Enabling Table of Contents]] - [[#enabling-org-bullets][Enabling Org Bullets]] - - [[#disable-electric-indent][Disable Electric Indent]] - [[#org-level-headers][Org Level Headers]] - [[#source-code-block-tag-expansion][Source Code Block Tag Expansion]] - [[#org-roam][ORG ROAM]] @@ -47,13 +45,18 @@ - [[#vterm][Vterm]] - [[#vterm-toggle][Vterm-Toggle]] - [[#sudo-edit][SUDO EDIT]] +- [[#language-support][Language support]] + - [[#nix][Nix]] - [[#nerd-icons][Nerd Icons]] - [[#nerd-icons-completion][Nerd Icons Completion]] - [[#buffer-move][Buffer Move]] - [[#vertico][Vertico]] + - [[#consult][Consult]] + - [[#embark][Embark]] - [[#descriptions][Descriptions]] - [[#theme][Theme]] - [[#theme-loading][Theme loading]] +- [[#tldr][TLDR]] - [[#transparency][Transparency]] - [[#which-key][WHICH-KEY]] @@ -67,12 +70,17 @@ (setq evil-want-keybinding nil) (setq evil-vsplit-window-right t) (setq evil-split-window-below t) + (setq evil-undo-system 'undo-redo) ;; Adds vim-like C-r redo functionality (evil-mode)) (use-package evil-collection :ensure t :after evil :config - (setq evil-collection-mode-list '(dashboard dired ibuffer)) + ;; Do not uncomment this unless you want to specify each and every mode + ;; that evil-collection should works with. The following line is here + ;; for documentation purposes in case you need it. + ;; (setq evil-collection-mode-list '(calendar dashboard dired ediff info magit ibuffer)) + (add-to-list 'evil-collection-mode-list 'help) ;; evilify help mode (evil-collection-init)) (use-package evil-tutor :ensure t) @@ -107,6 +115,7 @@ (kylekrein/leader-keys "." '(find-file :wk "Find file") "f r" '(recentf-open :wk "Open recent file") + "f d" '(find-grep-dired :wk "Search for string in files in DIR") "TAB TAB" '(comment-line :wk "Comment lines")) (kylekrein/leader-keys "b" '(:ignore t :wk "buffer") @@ -118,13 +127,14 @@ "b r" '(revert-buffer :wk "Reload buffer")) (kylekrein/leader-keys -"e" '(:ignore t :wk "Eshell/Evaluate") +"e" '(:ignore t :wk "Eshell/Ediff/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") - "e s" '(eshell :which-key "Eshell")) + "e s" '(eshell :which-key "Eshell") + "e f" '(ediff-files :wk "Run ediff on a pair of files")) (kylekrein/leader-keys "h" '(:ignore t :wk "Help") @@ -376,6 +386,11 @@ To use it, create a global keyboard shortcut with the following code (app-launcher-run-app) (delete-frame)))) #+end_src +* Backup files (tilda files) +By default, Emacs creates automatic backups of files in their original directories, such “file.el” and the backup “file.el~”. This leads to a lot of clutter, so let’s tell Emacs to put all backups that it creates in the ~TRASH~ directory. +#+begin_src emacs-lisp +(setq backup-directory-alist '((".*" . "~/.local/share/Trash/files"))) +#+end_src * Company [[https://company-mode.github.io/][Company]] is a text completion framework for Emacs. The name stands for “complete anything”. Completion will start automatically after you type a few letters. Use M-n and M-p to select, to complete or to complete the common part. #+begin_src emacs-lisp @@ -450,6 +465,19 @@ This package implements hiding or abbreviation of the modeline displays (lighter ;;(add-hook 'peep-dired-hook 'evil-normalize-keymaps) #+end_src +* EDIFF +‘ediff’ is a diff program that is built into Emacs. By default, ‘ediff’ splits files vertically and places the ‘help’ frame in its own window. I have changed this so the two files are split horizontally and the ‘help’ frame appears as a lower split within the existing window. Also, I create my own ‘dt-ediff-hook’ where I add ‘j/k’ for moving to next/prev diffs. By default, this is set to ‘n/p’. +#+begin_src emacs-lisp +(setq ediff-split-window-function 'split-window-horizontally + ediff-window-setup-function 'ediff-setup-windows-plain) + +(defun dt-ediff-hook () + (ediff-setup-keymap) + (define-key ediff-mode-map "j" 'ediff-next-difference) + (define-key ediff-mode-map "k" 'ediff-previous-difference)) + +(add-hook 'ediff-mode-hook 'dt-ediff-hook) +#+end_src * FLYCHECK Install luacheck from your Linux distro’s repositories for flycheck to work correctly with lua files. Install python-pylint for flycheck to work with python files. Haskell works with flycheck as long as haskell-ghc or haskell-stack-ghc is installed. For more information on language support for flycheck, [[https://www.flycheck.org/en/latest/languages.html][read this]]. #+begin_src emacs-lisp @@ -502,23 +530,25 @@ You can use the bindings CTRL plus =/- for zooming in/out. You can also use CTR #+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 -** Disable GUI elements +* Sane defaults +The following settings are simple modes that are enabled (or disabled) so that Emacs functions more like you would expect a proper editor/IDE to function. #+begin_src emacs-lisp +(delete-selection-mode 1) ;; You can select text and delete it by typing. +(electric-indent-mode -1) ;; Turn off the weird indenting that Emacs does by default. +(electric-pair-mode 1) ;; Turns on automatic parens pairing +;; The following prevents <> from auto-pairing when electric-pair-mode is on. +;; Otherwise, org-tempo is broken when you try to