blob: dd3b611a166c4f4653778c5419b87fc8ea09b244 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
;; symlink this file to ~/.emacs
;; M-x package-refresh-contents if some package 404s
;; Nicer defaults
(setq compilation-scroll-output t)
(setq column-number-mode t) ; in the mode line
(setq-default show-trailing-whitespace t)
(global-whitespace-mode)
(setopt whitespace-style '(tab-mark))
(xterm-mouse-mode 1)
(save-place-mode t) ; persists your position in files
(setq custom-file "~/.emacs.d/disable-custom-variable-saving")
(load-theme 'modus-vivendi :no-confirm) ; colorblind-friendly theme
(fido-vertical-mode) ; nice completion for M-x
(which-key-mode) ; learn keyboard shortcuts
(global-completion-preview-mode 1) ; show things that you can tab-complete
(setq tab-always-indent 'complete) ; allow tab to complete
(setq text-mode-ispell-word-completion nil) ; but do not complete dictionary words
(windmove-default-keybindings) ; S-cursor to move to different windows
(setq org-startup-folded t)
(editorconfig-mode 1)
(add-hook 'js-json-mode-hook
(lambda ()
(setq indent-tabs-mode nil)
(setq js-indent-level 2)))
;; 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)))
;; Configure the package manager. Some packages I use are not in the default repositories
(require 'use-package-ensure)
(setq use-package-always-ensure t)
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
;; Install xclip so cutting/copying in Emacs on a terminal affects the graphical clipboard
(use-package xclip
:ensure t
:config
(xclip-mode 1))
;; Fancy undo
(use-package undo-tree
: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"))))
;; for eglot snippet completion
(use-package yasnippet :ensure t)
(yas-global-mode 1)
;; Rust support
;; rustic-enable-detached-file-support seems to be problematic :(
(use-package rustic
:ensure t
:config
(setq rustic-format-on-save t)
(setq rustic-rustfmt-args "--edition 2018")
(setq rustic-lsp-client 'eglot)
;; https://github.com/emacs-rustic/rustic/issues/99
(put 'rustic-indent-offset 'safe-local-variable 'integerp)
(add-hook 'rustic-mode-hook
(lambda () (setq indent-tabs-mode nil))))
;; https://download.eclipse.org/jdtls/milestones/1.43.0/jdt-language-server-1.43.0-202412191447.tar.gz is the last language server that supports Debian 12 JDK
;; Untar the archive and symlink the jdtls binary in ~/.local/bin
(add-hook 'java-mode-hook 'eglot-ensure)
;; pipx install basedpyright
(add-hook 'python-mode-hook 'eglot-ensure)
;; The default setting is higher than strict, and complains (amongst others) about missing type annotations
(setq-default eglot-workspace-configuration
'(:basedpyright (:typeCheckingMode "strict")
:basedpyright.analysis (:diagnosticSeverityOverrides (
:reportMissingParameterType "none"
:reportUnknownParameterType "none"
:reportUnknownVariableType "none"
:reportUnknownMemberType "none"
:reportUnknownArgumentType "none"))))
;; YAML support
(use-package yaml-mode :ensure t)
;; Puppet support; mostly for syntax highlighting
(use-package puppet-mode :ensure t)
;; Python notebooks
(use-package ein
:ensure t
:config
(defvar ein:jupyter-default-notebook-directory (concat user-emacs-directory "ein")))
(use-package ledger-mode :ensure t)
;; Sometimes I like playing with Prolog
(setq prolog-system 'swi)
(setq auto-mode-alist (append '(("\\.pl\\'" . prolog-mode))
auto-mode-alist))
;; for typescript and tsx, use treesit-install-language-grammar to enable the built-in Emacs modes; interactive install is fine, see https://www.masteringemacs.org/article/how-to-get-started-tree-sitter
(add-hook 'tsx-ts-mode-hook 'eglot-ensure)
(add-hook 'typescript-ts-mode-hook 'eglot-ensure)
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'(tsx-ts-mode . ("npx" "typescript-language-server" "--stdio"))))
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'(typescript-ts-mode . ("npx" "typescript-language-server" "--stdio"))))
(add-to-list 'auto-mode-alist '("\\.ts" . typescript-ts-mode))
(add-to-list 'auto-mode-alist '("\\.tsx" . tsx-ts-mode))
(use-package sql-indent
:ensure t
:config
(add-hook 'sql-mode-hook 'sqlind-minor-mode))
;; the following is a bit fiddly, eglot requires some extra love to have extra flymake providers
(use-package flymake-vale
:vc (:url "https://github.com/tpeacock19/flymake-vale.git"
:rev :newest)
:config
(add-hook 'find-file-hook 'flymake-vale-maybe-load)
(add-to-list 'flymake-vale-modes 'rustic-mode))
(setq eglot-stay-out-of '(flymake))
(add-hook 'eglot--managed-mode-hook (lambda ()
(add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t)
(flymake-mode 1)))
(add-hook 'markdown-mode-hook 'flymake-mode)
|