]> Git — Sourcephile - julm/julm-nix.git/blob - home-manager/profiles/emacs/config.el
oignon: davfs2: enable demo
[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 )
234
235 (after! flycheck
236 ; flycheck-error-list-buffer
237 (set-popup-rule! (rx bos "*Flycheck errors*" eos) :side 'right :size 0.33)
238 ; M-x lsp-ui-flycheck-list
239 (setq lsp-ui-flycheck-list-position 'right)
240 (add-hook 'flycheck-error-list-mode-hook
241 (lambda () (setq tabulated-list-sort-key (list "Level"))))
242 (setq
243 flycheck-relevant-error-other-file-minimum-level 'error
244 flycheck-relevant-error-other-file-show t
245 )
246 )
247 ;(add-hook 'flycheck-error-list-after-refresh-hook
248 ; (lambda ()
249 ; (with-selected-window (flycheck-get-error-list-window t)
250 ; (fit-window-to-buffer (flycheck-get-error-list-window t) 30))))
251
252 ;; Completing
253 (add-hook 'after-init-hook 'global-company-mode)
254 ;(setq company-idle-delay nil)
255
256 ;(use-package! ivy
257 ; :defer t
258 ; :bind
259 ; (:map ivy-minibuffer-map
260 ; ("RET" . 'ivy-alt-done)
261 ; ("TAB" . 'ivy-alt-done))
262 ; :init
263 ; (setq ivy-extra-directories nil
264 ; )
265 ; )
266
267 ;(add-hook! 'org-mode-hook #'mixed-pitch-mode)
268 ;(add-hook! 'org-mode-hook #'solaire-mode)
269 ;(setq mixed-pitch-variable-pitch-cursor nil)
270
271 ;(add-hook! org-mode :append
272 ; #'visual-line-mode
273 ; #'variable-pitch-mode)
274
275 (setq doom-modeline-enable-word-count nil)
276
277 (map! "C-x b" #'counsel-buffer-or-recentf
278 "C-x C-b" #'counsel-switch-buffer)
279 (defun recentf-track-visited-file (_prev _curr)
280 (and buffer-file-name
281 (recentf-add-file buffer-file-name)))
282 (after! recentf
283 (add-hook 'switch-buffer-functions #'recentf-track-visited-file))
284
285 ;; Org
286 ; DOC: https://rgoswami.me/posts/org-note-workflow/
287 ; ToStudy: https://github.com/abo-abo/orca
288 ; ToStudy: https://github.com/weirdNox/org-noter
289 ; ToStudy: https://github.com/bastibe/org-journal
290 ; ToStudy: https://orgmode.org/manual/Org-Crypt.html
291 ; DOC: http://www.wouterspekkink.org/academia/writing/tool/doom-emacs/2021/02/27/writing-academic-papers-with-org-mode.html
292 ; DOC: https://jonathanabennett.github.io/blog/2019/05/29/writing-academic-papers-with-org-mode/
293 ; ToStudy: https://github.com/org-roam/org-roam-ui
294 ; ToStudy: https://blog.tecosaur.com/tmio/2021-07-31-citations.html
295 ; ToStudy: https://github.com/jkitchin/org-ref-cite
296 (setq org-directory "~/documents/notes")
297 (setq org-noter-notes-search-path '("~/notes/path/"))
298
299 (after! org
300 (setq org-log-done t
301 org-log-into-drawer t
302 org-special-ctrl-a/e t
303 org-special-ctrl-k t
304 ;org-hide-emphasis-markers t
305 )
306 (add-to-list 'org-capture-templates
307 '("e" "English" table-line ; key, name, type
308 (file "english/vocabulary.org") ; target
309 "|%^{English}|%^{Français}|%^{Registre|Courant|Soutenu|Familier}|"
310 :kill-buffer t))
311 (add-to-list 'org-capture-templates
312 '("x" "Expense" plain
313 (file "compta.org")
314 "\n%(org-read-date) * send %^{Send to} %^{For why}\nExpense:Gifts %^{Amount}\n %^{Currency|EUR|USD|JPY}\n Assets:%^{Account||Personal|Home}"))
315 ;; Firefox and Chrome
316 ;(add-to-list 'org-capture-templates
317 ; `("P" "Protocol" entry ; key, name, type
318 ; (file+headline +org-capture-notes-file "Inbox") ; target
319 ; "* %^{Title}\nSource: %u, %c\n #+BEGIN_QUOTE\n%i\n#+END_QUOTE\n\n\n%?"
320 ; :prepend t ; properties
321 ; :kill-buffer t))
322 ;(add-to-list 'org-capture-templates
323 ; `("L" "Protocol Link" entry
324 ; (file+headline +org-capture-notes-file "Inbox")
325 ; "* %? [[%:link][%(transform-square-brackets-to-round-ones \"%:description\")]]\n"
326 ; :prepend t
327 ; :kill-buffer t))
328 ; )
329 )
330
331 (map! :after counsel :map org-mode-map
332 "C-c l l h" #'counsel-org-link)
333 (after! counsel
334 (setq counsel-outline-display-style 'title))
335
336 ;(after! org-id
337 ; ;; Do not create ID if a CUSTOM_ID exists
338 ; (setq org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id)
339 ; )
340 ;
341 ;(after! org-agenda
342 ; ;; (setq org-agenda-prefix-format
343 ; ;; '((agenda . " %i %-12:c%?-12t% s")
344 ; ;; ;; Indent todo items by level to show nesting
345 ; ;; (todo . " %i %-12:c%l")
346 ; ;; (tags . " %i %-12:c")
347 ; ;; (search . " %i %-12:c")))
348 ; (setq org-agenda-include-diary t)
349 ; )
350 ;
351 ;(use-package! org-roam
352 ; :defer t
353 ; :hook ((after-init . org-roam-mode))
354 ; :custom
355 ; (setq org-roam-directory "~/documents/notes/org-roam")
356 ;
357 ; ;; Let's set up some org-roam capture templates
358 ; (setq org-roam-capture-templates
359 ; '(("d" "default" plain (function org-roam--capture-get-point)
360 ; "%?"
361 ; :file-name "%<%Y-%m-%d-%H%M%S>-${slug}"
362 ; :head "#+title: ${title}\n"
363 ; :unnarrowed t)))
364 ;
365 ; ;; And now we set necessary variables for org-roam-dailies
366 ; (setq org-roam-dailies-capture-templates
367 ; '(("d" "default" entry
368 ; #'org-roam-capture--get-point
369 ; "* %?"
370 ; :file-name "daily/%<%Y-%m-%d>"
371 ; :head "#+title: %<%Y-%m-%d>\n\n")))
372 ; )
373 ;
374 ;(use-package! org-ref
375 ; :after org-roam
376 ; :config
377 ; (setq reftex-default-bibliography bibliography-files
378 ; org-ref-default-bibliography bibliography-files
379 ; org-ref-bibliography-notes "~/documents/notes/org-roam/bibnotes.org" ;; Is this even needed?
380 ; org-ref-notes-directory "~/documents/notes/org-roam"
381 ; org-ref-notes-function 'orb-edit-notes
382 ; ;org-ref-get-pdf-filename-function 'org-ref-get-pdf-filename-helm-bibtex)
383 ; )
384 ;
385 ;(use-package! bibtex-completion
386 ; :defer t
387 ; :config
388 ; (setq bibtex-completion-notes-path "~/documents/notes/org-roam/"
389 ; bibtex-completion-pdf-field "file"
390 ; bibtex-completion-bibliography bibliography-files
391 ; )
392 ;)
393 ;
394 ;(defvar orb-title-format "${author-or-editor-abbrev} (${date}). ${title}."
395 ; "Format of the title to use for `orb-templates'.")
396 ;
397 ;(use-package! org-roam-bibtex
398 ; :after org-roam
399 ; :hook (org-roam-mode . org-roam-bibtex-mode)
400 ; :bind (:map org-mode-map
401 ; (("C-c n a" . orb-note-actions)))
402 ; :config
403 ; (setq orb-preformat-keywords
404 ; '(("citekey" . "=key=") "title" "date" "author-or-editor-abbrev")
405 ; orb-templates
406 ; `(("r" "ref" plain
407 ; (function org-roam-capture--get-point)
408 ; ""
409 ; :file-name "${citekey}"
410 ; :head ,(s-join "\n"
411 ; (list
412 ; (concat "#+TITLE: " orb-title-format)
413 ; "#+ROAM_KEY: ${ref}"
414 ; ""
415 ; "- tags :: "
416 ; ""
417 ; "* Notes"
418 ; ""))
419 ; :unnarrowed t)
420 ; ("n" "ref + noter" plain
421 ; (function org-roam-capture--get-point)
422 ; ""
423 ; :file-name "${citekey}"
424 ; :head ,(s-join "\n"
425 ; (list
426 ; (concat "#+TITLE: " orb-title-format)
427 ; "#+ROAM_KEY: ${ref}"
428 ; ""
429 ; "- tags :: "
430 ; ""
431 ; "* Annotations :noter:"
432 ; ":PROPERTIES:"
433 ; ":NOTER_DOCUMENT: %(orb-process-file-field \"${citekey}\")"
434 ; ":NOTER_PAGE:"
435 ; ":END:"
436 ; ""))))))
437 ;
438 ;(map! :after pdf-tools
439 ; :map pdf-view-mode-map
440 ; :gn "q" (lambda ()
441 ; (interactive)
442 ; (if (bound-and-true-p org-noter-doc-mode)
443 ; (org-noter-kill-session)
444 ; (kill-current-buffer)))
445 ; )
446 ;
447 ;(use-package! org-noter
448 ; :after (:any org pdf-view)
449 ; :config
450 ; (setq org-noter-notes-search-path '("~/documents/notes/org-roam")
451 ; org-noter-always-create-frame nil
452 ; )
453 ; )
454
455 ;(setq lsp-lens-mode t)
456 (setq doom-modeline-height 1)
457 (setq doom-modeline-lsp t)
458 ;(setq doom-modeline-minor-modes t)
459 ;(setq lsp-modeline-diagnostics-enable t)
460
461 ;; Indenting
462 (setq-default tab-width 2)
463 (setq indent-tabs-mode nil)
464
465 ;; Searching
466 (global-superword-mode t)
467 ; https://emacs.stackexchange.com/questions/9583/how-to-treat-underscore-as-part-of-the-word
468 (modify-syntax-entry ?_ "w")
469 (defun swiper-all/search-word-at-point ()
470 (interactive)
471 (swiper-all (format "\\_<%s\\_>" (thing-at-point 'word))))
472 ; Highlight without jumping to the next match
473 ; See: https://emacs.stackexchange.com/questions/52411/evil-star-visualstar-without-moving-the-cursor
474 (defun search-word-at-point ()
475 (interactive)
476 (evil-search (progn (evil-ex-search-word-forward)
477 (evil-ex-search-previous)
478 )))
479 (defun search-unbounded-word-at-point ()
480 (interactive)
481 (evil-search (progn (evil-ex-search-unbounded-word-forward)
482 (evil-ex-search-unbounded-word-previous)
483 )))
484
485 (after! (ivy swiper)
486 (setq case-fold-search nil ; case-sensitive search by default
487 ivy-case-fold-search-default nil ; case-sensitive search by default
488 ;; Press C-p and Enter to select current input as candidate
489 ;; https://oremacs.com/2017/11/30/ivy-0.10.0/
490 ivy-use-selectable-prompt t
491 )
492 (add-to-list 'ivy-re-builders-alist `(swiper . ivy--regex))
493 (add-to-list 'ivy-re-builders-alist `(swiper-all . ivy--regex))
494 (add-to-list 'ivy-re-builders-alist `(read-file-name-internal . ivy--regex-fuzzy))
495 )
496
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 ;; Edition
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 ;; Navigation
564 ;; DOC: https://github.com/noctuid/evil-guide
565 (after! evil
566 (setq evil-cross-lines t
567 evil-move-cursor-back nil
568 evil-search-wrap nil
569 evil-want-C-i-jump nil
570 )
571
572 ;; Switching buffers
573 (evil-define-key 'motion 'global
574 (kbd "<C-i>") 'evil-prev-buffer ; Does not work without the angles ('<' and '>')
575 (kbd "C-k") 'evil-next-buffer
576 (kbd "C-x k") 'kill-current-buffer
577 (kbd "C-m") 'counsel-switch-buffer
578 )
579 ;(define-key evil-normal-state-map [tab] 'evil-prev-buffer)
580
581 ;; Jumping
582 (evil-define-key 'motion 'global
583 (kbd "C-u") 'better-jumper-jump-backward
584 (kbd "C-o") 'better-jumper-jump-forward
585 )
586 ;; Jumping
587 (evil-define-key '(motion normal visual) 'global
588 (kbd "C--") 'doom/decrease-font-size
589 (kbd "C-=") 'doom/increase-font-size
590 )
591
592 ;; Moving with ijkl (instead of hjkl)
593 (evil-define-key '(motion normal visual) 'global
594 (kbd "i") 'evil-previous-visual-line
595 (kbd "j") 'evil-backward-char
596 (kbd "k") 'evil-next-visual-line
597 (kbd "h") 'evil-insert
598 )
599
600 ;; Switching windows with SPC-w + ijkl (instead of hjkl)
601 (define-key evil-window-map "i" 'evil-window-up)
602 (define-key evil-window-map "I" 'evil-window-move-very-top)
603 (define-key evil-window-map "j" 'evil-window-left)
604 (define-key evil-window-map "J" 'evil-window-move-far-left)
605 (define-key evil-window-map "k" 'evil-window-down)
606 (define-key evil-window-map "K" 'evil-window-move-very-bottom)
607 ;(define-key evil-emacs-state-map "\C-w" 'evil-window-map)
608 ;;(evil-define-key 'window global-map "l" 'evil-window-right)
609 ;;(evil-define-key 'window global-map "L" 'evil-window-move-far-right)
610
611 ;; ijkl in Dired
612 ;;(evil-define-key 'normal dired-mode-map "i" 'evil-previous-line)
613
614 ;; Errors
615 (evil-define-key 'motion 'global
616 (kbd "C-j") 'previous-error
617 (kbd "C-l") 'next-error
618 )
619 ;(bind-key "C-j" #'previous-error)
620 ;(bind-key "C-l" #'next-error)
621 )
622 (after! auto-yasnippet
623 (evil-define-key '(motion normal) 'global
624 (kbd "C-<tab>") 'evil-switch-to-windows-last-buffer
625 )
626 )
627 (after! (evil magit evil-collection-magit)
628 (evil-define-key '(motion normal) magit-mode-map
629 (kbd "C-i") 'evil-prev-buffer
630 (kbd "i") 'evil-previous-visual-line
631 (kbd "k") 'evil-next-visual-line
632 (kbd "C-k") 'evil-next-buffer
633 (kbd "j") 'magit-section-backward
634 (kbd "l") 'magit-section-forward
635 )
636 )
637 (after! (evil magit git-rebase)
638 (evil-define-key '(motion normal) git-rebase-mode-map
639 (kbd "C-i") 'evil-prev-buffer
640 (kbd "i") 'evil-previous-visual-line
641 (kbd "k") 'evil-next-visual-line
642 (kbd "C-k") 'evil-next-buffer
643 (kbd "j") 'evil-backward-char
644 )
645 )
646 ;;(eval-after-load 'evil ; to run after evil-integration.el
647 ;; '(progn
648 ;; (define-key Buffer-menu-mode-map "\C-i" 'evil-prev-buffer)
649 ;; (define-key Buffer-menu-mode-map "\C-k" 'evil-next-buffer)
650 ;; (define-key messages-buffer-mode-map "\C-i" 'evil-prev-buffer)
651 ;; (define-key messages-buffer-mode-map "\C-k" 'evil-next-buffer)
652 ;; (define-key completion-list-mode-map "\C-i" 'evil-prev-buffer)
653 ;; (define-key completion-list-mode-map "\C-k" 'evil-next-buffer)
654 ;; ;(define-key custom-theme-mode-map "\C-i" 'evil-prev-buffer)
655 ;; ;(define-key custom-theme-mode-map "\C-k" 'evil-next-buffer)
656 ;; )
657 ;; )
658
659 ;;(with-eval-after-load 'evil-maps
660 ;; (define-key evil-motion-state-map (kbd "TAB") nil))
661
662 ;; Feed reader
663 ; See also: Managing ArXiv RSS Feeds in Emacs https://cundy.me/post/elfeed/
664
665 (setq
666 elfeed-enable-web-interface t
667 url-queue-timeout 30
668 )
669 ;(global-set-key (kbd "C-x w") 'elfeed)
670
671 (defun elfeed-mark-all-as-read ()
672 (interactive)
673 (mark-whole-buffer)
674 (elfeed-search-untag-all-unread))
675
676 ; Functions to support syncing .elfeed between machines
677 ; makes sure elfeed reads index from disk before launching
678 (defun elfeed-load-db-and-open ()
679 "Wrapper to load the elfeed db from disk before opening"
680 (interactive)
681 (elfeed-db-load)
682 (elfeed)
683 (elfeed-search-update--force))
684
685 ; Write to disk when quiting
686 (defun elfeed-save-db-and-bury ()
687 "Wrapper to save the elfeed db to disk before burying buffer"
688 (interactive)
689 (elfeed-db-save)
690 (quit-window))
691
692 (defun elfeed-toggle-star ()
693 "Toggle star"
694 (interactive)
695 (elfeed-search-tag-all '*)
696 )
697 (after! (evil elfeed evil-collection-elfeed)
698 (evil-define-key 'motion elfeed-search-mode-map "m" #'elfeed-toggle-star)
699 )
700
701 (defun elfeed-org-update-incremental ()
702 "Automatically update the feeds from feeds.org when updated"
703 (setq my-elfeed-org-last (or (and (boundp 'elfeed-feeds) elfeed-feeds) nil))
704 (elfeed)
705 (setq my-elfeed-org-current elfeed-feeds)
706 (let ((elfeed-feeds (-difference my-elfeed-org-current my-elfeed-org-last)))
707 ;; You don't need the line below if you don't want to see a message about what feeds are being updated
708 (message "%s" elfeed-feeds)
709 (mapc #'elfeed-update-feed (elfeed--shuffle (elfeed-feed-list))))
710 (setq elfeed-feeds my-elfeed-org-current))
711