]> Git — Sourcephile - julm/julm-nix.git/blob - home-manager/profiles/emacs/config.el
wireguard: use LoadCrendentialEncrypted=
[julm/julm-nix.git] / home-manager / profiles / emacs / config.el
1 ;;; config.el -*- lexical-binding: t; -*-
2
3 ;; DOC: https://git.v0.io/hlissner/doom-emacs/src/commit/a680a4c96d2b57fcb75635bd1a918e1235e72890/docs/api.org
4 ;; DOC: https://github.com/daviwil/emacs-from-scratch
5
6 ;; Line numbers are pretty slow all around. The performance boost of
7 ;; disabling them outweighs the utility of always keeping them on.
8 (setq display-line-numbers-type nil)
9 (global-visual-line-mode t)
10
11 ;; Focus new window after splitting
12 (setq evil-split-window-below t
13 evil-vsplit-window-right t
14 )
15
16 ;; Undo
17 (setq undo-tree-auto-save-history t
18 undo-tree-history-directory-alist '(("." . "~/.cache/emacs/undo"))
19 )
20
21 ;; Fonts
22 (setq doom-font-increment 1
23 doom-font-size 9
24 ;doom-font-name "DejaVu Sans Mono"
25 doom-font-name "Hack"
26 ;doom-font-name "Unifont"
27 doom-font (font-spec :family doom-font-name :size doom-font-size :antialias t)
28 doom-unicode-font (font-spec :family "Symbola" :antialias t)
29 doom-variable-pitch-font (font-spec :family doom-font-name :antialias t)
30 ivy-posframe-font (font-spec :family doom-font-name :antialias t)
31 )
32 (setq x-underline-at-descent-line t)
33
34 ;; Dashboard
35 ;;(setq +doom-dashboard-banner-file (expand-file-name "banner.png" doom-private-dir))
36 (defun bury-messages-and-scratch ()
37 (mapcar #'bury-buffer '("*Messages*" "*scratch*")))
38 (add-hook 'emacs-startup-hook #'bury-messages-and-scratch)
39
40 ;; Formatting
41 (setq haskell-stylish-on-save nil)
42 (setq lsp-haskell-formatting-provider "fourmolu")
43 (setq +format-on-save-enabled-modes
44 '(not emacs-lisp-mode ; works well enough without it
45 sql-mode ; sqlformat is broken
46 tex-mode ; latexindent is broken
47 latex-mode ; latexindent is broken
48 bibtex-mode ; is broken
49 ess-r-mode ; styler takes forever
50 )
51 )
52
53 ;; Theming
54 (setq doom-theme 'doom-vibrant)
55 (custom-theme-set-faces! '(doom-vibrant)
56 '(default :background "black" :foreground "white")
57 '(hl-line :background "black")
58 '(cursor :background "DarkOrange" :foreground "black")
59 ;; Haskell colors
60 '(font-lock-string-face :foreground "magenta")
61 '(highlight-numbers-number :foreground "DeepSkyBlue" :bold t)
62 '(font-lock-comment-face :foreground "cyan3")
63 '(font-lock-doc-face :foreground "cyan1")
64 ;'(haskell-constructor-face :foreground "#c4451d")
65 ;'(haskell-keyword-face :foreground "#af005f")
66 ;'(haskell-keyword-face :foreground "RoyalBlue")
67 ;'(haskell-keyword-face :foreground "#44385f")
68 ;'(haskell-keyword-face :foreground "#906238" :bold t)
69 ;'(haskell-keyword-face :foreground "green4" :bold t)
70 '(haskell-keyword-face :foreground "LightGreen" :bold nil)
71 ;'(haskell-pragma-face :foreground "#2aa198")
72 '(haskell-pragma-face :foreground "#8f4e8b")
73 ;'(haskell-type-face :foreground "#9e358f")
74 '(haskell-operator-face :foreground "yellow" :bold nil)
75 ;'(haskell-type-face :foreground "SaddleBrown")
76 ;'(haskell-constructor-face :foreground "darkgoldenrod4")
77 '(haskell-definition-face :foreground "white" :bold nil)
78 '(swiper-line-face :background "grey15")
79 '(swiper-match-face-1 :foreground "grey50" :background "black") ; what is between matches
80 '(swiper-match-face-2 :foreground "black" :background "yellow2")
81 '(swiper-match-face-3 :foreground "black" :background "yellow3")
82 '(swiper-match-face-4 :foreground "black" :background "yellow4")
83 '(swiper-background-match-face-2 :foreground "black" :background "yellow2")
84 '(swiper-background-match-face-3 :foreground "black" :background "yellow3")
85 '(swiper-background-match-face-4 :foreground "black" :background "yellow4")
86 '(evil-ex-lazy-highlight :foreground "black" :background "yellow2")
87 '(region :foreground "black" :background "yellow") ; selected area
88 '(doom-modeline-buffer-modified :foreground "orange")
89 '(git-gutter-fr:added :foreground "green4" :background "black")
90 '(git-gutter-fr:deleted :foreground "red4" :background "black")
91 '(git-gutter-fr:modified :foreground "orange4" :background "black")
92 '(flycheck-fringe-error :foreground "red")
93 '(flycheck-fringe-warning :foreground "orange")
94 '(flycheck-fringe-info :foreground "purple")
95 '(flycheck-info :underline '(:color "SkyBlue4" :style wave))
96 '(flycheck-warning :underline '(:color "orange" :style wave))
97 '(flycheck-error :underline '(:color "red" :style wave))
98 '(warning :foreground "orange")
99 '(error :foreground "red")
100 '(ivy-minibuffer-match-face-1 :foreground "grey50" :background "black") ; what is between matches
101 '(ivy-minibuffer-match-face-2 :foreground "black" :background "yellow2")
102 '(ivy-minibuffer-match-face-3 :foreground "black" :background "yellow3")
103 '(ivy-minibuffer-match-face-4 :foreground "black" :background "yellow4")
104 ; Violet
105 ;'(haskell-operator-face :foreground "yellow3")
106 ;'(haskell-type-face :foreground "#5a4e82")
107 ;'(haskell-constructor-face :foreground "#8a4f88")
108 ;'(haskell-constructor-face :foreground "#8a4c87")
109 '(haskell-constructor-face :foreground "white" :bold t)
110 ; Almost the same as haskell-constructor-face
111 ; because that pattern does not match on type-contexts correctly
112 '(haskell-type-face :foreground "white" :bold t)
113 '(lsp-face-highlight-read :background "gray10")
114 '(lsp-face-highlight-write :background "gray10")
115 '(mode-line :background "gray20")
116 '(mode-line-inactive :background "gray5")
117 '(solaire-default-face :background "gray10")
118 '(solaire-mode-line-face :background "gray20")
119 '(solaire-mode-line-inactive-face :background "gray5")
120 '(doom-modeline-project-dir :foreground "DeepSkyBlue" :bold t)
121 ;'(magit-diff-context-highlight :foreground "white" :background "black")
122 '(magit-diff-added-highlight :foreground "green")
123 '(magit-diff-removed-highlight :foreground "red")
124 ;;'(font-lock-comment-face ((t (:foreground "cyan" :italic t :slant oblique))))
125 ;;'(font-lock-comment-delimiter-face ((t (:foreground "cyan"))))
126 ;;'(fringe ((t (:foreground "red" :background "black"))))
127 ;;'(whitespace-indentation ((t (:foreground "gray50" :bold t))))
128 ;;'(whitespace-space ((t (:foreground "black" :bold t))))
129 ;;'(whitespace-tab ((t (:foreground "gray50" :bold t))))
130 ;;'(whitespace-trailing ((t (:foreground "red" :bold t))))
131 ;;'(font-lock-builtin-face ((t (:foreground "yellow" :weight bold))))
132 ;;'(font-lock-keyword-face ((t (:foreground "yellow" :weight bold))))
133 ;;'(font-lock-string-face ((t (:foreground "magenta"))))
134 ;;'(font-lock-variable-name-face ((t (:foreground "SpringGreen3" :weight bold))))
135 ;;'(nix-antiquote-face ((t (:foreground "blue"))))
136 ;;'(mode-line ((t (:background "midnight blue" :box (:line-width 1 :color "blue") :height 1.0))))
137 ;;'(mode-line-inactive ((t (:background "grey30" :foreground "white" :box (:line-width 1 :color "grey30") :weight light :height 1.0))))
138 ;;'(mode-line ((t (:family "Noto Sans" :height 0.9))))
139 ;;'(mode-line-inactive ((t (:family "Noto Sans" :height 0.9))))
140 ;;'(solaire-mode-line-inactive-face ((t (:background "gray10"))))
141 )
142
143 ;; polymode
144 (use-package! polymode)
145 (define-hostmode poly-haskell-hostmode
146 :mode 'haskell-mode)
147 ;; Support org tables in Haskell files
148 (defun pm--org-table-tail-matcher (ahead)
149 (when (re-search-forward "^[^|]" nil t ahead)
150 (cons (match-beginning 0) (match-end 0))))
151 (define-innermode poly-haskell-org-table-innermode
152 :mode 'org-mode
153 :head-matcher "^|.*"
154 :tail-matcher #'pm--org-table-tail-matcher
155 :head-mode 'body
156 :tail-mode 'host)
157 (define-polymode poly-haskell-mode
158 :hostmode 'poly-haskell-hostmode
159 :innermodes '(poly-haskell-org-table-innermode))
160
161 ;; Language Server Protocol
162 (setq ;+lsp-prompt-to-install-server 'quiet
163 ;lsp-enable-file-watchers nil
164 ;lsp-enable-indentation nil
165 ;lsp-enable-on-type-formatting nil
166 ;lsp-enable-symbol-highlighting nil
167 lsp-enable-symbol-highlighting nil ; slow
168 lsp-ui-doc-enable nil ; slow
169 ;lsp-ui-sideline-enable nil ; not anymore useful than flycheck
170 ;lsp-ui-peek-enable t
171 ;lsp-ui-peek-always-show nil
172 ;lsp-ui-flycheck-enable t
173 ;lsp-ui-flycheck-live-reporting t
174 ;; Disable help mouse-overs for mode-line segments (i.e. :help-echo text).
175 ;; They're generally unhelpful and only add confusing visual clutter.
176 mode-line-default-help-echo nil
177 show-help-function nil
178 global-prettify-symbols-mode nil
179 prettify-symbols-mode -1
180 lsp-treemacs-errors-position-params `((side . right))
181 lsp-log-io nil ; Only for debugging
182 lsp-restart 'auto-restart
183 ; Only load lsp-clients to speed up loading
184 ; See https://github.com/emacs-lsp/lsp-mode/pull/1498
185 lsp-client-packages '(lsp-clients)
186 lsp-ui-sideline-show-code-actions t
187 )
188
189 ;; The modeline is not useful to me in the popup window.
190 ;; It looks much nicer to hide it.
191 (remove-hook 'emacs-everywhere-init-hooks #'hide-mode-line-mode)
192
193 ;;(remove-hook 'window-setup-hook #'doom-init-theme-h)
194 ;;(add-hook 'after-init-hook #'doom-init-theme-h 'append)
195 ;;(delq! t custom-theme-load-path)
196
197 (setq auto-save-default t ; Nobody likes to loose work, I certainly don't
198 confirm-kill-emacs t
199 confirm-kill-processes nil
200 make-backup-files nil
201 password-cache-expiry nil ; I can trust my computers ... can't I?
202 scroll-margin 10
203 ;; scroll-preserve-screen-position 'always ; Don't have `point' jump around
204 truncate-string-ellipsis "…" ; Unicode ellispis are nicer than "...", and also save /precious/ space
205 kill-whole-line t ; Make Ctrl-K remove the whole line, instead of just emptying it
206 undo-limit 80000000 ; Raise undo-limit to 80MB
207 x-stretch-cursor nil ; Disorienting
208 )
209
210 ;; Debugging
211 ;(setq debug-on-quit t)
212
213 ;; Haskell
214 (setq haskell-process-log nil
215 haskell-interactive-popup-errors nil
216 )
217 (add-hook 'haskell-mode-hook
218 (lambda ()
219 (set (make-local-variable 'company-backends)
220 (append '((company-capf company-dabbrev-code))
221 company-backends))))
222 (define-hostmode poly-haskell-hostmode
223 :mode 'haskell-mode)
224
225 ;; Layout
226 (setq split-height-threshold nil
227 split-width-threshold 160
228 )
229
230 ;; vterm
231 (after! vterm
232 (set-popup-rule! "*doom:vterm-popup:*" :side 'right :size 0.33 :vslot -4 :select t :quit nil :ttl 0)
233 (setq vterm-kill-buffer-on-exit t
234 vterm-max-scrollback 10000
235 )
236 )
237
238 (after! flycheck
239 ; flycheck-error-list-buffer
240 (set-popup-rule! (rx bos "*Flycheck errors*" eos) :side 'right :size 0.33)
241 ; M-x lsp-ui-flycheck-list
242 (setq lsp-ui-flycheck-list-position 'right)
243 (add-hook 'flycheck-error-list-mode-hook
244 (lambda () (setq tabulated-list-sort-key (list "Level"))))
245 (setq
246 flycheck-relevant-error-other-file-minimum-level 'error
247 flycheck-relevant-error-other-file-show t
248 )
249 )
250 ;(add-hook 'flycheck-error-list-after-refresh-hook
251 ; (lambda ()
252 ; (with-selected-window (flycheck-get-error-list-window t)
253 ; (fit-window-to-buffer (flycheck-get-error-list-window t) 30))))
254
255 ;; Completing
256 (add-hook 'after-init-hook 'global-company-mode)
257 ;(setq company-idle-delay nil)
258
259 ;(use-package! ivy
260 ; :defer t
261 ; :bind
262 ; (:map ivy-minibuffer-map
263 ; ("RET" . 'ivy-alt-done)
264 ; ("TAB" . 'ivy-alt-done))
265 ; :init
266 ; (setq ivy-extra-directories nil
267 ; )
268 ; )
269
270 ;(add-hook! 'org-mode-hook #'mixed-pitch-mode)
271 ;(add-hook! 'org-mode-hook #'solaire-mode)
272 ;(setq mixed-pitch-variable-pitch-cursor nil)
273
274 ;(add-hook! org-mode :append
275 ; #'visual-line-mode
276 ; #'variable-pitch-mode)
277
278 (setq doom-modeline-enable-word-count nil)
279
280 (map! "C-x b" #'counsel-buffer-or-recentf
281 "C-x C-b" #'counsel-switch-buffer)
282 (defun recentf-track-visited-file (_prev _curr)
283 (and buffer-file-name
284 (recentf-add-file buffer-file-name)))
285 (after! recentf
286 (add-hook 'switch-buffer-functions #'recentf-track-visited-file))
287
288 ;; Org
289 ; DOC: https://rgoswami.me/posts/org-note-workflow/
290 ; ToStudy: https://github.com/abo-abo/orca
291 ; ToStudy: https://github.com/weirdNox/org-noter
292 ; ToStudy: https://github.com/bastibe/org-journal
293 ; ToStudy: https://orgmode.org/manual/Org-Crypt.html
294 ; DOC: http://www.wouterspekkink.org/academia/writing/tool/doom-emacs/2021/02/27/writing-academic-papers-with-org-mode.html
295 ; DOC: https://jonathanabennett.github.io/blog/2019/05/29/writing-academic-papers-with-org-mode/
296 ; ToStudy: https://github.com/org-roam/org-roam-ui
297 ; ToStudy: https://blog.tecosaur.com/tmio/2021-07-31-citations.html
298 ; ToStudy: https://github.com/jkitchin/org-ref-cite
299 (setq org-directory "~/documents/notes")
300 (setq org-noter-notes-search-path '("~/notes/path/"))
301
302 (after! org
303 (setq org-log-done t
304 org-log-into-drawer t
305 org-special-ctrl-a/e t
306 org-special-ctrl-k t
307 ;org-hide-emphasis-markers t
308 )
309 (add-to-list 'org-capture-templates
310 '("e" "English" table-line ; key, name, type
311 (file "english/vocabulary.org") ; target
312 "|%^{English}|%^{Français}|%^{Registre|Courant|Soutenu|Familier}|"
313 :kill-buffer t))
314 (add-to-list 'org-capture-templates
315 '("x" "Expense" plain
316 (file "compta.org")
317 "\n%(org-read-date) * send %^{Send to} %^{For why}\nExpense:Gifts %^{Amount}\n %^{Currency|EUR|USD|JPY}\n Assets:%^{Account||Personal|Home}"))
318 ;; Firefox and Chrome
319 ;(add-to-list 'org-capture-templates
320 ; `("P" "Protocol" entry ; key, name, type
321 ; (file+headline +org-capture-notes-file "Inbox") ; target
322 ; "* %^{Title}\nSource: %u, %c\n #+BEGIN_QUOTE\n%i\n#+END_QUOTE\n\n\n%?"
323 ; :prepend t ; properties
324 ; :kill-buffer t))
325 ;(add-to-list 'org-capture-templates
326 ; `("L" "Protocol Link" entry
327 ; (file+headline +org-capture-notes-file "Inbox")
328 ; "* %? [[%:link][%(transform-square-brackets-to-round-ones \"%:description\")]]\n"
329 ; :prepend t
330 ; :kill-buffer t))
331 ; )
332 )
333
334 (map! :after counsel :map org-mode-map
335 "C-c l l h" #'counsel-org-link)
336 (after! counsel
337 (setq counsel-outline-display-style 'title))
338
339 ;(after! org-id
340 ; ;; Do not create ID if a CUSTOM_ID exists
341 ; (setq org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id)
342 ; )
343 ;
344 ;(after! org-agenda
345 ; ;; (setq org-agenda-prefix-format
346 ; ;; '((agenda . " %i %-12:c%?-12t% s")
347 ; ;; ;; Indent todo items by level to show nesting
348 ; ;; (todo . " %i %-12:c%l")
349 ; ;; (tags . " %i %-12:c")
350 ; ;; (search . " %i %-12:c")))
351 ; (setq org-agenda-include-diary t)
352 ; )
353 ;
354 ;(use-package! org-roam
355 ; :defer t
356 ; :hook ((after-init . org-roam-mode))
357 ; :custom
358 ; (setq org-roam-directory "~/documents/notes/org-roam")
359 ;
360 ; ;; Let's set up some org-roam capture templates
361 ; (setq org-roam-capture-templates
362 ; '(("d" "default" plain (function org-roam--capture-get-point)
363 ; "%?"
364 ; :file-name "%<%Y-%m-%d-%H%M%S>-${slug}"
365 ; :head "#+title: ${title}\n"
366 ; :unnarrowed t)))
367 ;
368 ; ;; And now we set necessary variables for org-roam-dailies
369 ; (setq org-roam-dailies-capture-templates
370 ; '(("d" "default" entry
371 ; #'org-roam-capture--get-point
372 ; "* %?"
373 ; :file-name "daily/%<%Y-%m-%d>"
374 ; :head "#+title: %<%Y-%m-%d>\n\n")))
375 ; )
376 ;
377 ;(use-package! org-ref
378 ; :after org-roam
379 ; :config
380 ; (setq reftex-default-bibliography bibliography-files
381 ; org-ref-default-bibliography bibliography-files
382 ; org-ref-bibliography-notes "~/documents/notes/org-roam/bibnotes.org" ;; Is this even needed?
383 ; org-ref-notes-directory "~/documents/notes/org-roam"
384 ; org-ref-notes-function 'orb-edit-notes
385 ; ;org-ref-get-pdf-filename-function 'org-ref-get-pdf-filename-helm-bibtex)
386 ; )
387 ;
388 ;(use-package! bibtex-completion
389 ; :defer t
390 ; :config
391 ; (setq bibtex-completion-notes-path "~/documents/notes/org-roam/"
392 ; bibtex-completion-pdf-field "file"
393 ; bibtex-completion-bibliography bibliography-files
394 ; )
395 ;)
396 ;
397 ;(defvar orb-title-format "${author-or-editor-abbrev} (${date}). ${title}."
398 ; "Format of the title to use for `orb-templates'.")
399 ;
400 ;(use-package! org-roam-bibtex
401 ; :after org-roam
402 ; :hook (org-roam-mode . org-roam-bibtex-mode)
403 ; :bind (:map org-mode-map
404 ; (("C-c n a" . orb-note-actions)))
405 ; :config
406 ; (setq orb-preformat-keywords
407 ; '(("citekey" . "=key=") "title" "date" "author-or-editor-abbrev")
408 ; orb-templates
409 ; `(("r" "ref" plain
410 ; (function org-roam-capture--get-point)
411 ; ""
412 ; :file-name "${citekey}"
413 ; :head ,(s-join "\n"
414 ; (list
415 ; (concat "#+TITLE: " orb-title-format)
416 ; "#+ROAM_KEY: ${ref}"
417 ; ""
418 ; "- tags :: "
419 ; ""
420 ; "* Notes"
421 ; ""))
422 ; :unnarrowed t)
423 ; ("n" "ref + noter" plain
424 ; (function org-roam-capture--get-point)
425 ; ""
426 ; :file-name "${citekey}"
427 ; :head ,(s-join "\n"
428 ; (list
429 ; (concat "#+TITLE: " orb-title-format)
430 ; "#+ROAM_KEY: ${ref}"
431 ; ""
432 ; "- tags :: "
433 ; ""
434 ; "* Annotations :noter:"
435 ; ":PROPERTIES:"
436 ; ":NOTER_DOCUMENT: %(orb-process-file-field \"${citekey}\")"
437 ; ":NOTER_PAGE:"
438 ; ":END:"
439 ; ""))))))
440 ;
441 ;(map! :after pdf-tools
442 ; :map pdf-view-mode-map
443 ; :gn "q" (lambda ()
444 ; (interactive)
445 ; (if (bound-and-true-p org-noter-doc-mode)
446 ; (org-noter-kill-session)
447 ; (kill-current-buffer)))
448 ; )
449 ;
450 ;(use-package! org-noter
451 ; :after (:any org pdf-view)
452 ; :config
453 ; (setq org-noter-notes-search-path '("~/documents/notes/org-roam")
454 ; org-noter-always-create-frame nil
455 ; )
456 ; )
457
458 ;(setq lsp-lens-mode t)
459 (setq doom-modeline-height 1)
460 (setq doom-modeline-lsp t)
461 ;(setq doom-modeline-minor-modes t)
462 ;(setq lsp-modeline-diagnostics-enable t)
463
464 ;; Indenting
465 (setq-default tab-width 2)
466 (setq indent-tabs-mode nil)
467
468 ;; Searching
469 (global-superword-mode t)
470 ; https://emacs.stackexchange.com/questions/9583/how-to-treat-underscore-as-part-of-the-word
471 (modify-syntax-entry ?_ "w")
472 (defun swiper-all/search-word-at-point ()
473 (interactive)
474 (swiper-all (format "\\_<%s\\_>" (thing-at-point 'word))))
475 ; Highlight without jumping to the next match
476 ; See: https://emacs.stackexchange.com/questions/52411/evil-star-visualstar-without-moving-the-cursor
477 (defun search-word-at-point ()
478 (interactive)
479 (evil-search (progn (evil-ex-search-word-forward)
480 (evil-ex-search-previous)
481 )))
482 (defun search-unbounded-word-at-point ()
483 (interactive)
484 (evil-search (progn (evil-ex-search-unbounded-word-forward)
485 (evil-ex-search-unbounded-word-previous)
486 )))
487 (after! (ivy swiper)
488 (setq case-fold-search nil ; case-sensitive search by default
489 ivy-case-fold-search-default nil ; case-sensitive search by default
490 ;; Press C-p and Enter to select current input as candidate
491 ;; https://oremacs.com/2017/11/30/ivy-0.10.0/
492 ivy-use-selectable-prompt t
493 )
494 (add-to-list 'ivy-re-builders-alist `(swiper . ivy--regex))
495 (add-to-list 'ivy-re-builders-alist `(swiper-all . ivy--regex))
496 (add-to-list 'ivy-re-builders-alist `(read-file-name-internal . ivy--regex-fuzzy))
497 )
498 (after! evil
499 ;(general-define-key "C-s" '(counsel-grep-or-swiper :which-key "search"))
500 ;(general-define-key :keymaps '(swiper-map) "C-u" '(lambda () (interactive) (kill-line 0)))
501 ;(general-nvmap "/" '(counsel-grep-or-swiper :which-key "search in buffer"))
502 (evil-define-key 'normal global-map
503 (kbd "/") 'swiper
504 (kbd "C-f") 'swiper-all
505 (kbd "C-/") 'swiper-all/search-word-at-point
506 (kbd "*") 'search-word-at-point
507 (kbd "g*") 'search-unbounded-word-at-point
508 )
509 )
510
511 ;; Editing
512 (after! evil
513 (setq evil-want-fine-undo t
514 )
515 (customize-set-variable 'evil-want-Y-yank-to-eol nil)
516 (evil-define-key 'normal global-map (kbd "K") 'evil-join)
517 (evil-define-key 'insert global-map (kbd "C-u") '(lambda () (interactive) (kill-line 0)))
518 (evil-define-key 'normal global-map (kbd "SPC g d") 'git-gutter:popup-hunk)
519 )
520 (setq +vc-gutter-default-style nil
521 )
522 (customize-set-variable 'git-gutter:update-interval 2)
523 ;(customize-set-variable 'git-gutter:window-width 2)
524 (after! git-gutter-fringe
525 (require 'fringe-helper)
526 ; Narrower vertical bar, matching the one in the "+" of git-gutter-fr:added
527 (fringe-helper-define 'git-gutter-fr:modified nil
528 "...XX..."
529 "...XX..."
530 ".XXXXXX."
531 ".XXXXXX."
532 "...XX..."
533 "...XX..."
534 ".XXXXXX."
535 ".XXXXXX.")
536 ; Narrower horizontql bar, matching the one in the "+" of git-gutter-fr:added
537 (fringe-helper-define 'git-gutter-fr:deleted nil
538 "........"
539 "........"
540 "........"
541 ".XXXXXX."
542 ".XXXXXX."
543 "........"
544 "........"
545 "........")
546 )
547
548
549 ;; Folding
550 (defun set-selective-display/at-point (&optional level)
551 "Fold text indented same of more than the cursor.
552 If level is set, set the indent level to LEVEL.
553 If 'selective-display' is already set to LEVEL,
554 calling it again will unset 'selective-display' by setting it to 0."
555 (interactive "P")
556 (if (eq selective-display (1+ (current-column)))
557 (set-selective-display 0)
558 (set-selective-display (or level (1+ (current-column))))))
559 (after! evil
560 (evil-define-key 'normal global-map
561 (kbd "C-d") 'set-selective-display/at-point)
562 )
563
564 ;; Navigating
565 ;; DOC: https://github.com/noctuid/evil-guide
566 (after! evil
567 (setq evil-cross-lines t
568 evil-move-cursor-back nil
569 evil-search-wrap nil
570 evil-want-C-i-jump nil
571 )
572
573 ;; Switching buffers
574 (evil-define-key 'motion 'global
575 (kbd "<C-i>") 'evil-prev-buffer ; Does not work without the angles ('<' and '>')
576 (kbd "C-k") 'evil-next-buffer
577 (kbd "C-x k") 'kill-current-buffer
578 (kbd "C-m") 'counsel-switch-buffer
579 )
580 ;(define-key evil-normal-state-map [tab] 'evil-prev-buffer)
581
582 ;; Jumping
583 (evil-define-key 'motion 'global
584 (kbd "C-u") 'better-jumper-jump-backward
585 (kbd "C-o") 'better-jumper-jump-forward
586 )
587 ;; Jumping
588 ;(evil-define-key '(motion normal visual) 'global
589 ;(kbd "C--") 'doom/decrease-font-size
590 ;(kbd "C-=") 'doom/increase-font-size
591 ; )
592
593 ;; Moving with ijkl (instead of hjkl)
594 (evil-define-key '(motion normal visual) 'global
595 (kbd "i") 'evil-previous-visual-line
596 (kbd "j") 'evil-backward-char
597 (kbd "k") 'evil-next-visual-line
598 (kbd "h") 'evil-insert
599 )
600
601 ;; Switching windows with SPC-w + ijkl (instead of hjkl)
602 (define-key evil-window-map "i" 'evil-window-up)
603 (define-key evil-window-map "I" 'evil-window-move-very-top)
604 (define-key evil-window-map "j" 'evil-window-left)
605 (define-key evil-window-map "J" 'evil-window-move-far-left)
606 (define-key evil-window-map "k" 'evil-window-down)
607 (define-key evil-window-map "K" 'evil-window-move-very-bottom)
608 ;(define-key evil-emacs-state-map "\C-w" 'evil-window-map)
609 ;;(evil-define-key 'window global-map "l" 'evil-window-right)
610 ;;(evil-define-key 'window global-map "L" 'evil-window-move-far-right)
611
612 ;; ijkl in Dired
613 ;;(evil-define-key 'normal dired-mode-map "i" 'evil-previous-line)
614
615 ;; Errors
616 (evil-define-key 'motion 'global
617 (kbd "C-j") 'previous-error
618 (kbd "C-l") 'next-error
619 )
620 ;(bind-key "C-j" #'previous-error)
621 ;(bind-key "C-l" #'next-error)
622 )
623 (after! auto-yasnippet
624 (evil-define-key '(motion normal) 'global
625 (kbd "C-<tab>") 'evil-switch-to-windows-last-buffer
626 )
627 )
628 (after! (evil magit evil-collection-magit)
629 (evil-define-key '(motion normal) magit-mode-map
630 (kbd "C-i") 'evil-prev-buffer
631 (kbd "i") 'evil-previous-visual-line
632 (kbd "k") 'evil-next-visual-line
633 (kbd "C-k") 'evil-next-buffer
634 (kbd "j") 'magit-section-backward
635 (kbd "l") 'magit-section-forward
636 )
637 )
638 (after! (evil magit git-rebase)
639 (evil-define-key '(motion normal) git-rebase-mode-map
640 (kbd "C-i") 'evil-prev-buffer
641 (kbd "i") 'evil-previous-visual-line
642 (kbd "k") 'evil-next-visual-line
643 (kbd "C-k") 'evil-next-buffer
644 (kbd "j") 'evil-backward-char
645 )
646 )
647 ;;(eval-after-load 'evil ; to run after evil-integration.el
648 ;; '(progn
649 ;; (define-key Buffer-menu-mode-map "\C-i" 'evil-prev-buffer)
650 ;; (define-key Buffer-menu-mode-map "\C-k" 'evil-next-buffer)
651 ;; (define-key messages-buffer-mode-map "\C-i" 'evil-prev-buffer)
652 ;; (define-key messages-buffer-mode-map "\C-k" 'evil-next-buffer)
653 ;; (define-key completion-list-mode-map "\C-i" 'evil-prev-buffer)
654 ;; (define-key completion-list-mode-map "\C-k" 'evil-next-buffer)
655 ;; ;(define-key custom-theme-mode-map "\C-i" 'evil-prev-buffer)
656 ;; ;(define-key custom-theme-mode-map "\C-k" 'evil-next-buffer)
657 ;; )
658 ;; )
659
660 ;;(with-eval-after-load 'evil-maps
661 ;; (define-key evil-motion-state-map (kbd "TAB") nil))
662
663 ;; Feed reader
664 ; See also: Managing ArXiv RSS Feeds in Emacs https://cundy.me/post/elfeed/
665
666 (setq
667 elfeed-enable-web-interface t
668 url-queue-timeout 30
669 )
670 ;(global-set-key (kbd "C-x w") 'elfeed)
671
672 (defun elfeed-mark-all-as-read ()
673 (interactive)
674 (mark-whole-buffer)
675 (elfeed-search-untag-all-unread))
676
677 ; Functions to support syncing .elfeed between machines
678 ; makes sure elfeed reads index from disk before launching
679 (defun elfeed-load-db-and-open ()
680 "Wrapper to load the elfeed db from disk before opening"
681 (interactive)
682 (elfeed-db-load)
683 (elfeed)
684 (elfeed-search-update--force))
685
686 ; Write to disk when quiting
687 (defun elfeed-save-db-and-bury ()
688 "Wrapper to save the elfeed db to disk before burying buffer"
689 (interactive)
690 (elfeed-db-save)
691 (quit-window))
692
693 (defun elfeed-toggle-star ()
694 "Toggle star"
695 (interactive)
696 (elfeed-search-tag-all '*)
697 )
698 (after! (evil elfeed evil-collection-elfeed)
699 (evil-define-key 'motion elfeed-search-mode-map "m" #'elfeed-toggle-star)
700 )
701
702 (defun elfeed-org-update-incremental ()
703 "Automatically update the feeds from feeds.org when updated"
704 (setq my-elfeed-org-last (or (and (boundp 'elfeed-feeds) elfeed-feeds) nil))
705 (elfeed)
706 (setq my-elfeed-org-current elfeed-feeds)
707 (let ((elfeed-feeds (-difference my-elfeed-org-current my-elfeed-org-last)))
708 ;; You don't need the line below if you don't want to see a message about what feeds are being updated
709 (message "%s" elfeed-feeds)
710 (mapc #'elfeed-update-feed (elfeed--shuffle (elfeed-feed-list))))
711 (setq elfeed-feeds my-elfeed-org-current))
712