-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
1811 lines (1640 loc) · 60 KB
/
init.el
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; init.el -*- lexical-binding: t; -*-
;; DO NOT EDIT THIS FILE DIRECTLY
;; This is a file generated from a literate programing source file located at
;; https://github.com/christophe-gouel/dotemacs/blob/master/README.org
;; You should make any changes there and regenerate it from Emacs org-mode
;; using org-babel-tangle (C-c C-v t)
;;; Code:
(use-package package
:config
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-initialize))
(use-package use-package)
(use-package use-package-ensure-system-package
:ensure t)
(use-package system-packages
:ensure t
:defer t)
(add-to-list 'display-buffer-alist
'("\\`\\*\\(Warnings\\|Compile-Log\\)\\*\\'"
(display-buffer-no-window)
(allow-no-window . t)))
(when (equal window-system 'ns)
(use-package exec-path-from-shell
:ensure t
:config
(dolist (var '("DROPBOX" "BIBINPUTS" "BSTINPUTS" "GH_TOKEN"))
(add-to-list 'exec-path-from-shell-variables var))
(exec-path-from-shell-initialize)))
(use-package dashboard
:ensure t
:custom
(dashboard-projects-switch-function 'project-switch-project)
(dashboard-set-navigator t) ; raccourcis de rubrique
(dashboard-center-content t)
(dashboard-items '((recents . 6)
(projects . 6)
(bookmarks . 6)))
(dashboard-set-heading-icons t)
(dashboard-set-file-icons t)
:config
(dashboard-setup-startup-hook))
(unless (eq window-system 'ns)
(menu-bar-mode 0))
(scroll-bar-mode 0)
(tool-bar-mode 0)
(tooltip-mode 0)
(setopt blink-cursor-blinks 0 ; curseur clignote indéfiniment
display-time-24hr-format t ; Affichage de l'heure format 24h
column-number-mode t ; affichage du numéro de la colonne
prettify-symbols-unprettify-at-point t
frame-resize-pixelwise t
window-resize-pixelwise t)
(when (display-graphic-p)
;; Cursor (in terminal mode, to be set in terminal options)
(setopt cursor-type 'bar) ; curseur étroit
(set-face-background 'cursor "#CC0000") ; curseur rouge foncé
;; Fonts and unicode characters
;; Main font
(set-face-attribute 'default nil :family "JetBrainsMono NF" :height 120)
(set-face-attribute 'fixed-pitch nil :family "JetBrainsMono NF" :height 1.0)
(set-face-attribute 'variable-pitch nil :family "Noto Serif" :height 1.0)
;; Additional font for some unicode characters missing in prettify symbols
(set-fontset-font t 'unicode (font-spec :name "XITS Math") nil 'prepend))
(defun my-screen-27 ()
"Adjust font for 27 inch screen."
(interactive)
(set-face-attribute 'default nil :family "JetBrainsMono NF" :height 140)
(setopt org-format-latex-options
(plist-put org-format-latex-options :scale 1.8)
preview-scale-function 1.4))
(defun my-screen-default ()
"Adjust font for default screen."
(interactive)
(set-face-attribute 'default nil :family "JetBrainsMono NF" :height 120)
(setopt org-format-latex-options
(plist-put org-format-latex-options :scale 1.7)
preview-scale-function 1.5))
(use-package mixed-pitch
:ensure t
:hook
((org-mode LaTeX-mode) . mixed-pitch-mode)
:config
(add-to-list 'mixed-pitch-fixed-pitch-faces 'markdown-table-face))
(use-package hl-line
:config
(global-hl-line-mode +1)
:custom
(global-hl-line-sticky-flag t))
(use-package rainbow-mode
:ensure t
:hook (prog-mode . rainbow-mode))
(use-package nerd-icons
:ensure t
:custom
(nerd-icons-font-family "Symbols Nerd Font Mono")) ; JetBrains font did not work well
(use-package nerd-icons-dired
:ensure t
:hook
(dired-mode . nerd-icons-dired-mode))
(use-package nerd-icons-ibuffer
:ensure t
:hook (ibuffer-mode . nerd-icons-ibuffer-mode))
(use-package nerd-icons-completion
:ensure t
:after marginalia
:config
(nerd-icons-completion-mode)
:hook
(marginalia-mode . nerd-icons-completion-marginalia-setup))
(use-package ligature
:ensure t
:config
;; Enable all JetBrains Mono ligatures in programming modes
(defconst jb-ligatures
'("-|" "-~" "---" "-<<" "-<" "--" "->" "->>" "-->" "///" "/=" "/==" "/>"
"//" "/*" "*>" "***" ",*/" "<-" "<<-" "<=>" "<=" "<|" "<||" "<|||" "<|>"
"<:" "<>" "<-<" "<<<" "<==" "<<=" "<=<" "<==>" "<-|" "<<" "<~>" "<=|"
"<~~" "<~" "<$>" "<$" "<+>" "<+" "</>" "</" "<*" "<*>" "<->" "<!--" ":>"
":<" ":::" "::" ":?" ":?>" ":=" "::=" "=>>" "==>" "=/=" "=!=" "=>" "==="
"=:=" "==" "!==" "!!" "!=" ">]" ">:" ">>-" ">>=" ">=>" ">>>" ">-" ">="
"&&&" "&&" "|||>" "||>" "|>" "|]" "|}" "|=>" "|->" "|=" "||-" "|-" "||="
"||" ".." ".?" ".=" ".-" "..<" "..." "+++" "+>" "++" "[||]" "[<" "[|" "{|"
"??" "?." "?=" "?:" "##" "###" "####" "#[" "#{" "#=" "#!" "#:" "#_(" "#_"
"#?" "#(" ";;" "_|_" "__" "~~" "~~>" "~>" "~-" "~@" "$>" "^=" "]#"))
(ligature-set-ligatures 'prog-mode jb-ligatures)
(ligature-set-ligatures 'text-mode jb-ligatures)
(ligature-set-ligatures 'comint-mode jb-ligatures)
(ligature-set-ligatures 'special-mode jb-ligatures)
;; Enables ligature checks globally in all buffers. You can also do it
;; per mode with `ligature-mode'.
(global-ligature-mode t))
(use-package doom-modeline
:ensure t
:hook (after-init . doom-modeline-mode))
(use-package rainbow-delimiters
:ensure t
:hook ((prog-mode yaml-mode) . rainbow-delimiters-mode)
:custom-face
(rainbow-delimiters-depth-1-face ((t (:foreground "red"))))
(rainbow-delimiters-depth-2-face ((t (:foreground "orange"))))
(rainbow-delimiters-depth-3-face ((t (:foreground "cyan"))))
(rainbow-delimiters-depth-4-face ((t (:foreground "green"))))
(rainbow-delimiters-depth-5-face ((t (:foreground "blue"))))
(rainbow-delimiters-depth-6-face ((t (:foreground "violet"))))
(rainbow-delimiters-depth-7-face ((t (:foreground "purple"))))
(rainbow-delimiters-depth-8-face ((t (:foreground "black"))))
(rainbow-delimiters-unmatched-face ((t (:background "yellow")))))
(setopt custom-safe-themes t) ; consider all themes as safe
(use-package modus-themes
:ensure t
:config
(setopt modus-themes-italic-constructs t
modus-themes-bold-constructs t
modus-themes-to-toggle
'(modus-operandi-deuteranopia modus-vivendi-deuteranopia)
;; Remove the mode-line border
modus-themes-common-palette-overrides
'((border-mode-line-active unspecified)
(border-mode-line-inactive unspecified)))
(load-theme 'modus-vivendi-deuteranopia)
(define-key global-map (kbd "S-<f5>") #'modus-themes-toggle))
(use-package autorevert
:custom
(auto-revert-verbose nil)) ; Prevent autorevert from generating messages
(use-package casual-calc
:ensure casual
:after calc
:bind (:map
calc-mode-map
("C-o" . casual-calc-tmenu)
:map
calc-alg-map
("C-o" . casual-calc-tmenu)))
(use-package compile
:bind (:map compilation-mode-map ("r" . recompile))
:hook
;; Get proper coloring of compile buffers (does not seem to work under Windows, probably because cmd does not support ANSI colors)
(compilation-filter . ansi-color-compilation-filter)
:custom
;; compilation buffer automatically scrolls and stops at first error
(compilation-scroll-output 'first-error))
(use-package dictionary
:defer t
:custom
(dictionary-server "dict.org"))
(use-package dired
:commands (dired dired-jump)
:config
; macOS ls is not the standard ls so we substitute it by GNU ls
(when (and (eq system-type 'darwin) (executable-find "gls"))
(setopt insert-directory-program "gls"))
(setq dired-compress-files-alist
'(("\\.tar\\.gz\\'" . "tar -cf - %i | gzip -c9 > %o")
("\\.tar\\.bz2\\'" . "tar -cf - %i | bzip2 -c9 > %o")
("\\.tar\\.xz\\'" . "tar -cf - %i | xz -c9 > %o")
("\\.tar\\.zst\\'" . "tar -cf - %i | zstd -19 -o %o")
("\\.tar\\.lz\\'" . "tar -cf - %i | lzip -c9 > %o")
("\\.tar\\.lzo\\'" . "tar -cf - %i | lzop -c9 > %o")
("\\.zip\\'" . "zip %o -r -9 --filesync %i --exclude \\*/.DS_Store __MACOSX")
("\\.pax\\'" . "pax -wf %o %i")))
:custom
(dired-listing-switches "-agho --group-directories-first")
(dired-compress-directory-default-suffix ".zip")
(dired-compress-file-default-suffix ".zip")
:hook
(dired-mode . (lambda ()
(dired-hide-details-mode)))
(dired-mode . auto-revert-mode))
(use-package diredfl
:ensure t
:hook
(dired-mode . diredfl-mode))
(use-package dired-subtree
:ensure t
:after dired
:bind
(:map dired-mode-map
("<tab>" . dired-subtree-toggle)
("TAB" . dired-subtree-toggle)))
(use-package ediff-wind
:defer t
:custom
(ediff-split-window-function 'split-window-horizontally)
(ediff-window-setup-function 'ediff-setup-windows-plain))
(set-language-environment "UTF-8")
(prefer-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setopt default-buffer-file-coding-system 'utf-8-unix
x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
(if (equal system-type 'windows-nt) ;; MS Windows clipboard is UTF-16LE
(set-clipboard-coding-system 'utf-16le-dos))
(use-package expand-region
:ensure t
:bind ("C-!" . er/expand-region))
(use-package grep
:defer t
:custom
(grep-use-headings t)
:config
(if (equal system-type 'windows-nt)
(setopt find-program "\"C:\\Program Files\\Git\\usr\\bin\\find.exe\"")))
(use-package wgrep
:ensure t
:bind (:map grep-mode-map ("e" . wgrep-change-to-wgrep-mode)))
(use-package ripgrep
:ensure t
:bind
("C-c f" . my-ripgrep-in-same-extension)
:config
(defun my-ripgrep-in-same-extension (expression)
"Search for EXPRESSION in files with the same extension as the
current buffer within the project or the current directory if not in a project."
(interactive
(list
(read-from-minibuffer "Ripgrep search for: " (thing-at-point 'symbol))))
(let* ((extension (file-name-extension (buffer-file-name)))
(glob (if extension (concat "*." extension) "*"))
;; Check if we are inside a project. If not, use `nil`.
(project (if (ignore-errors (project-current)) (project-current) nil))
;; Use project root if in a project, otherwise use `default-directory`.
(root (if project (project-root project) default-directory)))
(ripgrep-regexp expression
root
(list (format "-g %s" glob)))))
:ensure-system-package rg)
(use-package ibuffer-project
:ensure t
:hook
(ibuffer .
(lambda ()
(setopt ibuffer-filter-groups (ibuffer-project-generate-filter-groups))
(unless (eq ibuffer-sorting-mode 'project-file-relative)
(ibuffer-do-sort-by-project-file-relative)))))
(use-package imenu
:defer t
:custom
(imenu-auto-rescan t))
(use-package imenu-list
:ensure t
:bind
(("C-c =" . imenu-list-smart-toggle)
:map imenu-list-major-mode-map
("M-<return>" . my-imenu-list-goto-entry))
:custom
(imenu-list-focus-after-activation t)
(imenu-list-position 'right)
:config
(defun my-imenu-list-goto-entry ()
"Goto entry and exit imenu"
(interactive)
(imenu-list-goto-entry)
(imenu-list-smart-toggle)))
(use-package isearch
:defer t
:custom
;; Display a counter of the matches
(isearch-lazy-count t)
(lazy-count-prefix-format "(%s/%s) ")
;; Make regular Isearch interpret the empty space as a regular expression that
;; matches any character between the words you give it.
(search-whitespace-regexp ".*?"))
(use-package minibuffer
:custom
(read-file-name-completion-ignore-case t))
(use-package outline
:hook ((prog-mode text-mode) . outline-minor-mode)
:custom
(outline-minor-mode-use-buttons 'in-margins) ; add in-margin buttons to fold/unfold
:config
(unbind-key "RET" outline-overlay-button-map))
(use-package bicycle
:ensure t
:after outline
:bind (:map outline-minor-mode-map
([C-tab] . bicycle-cycle)
([S-tab] . my-bibycle-cycle-global)
([backtab] . my-bibycle-cycle-global))
:config
;; bicycle-cycle-global should not be used in org-mode, hence this function
(defun my-bibycle-cycle-global ()
(interactive)
(if (derived-mode-p 'org-mode)
(org-cycle-global)
(bicycle-cycle-global))))
(use-package outline-minor-faces
:ensure t
:after outline
:hook
(outline-minor-mode . outline-minor-faces-mode))
(setopt show-paren-mode t ; coupler les parenthèses
auth-sources '("~/.authinfo") ; Define file that stores secrets
backup-directory-alist '(("." . "~/.emacs.d/backup"))
default-major-mode 'text-mode ; mode par défaut
delete-by-moving-to-trash t ; Sent deleted files to trash
comment-column 0 ; Prevent indentation of lines starting with one comment
jit-lock-chunk-size 50000 ; Number of characters used for fontification
;; set large file threshold at 100 megabytes
large-file-warning-threshold 100000000
ring-bell-function 'ignore ; disable the bell (useful for macOS)
mouse-yank-at-point t ; coller avec la souris
case-fold-search t ; recherche sans égard à la casse
enable-recursive-minibuffers t
help-window-select t) ; Jump to help window when it opens
(delete-selection-mode t) ; entrée efface texte sélectionné
(fset 'yes-or-no-p 'y-or-n-p) ; Replace yes or no with y or n
(auto-compression-mode t)
(when (equal system-type 'windows-nt)
(setopt tramp-default-method "plink"))
(setopt user-full-name "Christophe Gouel"
user-mail-address "christophe.gouel@inrae.fr")
(use-package doc-view
:if (display-graphic-p)
:defer t
:custom
(doc-view-ghostscript-program (executable-find "rungs")))
(use-package pdf-tools
:ensure t
:if (display-graphic-p)
:mode ("\\.pdf\\'" . pdf-view-mode)
:bind (:map pdf-view-mode-map
("C-s" . isearch-forward))
:custom
(pdf-view-display-size 'fit-page)
(pdf-view-selection-style 'glyph)
:config
(pdf-tools-install))
(use-package proced
:defer t
:custom
(proced-enable-color-flag t))
(use-package prog-mode
:defer t
:hook
(prog-mode . (lambda() (setq-local show-trailing-whitespace t)))
(prog-mode . (lambda () (display-fill-column-indicator-mode)))
(prog-mode .
(lambda() (add-to-list 'write-file-functions 'delete-trailing-whitespace)))
;; Make URLs in comments clickable
(prog-mode . goto-address-prog-mode))
(use-package text-mode
:defer t
:hook
(text-mode . (lambda() (setq-local show-trailing-whitespace t)))
(text-mode . prettify-symbols-mode)
:custom
(sentence-end-double-space nil))
(use-package recentf
:ensure t
:custom
(recentf-max-saved-items 100))
(set-register ?b '(file . "~/Inrae EcoPub Dropbox/Christophe Gouel/Bibliography/Bibtex/References.bib"))
(set-register ?d '(file . "~/Downloads"))
(set-register ?r '(file . "~/Inrae EcoPub Dropbox/Christophe Gouel/dropbox_projects/Review"))
(setopt initial-scratch-message nil)
(setopt
pixel-scroll-precision-mode t
scroll-step 1
;; Marker distance from center (don't jump to center).
scroll-conservatively 100000
;; Start scrolling when marker at top/bottom.
scroll-margin 2
;; Try to keep screen position when PgDn/PgUp.
scroll-preserve-screen-position 1)
(use-package server
:defer 1
:config
(when (and (display-graphic-p) (not (server-running-p)))
(server-start)))
(use-package windmove
:config
(windmove-default-keybindings))
(use-package xwidget
:defer t
:config
(defun my-open-chatgpt ()
"Open ChatGPT in xwidget."
(interactive)
(xwidget-webkit-browse-url "https://chatgpt.com")))
;; Remove a bug appearing on Linux GTK and preventing the use of S-space (https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-07/msg00071.html)
(when (equal window-system 'pgtk)
(setopt pgtk-use-im-context-on-new-connection nil))
(keymap-global-set "C-x C-b" 'ibuffer)
(keymap-global-set "C-<apps>" 'menu-bar-mode) ; for Windows
(keymap-global-set "C-<menu>" 'menu-bar-mode) ; For Linux
(keymap-global-set "<f5>" 'revert-buffer)
;; Replace upcase-word, downcase-word, and capitalize-word by DWIM versions
(keymap-global-set "M-u" 'upcase-dwim)
(keymap-global-set "M-l" 'downcase-dwim)
(keymap-global-set "M-c" 'capitalize-dwim)
;; Unbind "C-z" that minimizes emacs
(global-unset-key (kbd "C-z"))
(when (equal system-type 'darwin)
(setopt
mac-command-modifier 'meta
mac-function-modifier 'control
mac-option-modifier 'meta
mac-right-option-modifier 'none)
(keymap-global-set "<home>" 'move-beginning-of-line)
(keymap-global-set "<end>" 'move-end-of-line)
(keymap-global-set "§" (lambda () (interactive) (insert "-")))
(keymap-global-set "M-é" (lambda () (interactive) (insert "~")))
(keymap-global-set "M-\"" (lambda () (interactive) (insert "#")))
(keymap-global-set "M-'" (lambda () (interactive) (insert "{")))
(keymap-global-set "M-(" (lambda () (interactive) (insert "[")))
(keymap-global-set "M-§" (lambda () (interactive) (insert "|")))
(keymap-global-set "M-è" (lambda () (interactive) (insert "`")))
(keymap-global-set "M-!" (lambda () (interactive) (insert "\\")))
(keymap-global-set "M-à" (lambda () (interactive) (insert "@")))
(keymap-global-set "M-)" (lambda () (interactive) (insert "]")))
;; (keymap-global-set "M--" (lambda () (interactive) (insert "}")))
;; (keymap-global-set "M-e" (lambda () (interactive) (insert "€")))
)
(use-package keycast
:ensure t
:defer t)
(unless (equal system-type 'darwin)
(use-package greek-unicode-insert
:ensure t
:vc (:url "https://github.com/Malabarba/greek-unicode-insert")
:bind (:map prog-mode-map ("²" . greek-unicode-insert-map))))
; :init (setq greek-unicode-insert-key "`"))
(use-package elec-pair
:config
(electric-pair-mode))
(use-package which-key
:ensure t
:diminish which-key-mode
:init
(setopt which-key-sort-uppercase-first nil
max-mini-window-height 15)
;; On va utiliser une fenêtre dédiée plutôt que le minibuffer
(which-key-setup-side-window-bottom)
;; On l'active partout, tout le temps
(which-key-mode t))
(use-package prescient
:ensure t
:config
(prescient-persist-mode))
(use-package company
:ensure t
:hook
(after-init . global-company-mode)
;; (prog-mode . (lambda ()
;; (setq-local company-backends
;; '(company-capf
;; company-files
;; company-math-symbols-unicode
;; (company-dabbrev-code company-keywords)
;; company-dabbrev
;; :with
;; company-yasnippet))))
(text-mode . (lambda ()
(setq-local company-backends
'(company-capf
company-files
company-latex-commands
company-math-symbols-latex
;; company-ispell
(company-dabbrev-code company-keywords)
company-dabbrev
;; :with
company-yasnippet))))
(TeX-mode . (lambda ()
(setq-local company-backends
'(company-capf
company-files
company-reftex-labels
company-reftex-citations
company-math-symbols-latex
company-latex-commands
company-ispell
(company-dabbrev-code company-keywords)
company-dabbrev
;; :with
company-yasnippet))))
:custom
(company-show-numbers t)
(company-idle-delay 0.2)
(company-backends '(company-capf
company-files
(company-dabbrev-code company-keywords)
company-dabbrev
;; :with
company-yasnippet))
;; company configuration from
;; <https://github.com/radian-software/radian/blob/develop/emacs/radian.el>
:bind (;; Replace `completion-at-point' and `complete-symbol' with
;; `company-manual-begin'. You might think this could be put
;; in the `:bind*' declaration below, but it seems that
;; `bind-key*' does not work with remappings.
;; ([remap completion-at-point] . company-manual-begin)
;; ([remap complete-symbol] . company-manual-begin)
("C-c y" . company-yasnippet)
;; The following are keybindings that take effect whenever
;; the completions menu is visible, even if the user has not
;; explicitly interacted with Company.
:map company-active-map
;; Make TAB always complete the current selection. Note that
;; <tab> is for windowed Emacs and TAB is for terminal Emacs.
("<tab>" . company-complete-selection)
("TAB" . company-complete-selection)
;; Prevent SPC from ever triggering a completion.
("SPC" . nil)
;; The following are keybindings that only take effect if the
;; user has explicitly interacted with Company.
:map company-active-map
:filter (company-explicit-action-p)
;; Make RET trigger a completion if and only if the user has
;; explicitly interacted with Company. Note that <return> is
;; for windowed Emacs and RET is for terminal Emacs.
("<return>" . company-complete-selection)
("RET" . company-complete-selection)))
(use-package company-math
:ensure t
:custom
(company-math-allow-latex-symbols-in-faces t)) ; use LaTeX symbols everywhere (avoid unicode symbols to dominate outside LaTeX mode)
(use-package company-reftex
:ensure t)
(use-package company-jedi
:ensure t)
(use-package company-box
:ensure t
:hook (company-mode . company-box-mode)
:custom
(company-box-doc-enable nil))
(use-package company-prescient
:ensure t
:config
(company-prescient-mode))
(use-package vertico
:ensure t
:init
(vertico-mode)
(vertico-multiform-mode)
:custom
(vertico-multiform-categories
'(;; Commands that are displayed in separate buffers
(consult-flymake-error buffer)
(consult-grep buffer)
(consult-location buffer)
(imenu buffer)
(org-heading buffer)
;; Standard vertico in minibuffer
(kill-ring)
;; The rest in postframe in the center of the screen
(t posframe)))
:bind
(:map vertico-map
("<next>" . vertico-scroll-up)
("<prior>" . vertico-scroll-down)))
(use-package vertico-posframe
:ensure t)
(use-package vertico-directory
:after vertico
:ensure nil
:bind
(:map vertico-map ("DEL" . vertico-directory-delete-char)))
(use-package orderless
:ensure t
:custom
(completion-styles '(orderless basic)))
(use-package marginalia
:ensure t
:init
(marginalia-mode))
(use-package consult
:ensure t
:bind
(("C-x b" . consult-buffer)
("M-y" . consult-yank-pop)
;; M-s bindings in `search-map'
("M-s g" . consult-grep)
("M-s G" . consult-git-grep)
("M-s r" . consult-ripgrep)
("M-s l" . consult-line)
("M-s L" . consult-line-multi)
;; Other custom bindings
("M-g f" . consult-flymake)
("M-g i" . consult-imenu)
("M-g I" . consult-imenu-multi)
("M-g o" . consult-outline)
("M-#" . consult-register)
:map isearch-mode-map
("M-s l" . consult-line)
("M-s L" . consult-line-multi))
:config
;; Disable preview for commands that can be slow
(consult-customize
consult--source-bookmark consult--source-file-register
consult--source-recent-file consult--source-project-recent-file
:preview-key "M-."))
(use-package vertico-prescient
:ensure t
:after vertico
:init
(vertico-prescient-mode))
(use-package magit
:ensure t
:init
;; this binds `magit-project-status' to `project-prefix-map' when project.el is loaded.
(require 'magit-extras)
:bind ("C-x g" . magit-status)
:custom
(magit-diff-refine-hunk (quote all))
:config
; Do not diff when committing
(remove-hook 'server-switch-hook 'magit-commit-diff)
(remove-hook 'with-editor-filter-visit-hook 'magit-commit-diff))
(use-package magit-delta
:ensure t
:hook (magit-mode . magit-delta-mode)
:ensure-system-package (delta . git-delta))
(use-package diff-hl
:defer t
:after magit
:hook
(prog-mode . diff-hl-mode)
(latex-mode . diff-hl-mode)
(dired-mode . diff-hl-dired-mode)
(magit-post-refresh . diff-hl-magit-post-refresh))
(use-package git-modes
:ensure t
:mode ("/.dockerignore\\'" . gitignore-mode)) ; works also with other ignore files
(use-package chatgpt-shell
:ensure t
:config
(defun my-chatgpt-save-block ()
(interactive)
(chatgpt-shell-mark-block)
(kill-ring-save (region-beginning) (region-end)))
:bind
(("C-x j p" . chatgpt-shell-proofread-region)
("C-x j c" . chatgpt-shell-prompt-compose)
("C-x j RET" . chatgpt-shell)
("C-x j s" . chatgpt-shell-swap-model)
:map chatgpt-shell-mode-map
("C-c C-b" . my-chatgpt-save-block)
:map chatgpt-shell-prompt-compose-view-mode-map
("C-c C-b" . my-chatgpt-save-block))
:custom
(chatgpt-shell-openai-key
(auth-source-pick-first-password :host "api.openai.com"))
:ensure-system-package curl)
(use-package gptel
:ensure t
:bind
(("C-c RET" . gptel-send)
("C-c C-<return>" . gptel-send))
;; :custom
;; (gptel-use-curl nil)
:config
(add-to-list 'gptel-directives
'(academic . "You are an editor specialized in academic paper in economics. You are here to help me generate the best text for my academic articles. I will provide you texts and I would like you to review them for any spelling, grammar, or punctuation errors. Do not stop at simple proofreading, if it is useful, propose to refine the content's structure, style, and clarity. Once you have finished editing the text, provide me with any necessary corrections or suggestions for improving the text. Please respect any LaTeX, org, or markdown command. Avoid passive form."))
(add-to-list 'gptel-directives
'(mathematics . "Solve this mathematical formula. Just output the solution in LaTeX without giving any explanation.")))
(use-package eshell-git-prompt
:ensure t
:defer 2
:config
(eshell-git-prompt-use-theme 'powerline))
(use-package comint
:defer t
:custom
(comint-scroll-to-bottom-on-input 'this)
(comint-scroll-to-bottom-on-output t)
(comint-move-point-for-output t))
(use-package shell
:defer t
:hook
(shell-mode . (lambda ()
(face-remap-set-base 'comint-highlight-prompt :inherit nil))))
(use-package citar
:ensure t
:after (org nerd-icons)
:hook
(markdown-mode . citar-capf-setup)
(org-mode . citar-capf-setup)
:config
;; Configuration to use nerd-icons in citar
(defvar citar-indicator-files-icons
(citar-indicator-create
:symbol (nerd-icons-faicon
"nf-fa-file_o"
:face 'nerd-icons-green
:v-adjust -0.1)
:function #'citar-has-files
:padding " " ; need this because the default padding is too low for these icons
:tag "has:files"))
(defvar citar-indicator-links-icons
(citar-indicator-create
:symbol (nerd-icons-faicon
"nf-fa-link"
:face 'nerd-icons-orange
:v-adjust 0.01)
:function #'citar-has-links
:padding " "
:tag "has:links"))
(defvar citar-indicator-notes-icons
(citar-indicator-create
:symbol (nerd-icons-codicon
"nf-cod-note"
:face 'nerd-icons-blue
:v-adjust -0.3)
:function #'citar-has-notes
:padding " "
:tag "has:notes"))
(defvar citar-indicator-cited-icons
(citar-indicator-create
:symbol (nerd-icons-faicon
"nf-fa-circle_o"
:face 'nerd-icon-green)
:function #'citar-is-cited
:padding " "
:tag "is:cited"))
(setopt citar-indicators
(list citar-indicator-files-icons
citar-indicator-links-icons
citar-indicator-notes-icons
citar-indicator-cited-icons))
;; Functions to side-step a bug in citar which affects the state of RefTeX. To remove as soon as the fix has been pushed to MELPA.
(defun my-citar-open (&optional key)
"Run `citar-open` with a KEY in a temporary buffer to avoid interfering with RefTeX in LaTeX mode.
This ensures that `citar-open` does not modify the current LaTeX buffer's settings."
(interactive
(list (citar-select-refs))) ; Prompt user to select a citation.
(with-temp-buffer
;; Temporarily switch to a clean buffer
(delay-mode-hooks (org-mode)) ; Set a neutral mode (like org-mode) to avoid LaTeX hooks
(citar-open key))) ; Run citar-open in the temporary buffer
(defun my-citar-open-notes (&optional key)
"Run `citar-open-notes` with a KEY in a temporary buffer to avoid interfering with RefTeX in LaTeX mode."
(interactive
(list (citar-select-refs))) ; Prompt user to select a citation.
(with-temp-buffer
;; Temporarily switch to a clean buffer
(delay-mode-hooks (org-mode)) ; Set a neutral mode (like org-mode) to avoid LaTeX hooks
(citar-open-notes key))) ; Run citar-open in the temporary buffer
(defun my-citar-open-files (&optional key)
"Run `citar-open-files` with a KEY in a temporary buffer to avoid interfering with RefTeX in LaTeX mode."
(interactive
(list (citar-select-refs))) ; Prompt user to select a citation.
(with-temp-buffer
;; Temporarily switch to a clean buffer
(delay-mode-hooks (org-mode)) ; Set a neutral mode (like org-mode) to avoid LaTeX hooks
(citar-open-files key))) ; Run citar-open in the temporary buffer
:custom
(org-cite-insert-processor 'citar)
(org-cite-follow-processor 'citar)
(org-cite-activate-processor 'citar)
(citar-bibliography org-cite-global-bibliography)
(citar-library-paths
(list (substitute-in-file-name "${DROPBOX}/Bibliography/Papers")))
(citar-notes-paths
(list (substitute-in-file-name "${DROPBOX}/Bibliography/notes")))
(citar-templates
'((main . "${author editor:30%sn} ${date year issued:4} ${title:48}")
(suffix . " ${=key= id:7} ${=type=:12} ${journal journaltitle}")
(preview . "${author editor:%etal} (${year issued date}) ${title}, ${journal journaltitle publisher container-title collection-title}.\n")
(note . "Notes on ${author editor:%etal}, ${title}")))
:bind
(("C-x c d" . citar-dwim)
("C-x c f" . my-citar-open-files)
("C-x c o" . my-citar-open)
("C-x c n" . my-citar-open-notes)
:map bibtex-mode-map
("C-x c i" . citar-insert-bibtex)
:map text-mode-map
("C-x c c" . citar-insert-citation)))
(defun my-screenshot-to-file (arg)
"Take a screenshot or copy from the clipboard (depending on OS),
save it to a file in the 'images' folder, and copy the relative file path to the kill ring.
If called with a universal argument (C-u), prompt for the file name (including the folder)."
(interactive "P")
(let* ((default-dir (concat (file-name-directory (buffer-file-name)) "images/"))
;; Prompt for filename if universal argument is used
(filename (if arg
(expand-file-name (read-file-name "Save screenshot as: " default-dir))
(expand-file-name (concat default-dir (format-time-string "%Y-%m-%d_%H%M%S") ".png"))))
(dir (file-name-directory filename)) ;; Extract directory from provided or default filename
(relative-filename (file-relative-name filename)))
;; Ensure the directory exists
(unless (file-exists-p dir)
(make-directory dir t))
;; macOS screenshot
(cond
((eq system-type 'darwin)
(call-process "screencapture" nil nil nil "-i" filename))
;; Linux screenshot
((eq system-type 'gnu/linux)
(call-process "myflameshot" nil nil nil filename))
;; Windows clipboard
((eq system-type 'windows-nt)
(let ((powershell-command
(concat "powershell -command \"Add-Type -AssemblyName System.Windows.Forms;"
"if ($([System.Windows.Forms.Clipboard]::ContainsImage())) {"
"$image = [System.Windows.Forms.Clipboard]::GetImage();"
"[System.Drawing.Bitmap]$image.Save('" (shell-quote-argument filename) "',"
"[System.Drawing.Imaging.ImageFormat]::Png);"
"Write-Output 'clipboard content saved as file'} else {"
"Write-Output 'clipboard does not contain image data'}\"")))
(shell-command powershell-command))))
;; Handle file existence and copy relative path to kill ring
(if (file-exists-p filename)
(progn
(kill-new relative-filename)
(message "Screenshot saved to %s and relative path copied to kill ring" relative-filename))
(message "Screenshot failed."))))
(use-package csv-mode
:ensure t
:hook
(csv-mode . csv-guess-set-separator))
(use-package tex
:defer t
:ensure auctex
:hook
(TeX-mode . latex-math-mode)
(TeX-mode . TeX-fold-buffer)
(TeX-mode . flymake-mode)
(TeX-mode . my-center-text)
:hook
(TeX-mode . TeX-fold-mode)
:custom
(TeX-auto-save t)
(TeX-save-query nil) ; don't ask to save the file before compiling
(TeX-parse-self t)
(LaTeX-item-indent 0)
(LaTeX-default-options "12pt")
(TeX-PDF-mode t)
(TeX-electric-sub-and-superscript 1)
(LaTeX-flymake-chktex-options
'("-n3")) ; You should enclose the previous parenthesis with ‘{}’.
;; View PDF
(TeX-view-program-selection '((output-pdf "PDF Tools")))
(TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view)))
(TeX-source-correlate-mode t)
(TeX-source-correlate-start-server t)
;; (TeX-source-correlate-method (quote synctex))
;; Fold-mode
(TeX-fold-auto-reveal t)
;; Personalize the list of commands to be folded
(TeX-fold-macro-spec-list
'(("[f]"
("footnote" "marginpar"))
("[c]"
("citeyear" "citeauthor" "citep" "citet" "cite" "textcite" "parencite"))
("[l]"
("label"))
("[r]"
("ref" "pageref" "eqref" "footref" "fref" "Fref"))
("[i]"
("index" "glossary"))
("[1]:||*"
("item"))
("..."