From 940156e3119a10cf60a2429a11be5abfc319d004 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 5 Nov 2023 18:52:22 +0100 Subject: [PATCH] Clean up a bit --- emacs/emacs.el | 97 +++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 53 deletions(-) diff --git a/emacs/emacs.el b/emacs/emacs.el index 023fc7a..0ac9a46 100644 --- a/emacs/emacs.el +++ b/emacs/emacs.el @@ -11,6 +11,13 @@ (setq scroll-conservatively 10000) (setq auto-window-vscroll nil) +;; Do not spill temporary files everywhere +;; https://stackoverflow.com/a/18330742 +(defvar --backup-directory (concat user-emacs-directory "backups")) +(if (not (file-exists-p --backup-directory)) + (make-directory --backup-directory t)) +(setq backup-directory-alist `(("." . ,--backup-directory))) + ;; Colorblind friendly theme. (require-theme 'modus-themes) (load-theme 'modus-operandi :no-confirm) @@ -24,74 +31,57 @@ (package-initialize) ;; Install xclip so cutting/copying in Emacs on a terminal affects the graphical clipboard - (use-package xclip :ensure t - :init + :config (xclip-mode 1)) ;; Fancy undo - (use-package undo-tree - :ensure t) - -(global-undo-tree-mode) -(setq undo-tree-visualizer-diff t) -(setq undo-tree-visualizer-timestamp t) -(setq undo-tree-auto-save-history t) - -;; Do not spill temporary files everywhere - -;; https://stackoverflow.com/a/18330742 -(defvar --backup-directory (concat user-emacs-directory "backups")) -(if (not (file-exists-p --backup-directory)) - (make-directory --backup-directory t)) -(setq backup-directory-alist `(("." . ,--backup-directory))) - -;; https://www.reddit.com/r/emacs/comments/tejte0/undotree_bug_undotree_files_scattering_everywhere/?rdt=39892 -(setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo"))) + :ensure t + :config + (global-undo-tree-mode) + (setq undo-tree-visualizer-diff t) + (setq undo-tree-visualizer-timestamp t) + (setq undo-tree-auto-save-history t) + ;; https://www.reddit.com/r/emacs/comments/tejte0/undotree_bug_undotree_files_scattering_everywhere/?rdt=39892 + (setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo")))) ;; nicer completion UI - (use-package helm - :ensure t) - -(global-set-key (kbd "M-x") #'helm-M-x) -(global-set-key (kbd "C-x C-f") #'helm-find-files) -(global-set-key (kbd "C-x C-b") #'helm-mini) - -(setq helm-ff-skip-boring-files t) + :ensure t + :config + (global-set-key (kbd "M-x") #'helm-M-x) + (global-set-key (kbd "C-x C-f") #'helm-find-files) + (global-set-key (kbd "C-x C-b") #'helm-mini) + (setq helm-ff-skip-boring-files t)) ;; LSP base for Rust and Java - (use-package lsp-mode :ensure t) + (use-package company - :ensure t) -(add-hook 'after-init-hook 'global-company-mode) + :ensure t + :config + (add-hook 'after-init-hook 'global-company-mode)) (use-package lsp-ui :ensure t) (use-package yasnippet :ensure t) -(add-hook 'java-mode-hook (lambda () - (setq c-basic-offset 2 - indent-tabs-mode f))) - (yas-global-mode 1) ;; Rust support - (use-package rust-mode - :ensure t) -(add-hook 'rust-mode-hook #'lsp) -(add-hook 'rust-mode-hook - (lambda () (setq indent-tabs-mode nil))) -(setq rust-format-on-save t) + :ensure t + :config + (add-hook 'rust-mode-hook #'lsp) + (add-hook 'rust-mode-hook + (lambda () (setq indent-tabs-mode nil))) + (setq rust-format-on-save t)) ;; Python support - ; https://github.com/jorgenschaefer/elpy/issues/1890#issuecomment-792361668 ; Need to downgrade jedi to get it to work :( (use-package elpy @@ -100,22 +90,24 @@ (elpy-enable)) ;;; Java Support - (use-package lsp-java - :ensure t) -(add-hook 'java-mode-hook 'lsp) + :ensure t + :config + (add-hook 'java-mode-hook 'lsp) + (add-hook 'java-mode-hook (lambda () + (setq c-basic-offset 2 + indent-tabs-mode f)))) ;; YAML support - (use-package yaml-mode :ensure t) ;; lsp-mode seems unusably slow, so don't install the Ansible language server ;; if you want to get it working, try https://www.reddit.com/r/emacs/comments/ybbkks/how_to_properly_set_up_lsp_ansible_language/itfxoaa/ - (use-package ansible - :ensure t) -(add-hook 'yaml-mode-hook 'ansible) + :ensure t + :config + (add-hook 'yaml-mode-hook 'ansible)) ;; Puppet support; mostly for syntax highlighting @@ -125,7 +117,6 @@ ;; ==== WORK ==== ;; Abbrevs for work, declared in emacs.el for version control - (clear-abbrev-table global-abbrev-table) (progn @@ -139,10 +130,10 @@ (setq save-abbrevs nil) ;; AsciiDoc + Vale + Aspell support for work - (use-package adoc-mode - :ensure t) -(add-hook 'adoc-mode-hook #'abbrev-mode) + :ensure t + :config + (add-hook 'adoc-mode-hook #'abbrev-mode)) (cl-defun slot/vc-install (&key (fetcher "github") repo name rev backend) (let* ((url (format "https://www.%s.com/%s" fetcher repo)) -- 2.47.3