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