dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 184984cbfcc670fa63b32f2a7d04f69585f5bc52
parent 4465caa17d5bf4a14d3375414b0534fe97bd82fe
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Tue, 29 Jun 2021 15:01:54 +0200

emacs: various configuration

Diffstat:
Memacs/config.org | 141++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------
Memacs/init.el | 4+++-
2 files changed, 92 insertions(+), 53 deletions(-)

diff --git a/emacs/config.org b/emacs/config.org @@ -1,10 +1,49 @@ +* Theme + I want this to load first because otherwise it'll blind me during the night while it's trying to refresh packages. + + Icons required for some parts of the doom theme: + + #+begin_src emacs-lisp + (use-package all-the-icons) + #+end_src + + Load Doom emacs themes: + + #+begin_src emacs-lisp + (use-package doom-themes + :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 + + ;; Enable flashing mode-line on errors + (doom-themes-visual-bell-config) + + ;; Enable custom neotree theme (all-the-icons must be installed!) + (doom-themes-neotree-config) + ;; or for treemacs users + (setq doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme + (doom-themes-treemacs-config) + + ;; Corrects (and improves) org-mode's native fontification. + (doom-themes-org-config)) + #+end_src + + Change theme depending on the current system theme (I use the presence of the ~/.config/dark-theme file to indicate when dark theme is set): + + #+begin_src emacs-lisp + (if (file-exists-p "~/.config/dark-theme") + (load-theme 'doom-one t) + (load-theme 'doom-acario-light t)) + #+end_src + * Garbage collection Garbage-collect on focus-out, Emacs /should/ feel snappier. #+begin_src emacs-lisp (add-hook 'focus-out-hook #'garbage-collect) #+end_src - + * Package management ** Repositories (MELPA & Org) #+begin_src emacs-lisp @@ -15,8 +54,11 @@ (package-refresh-contents) (package-initialize) #+end_src - + ** use-package + Install and load use-package. + Use-package tidies up package configuration and reduces the verboseness of configuration. + #+begin_src emacs-lisp (unless (package-installed-p 'use-package) (package-install 'use-package)) @@ -32,7 +74,7 @@ * Packages ** exec-path-from-shell (macOS) - + In macOS, the path is not set correctly in the GUI app. This fixes it. #+begin_src emacs-lisp (when (memq window-system '(mac ns x)) @@ -49,11 +91,11 @@ :config (which-key-mode)) #+end_src - + ** helm Better incremental completion and selection narrowing. Generally makes for nicer interactivity. - + #+begin_src emacs-lisp (use-package helm :defer nil @@ -78,11 +120,11 @@ (helm-mode) (savehist-mode)) #+end_src - + ** org In org mode, I want to use bullets instead of stars. Also, I add a few expansions - + #+begin_src emacs-lisp (use-package org :config @@ -95,18 +137,32 @@ :hook (org-mode . (lambda () (org-bullets-mode 1)))) #+end_src - + ** lean-mode - Shift completion for lean-mode and company-lean: + Specifically for the Lean prover. + I also install company-lean and helm-lean, which are suggested on the [[https://github.com/leanprover/lean-mode][Github page]]. + Then I map company-complete only for lean-mode. #+begin_src emacs-lisp - (global-set-key (kbd "S-SPC") #'company-complete) - #+end_src + (use-package lean-mode + :config + (unless (package-installed-p 'company-lean) + (package-refresh-contents) + (package-install 'company-lean)) + (require 'company-lean) + (unless (package-installed-p 'helm-lean) + (package-refresh-contents) + (package-install 'helm-lean)) + (require 'helm-lean) + + :hook + (lean-mode . (lambda () (define-key lean-mode-map (kbd "S-SPC") #'company-complete)))) + #+end_src * Interface ** GUI elements Get rid of all bars. - + #+begin_src emacs-lisp (setq org-src-tab-acts-natively t) (when window-system @@ -115,10 +171,10 @@ (scroll-bar-mode -1) (tooltip-mode -1)) #+end_src - + ** Messages Hide some messages I don't need. - + #+begin_src emacs-lisp (setq inhibit-startup-message t) (setq initial-scratch-message "") @@ -133,49 +189,12 @@ #+end_src Relative line numbers: - + #+begin_src emacs-lisp (setq display-line-numbers-type 'relative) (global-display-line-numbers-mode) #+end_src -* Theme - Icons required for some parts of the doom theme: - - #+begin_src emacs-lisp - (use-package all-the-icons) - #+end_src - - Load Doom emacs themes: - - #+begin_src emacs-lisp - (use-package doom-themes - :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 - - ;; Enable flashing mode-line on errors - (doom-themes-visual-bell-config) - - ;; Enable custom neotree theme (all-the-icons must be installed!) - (doom-themes-neotree-config) - ;; or for treemacs users - (setq doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme - (doom-themes-treemacs-config) - - ;; Corrects (and improves) org-mode's native fontification. - (doom-themes-org-config)) - #+end_src - - Change theme depending on the current system theme (I use the presence of the ~/.config/dark-theme file to indicate when dark theme is set): - - #+begin_src emacs-lisp - (if (file-exists-p "~/.config/dark-theme") - (load-theme 'doom-one t) - (load-theme 'doom-one-light t)) - #+end_src - * Backup files By default, backup files (those with a tilde) are saved in the same directory as the currently edited file. This setting puts them in ~/.local/share/emacs/saves. @@ -184,3 +203,21 @@ (setq backup-directory-alist '(("." . "~/.local/share/emacs/saves"))) (setq backup-by-copying t) #+end_src + +* Editor +** Strip trailing whitespace + You can show trailing whitespace by setting show-trailing-whitespace to 't'. + But I want to automatically strip trailing whitespace. + Luckily there's already a function for that, I just need to call it in a hook: + + #+begin_src emacs-lisp + (add-hook 'before-save-hook 'delete-trailing-whitespace) + #+end_src +* Misc settings +** Enable all commands + By default, Emacs disables some commands. + I want to have these enabled so I don't get a prompt whenever I try to use a disabled command. + + #+begin_src emacs-lisp + (setq disabled-command-function nil) + #+end_src diff --git a/emacs/init.el b/emacs/init.el @@ -9,8 +9,10 @@ ;; 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. + '(custom-safe-themes + '("f2927d7d87e8207fa9a0a003c0f222d45c948845de162c885bf6ad2a255babfd" "e3c64e88fec56f86b49dcdc5a831e96782baf14b09397d4057156b17062a8848" "f4876796ef5ee9c82b125a096a590c9891cec31320569fc6ff602ff99ed73dca" default)) '(package-selected-packages - '(anki-connect anki-editor doom-themes all-the-icons use-package-ensure which-key use-package org-bullets helm exec-path-from-shell))) + '(lean-mode markdown-mode anki-connect anki-editor doom-themes all-the-icons use-package-ensure which-key use-package org-bullets helm exec-path-from-shell))) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful.