-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
893 lines (757 loc) · 24.8 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
;;; init.el --- Emacs configuration of Kristiyan Kanchev
;;; Commentary:
;; Emacs configuration of Kristiyan Kanchev
;;; Code:
;;
;; ------------------------
;; Emacs Customization file
(setq custom-file (expand-file-name "customize.el" user-emacs-directory))
(when (file-exists-p custom-file)
(load custom-file))
;; ------------
;; OS-dependent
(cond
;; --- Windows
((memq system-type '(windows-nt msdos))
;; Append MSYS2 to PATH on Windows
(setenv "PATH" (concat "C:\\msys64\\mingw64\\bin;" (getenv "PATH")))
(add-to-list 'exec-path "C:\\msys64\\mingw64\\bin")
(setenv "PATH" (concat "C:\\msys64\\usr\\bin;" (getenv "PATH")))
(add-to-list 'exec-path "C:\\msys64\\usr\\bin")
;; Fix 'find' listing on Windows
(with-eval-after-load 'find-dired
(if (boundp 'find-ls-option)
(setq find-ls-option '("-exec ls -ldh {} +" . "-ldh")))))
;; --- MacOS
((eval-when-compile (eq system-type 'darwin))
;; Swap Command and Control keys on OSX because if we use Mac with
;; their own keyboard and we remapped these keys in System
;; Preferences.
(setq mac-command-modifier 'meta
mac-option-modifier 'super
mac-right-option-modifier 'control)
;; Append Homebrew bin dir to exec-path on OSX
(setenv "PATH" (concat "/usr/local/bin:"
(expand-file-name "~/go/bin:")
(getenv "PATH")))
(add-to-list 'exec-path "/usr/local/bin")
(add-to-list 'exec-path (expand-file-name "~/go/bin"))
;; Enable emoji for macOS
(set-fontset-font t 'symbol "Apple Color Emoji" nil 'prepend)
;; Force en_US.UTF-8 locale because macOS creates en_BG.UTF-8 when
;; selecting English as main language and Bulgaria as
;; Region. However, this locale is not defined (checked with "locale
;; -a")
(setenv "LANG" "en_US.UTF-8")))
;; ------------------------
;; Global built-in configs.
;; Disable toobar.
(tool-bar-mode -1)
;; Navigation numbers here and there.
(setq column-number-mode t) ; show column number in modeline
(if (eval-when-compile (>= emacs-major-version 26)) ; display line numbers
(global-display-line-numbers-mode)
(global-linum-mode t))
;; Fix scroll.
(setq scroll-conservatively 10000) ; allow to scrol line-by-line
;; Parentheses stuff
(electric-pair-mode) ; auto-close parentheses
(show-paren-mode) ; show matching parentheses
;; Delete trailing space before save.
(add-hook 'before-save-hook
'delete-trailing-whitespace) ; delete whitespaces
(put 'dired-find-alternate-file 'disabled nil) ; reuse dired buffers
;; Shows current function name -- in the header for modes are
;; specified in `sch/which-function-in-header-modes'
(defvar sch/which-function-in-header-modes '(python-mode))
(defvar-local sch/which-function-in-mode-line t)
(defun sch/which-function-in-header ()
"Puts `which-function' output in header line for the designated modes."
(setq sch/which-function-in-mode-line
(not (memq major-mode sch/which-function-in-header-modes)))
(unless sch/which-function-in-mode-line
(setq header-line-format '(" " which-func-format " "))))
(defun sch/which-function-disable-mode-line ()
"Don't show `which-function' in modes that want to show it in header."
(let ((old-construct (assq 'which-function-mode mode-line-misc-info))
(misc-info (assq-delete-all 'which-function-mode mode-line-misc-info)))
(add-to-list 'misc-info
(list 'sch/which-function-in-mode-line old-construct))
(setq mode-line-misc-info misc-info)))
(add-hook 'after-change-major-mode-hook 'sch/which-function-in-header)
(which-function-mode t)
(sch/which-function-disable-mode-line)
;; find-grep-dired to not recurse in .svn folder
(with-eval-after-load 'find-dired
(if (boundp 'find-grep-options)
(setq find-grep-options "-Iq --exclude=\"*\\.svn*\"")))
;; Prevent accidental exiting
(setq confirm-kill-emacs 'y-or-n-p)
;;; TODO -- configure sending mail properly by using SMTP submission.
;; Email config
(setq send-mail-function 'smtpmail-send-it
user-mail-address "[email protected]"
smtpmail-smtp-server "smtp.gmail.com"
smtpmail-stream-type 'ssl
smtpmail-smtp-service 465)
;; Abbreviate long path-like Git branch names
(defun shorten-git-mode-line (return-string)
"Abbreviates path-like Git branches and preserves the prefix.
RETURN-STRING - the string returned by `vc-git-mode-line-string'."
(let ((prefix (substring return-string 0 4)))
(concat prefix (replace-regexp-in-string "\\([^/]\\{2\\}\\)[^/]*/"
"\\1/"
return-string
nil nil nil 4))))
(advice-add 'vc-git-mode-line-string
:filter-return
'shorten-git-mode-line)
;; -----------
;; Auth-source
;; Enable `password-store' -- that is, integrate with `pass' UNIX
;; utility. We enabled it at the end of auth-sources, so that
;; `.authinfo' files take precendence (especially the un-encrypted
;; one) for easier ad-hoc experiments.
;; (require 'auth-source-pass)
(with-eval-after-load 'auth-source
;; Require the builtin 'pass'-integration library so registration
;; hooks can run.
(require 'auth-source-pass)
;; Customize `auth-sources'. Put `.authinfo' files (unencrypted and
;; encrypted) before `password-store' for easier ad-hoc
;; customizations when needed. Otherwise, all my passwords are saved
;; in 'pass'
(if (boundp 'auth-sources)
(setq auth-sources '("~/.authinfo" "~/.authinfo.gpg" password-store))))
;; -----------
;; Tree-sitter
(require 'treesit nil 'noerror)
(defun sch/treesit-available-p (&optional lang)
"Check if current Emacs is built with tree-sitter support.
LANG might be supplied (a symbol), which will additionally check if
that language is available for tree-sitter."
(when (featurep 'treesit)
(if lang
(treesit-ready-p lang)
(treesit-available-p))))
(defun sch/setup-treesit-grammers ()
"Configure Tree-Sitter grammer sources alist and install grammers.
Will execute only if Tree-Sitter is actually available."
(if (sch/treesit-available-p)
(progn
(setq treesit-language-source-alist
'((elixir "https://github.com/elixir-lang/tree-sitter-elixir")
(heex "https://github.com/phoenixframework/tree-sitter-heex")))
;; Install the grammers (if not already installed)
(mapc #'treesit-install-language-grammar
(seq-remove (lambda (lang) (treesit-language-available-p lang))
(mapcar #'car treesit-language-source-alist))))
(message "Tree-Sitter not available. Skipping its initialization.")))
(sch/setup-treesit-grammers)
;; ----
;; Site-specific config
(defvar sch/site-config-dir (file-name-as-directory
(expand-file-name "site-config"
user-emacs-directory))
"Directory where site-specific configurations reside.")
(defun sch/maybe-load-site-conf (filename)
"Load site-specific config contained in FILENAME.
FILENAME is searched in the `site-config-dir' dir."
(let ((abs-filename (concat sch/site-config-dir
filename)))
(when (file-exists-p abs-filename)
(load abs-filename))))
;;; Load generic site-specific configurations
;; Place to include ad-hoc changes or experimentation to the
;; initialization logic specific for a given site. File is not version
;; controlled and is missing by default.
;;; NOTE: If some requred library is expected to have site-specific
;; configuration every time, it's better to split it under its own
;; file under `site-config'.
;;; NOTE: Be careful when mutating varialbes (functions like
;; `add-to-list' and firends) because they might not be loaded
;; yet. Use `eval-after-load' when working with such variables.
(sch/maybe-load-site-conf "site-generic.el")
;; ----
;; Straight
;; Disable straight.el customization hacks.
(defvar straight-enable-package-integration)
(setq straight-enable-package-integration nil)
;; Bootstrap straight.el
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
;; ----
;; ELPA
(require 'package)
;; Call `eval-and-compile' to make the byte-compiler aware of the
;; load-path modifications and autoloadeds in the installed packages.
;; -- EXPLANATION: `package.el' creates autoloads file when installing
;; every package. `package-initialize' enumerates the installed
;; packages and then 'activates' them (meaning, modifying load-path
;; and then loading their autoloads). Byte-compiler should *eval* the
;; initialization code in addition to compiling it (because compile
;; only records the function call w/o knowing what would happen
;; inside), so it knows the effects of activation. Usually, package
;; initialization happens before user init is executed. However,
;; byte-compiler (for linting) is always started with `emacs -q'
;; switch, which doesn't initialize the packages as normal (see the
;; docs of `package.el'). That's why we introduced early-init.el and
;; manually cal `package-initialize', so the code for byte-compiler
;; and interpreter are the same.
;; -- WARNING: I came up with this solution *myself*. Check from time to
;; time what would happen if eval-and-compile is removed --
;; `package.el' or `use-package' might have prepared a built-in
;; solution.
(eval-and-compile
(package-initialize))
;; Set repos
(setq package-archives
;; Package archives
'(("GNU ELPA" . "http://elpa.gnu.org/packages/")
("MELPA" . "https://melpa.org/packages/")))
;; Install `use-package' if using older version of Emacs.
(unless (package-installed-p 'use-package)
(package-refresh-contents) ; refresh packages cache
(package-install 'use-package))
(require 'use-package)
;; ------------------------------
;; Packages init with use-package
;; +++
;; Always-on
;; Themes
;; (use-package color-theme-sanityinc-tomorrow
;; :ensure t
;; :init
;; (load-theme 'sanityinc-tomorrow-eighties t))
(use-package solarized-theme
:ensure t
:init
;; Don't change the font for some headings and titles
;; (setq solarized-use-variable-pitch nil)
;; Remove scaling of fonts
;; (setq solarized-scale-org-headlines nil
;; solarized-height-minus-1 1.0
;; solarized-height-plus-1 1.0
;; solarized-height-plus-2 1.0
;; solarized-height-plus-3 1.0
;; solarized-height-plus-4 1.0)
(load-theme 'solarized-light t))
;; Ivy -- Completion mechanism.
(use-package ivy
:ensure t
:init
(ivy-mode)
:bind (:map ivy-minibuffer-map
([tab] . ivy-alt-done))
:config
(setq ivy-use-virtual-buffers t
ivy-count-format "(%d/%d) "
ivy-on-del-error-function 'ignore)
:diminish ivy-mode)
;; Ivy Hydra
(use-package ivy-hydra
:ensure t)
;; Counsel -- Power replacement for Emacs' commands and some external tools.
(use-package counsel
:ensure t
:init
(counsel-mode)
:bind
(("C-x c r" . ivy-resume)
("C-x c g" . counsel-git)
("C-x c j" . counsel-git-grep)
("C-x c L" . counsel-git-log)
("C-x c l" . counsel-locate)
("C-x c a" . counsel-ag)
("C-x c i" . counsel-imenu))
:config
(setq counsel-ag-base-command "ag --nogroup --nocolor %s"
counsel-find-file-ignore-regexp (concat "\\(?:^[#.]\\)"
"\\|"
"\\(?:[#~]$\\)" ;lock/temp files
"\\|"
"\\(?:\\.pyc$\\)" ;.pyc files
"\\|"
"\\(?:^__pycache__$\\)" ;pycache
))
:diminish counsel-mode)
;; Swiper -- Isearch on steroids using Ivy.
(use-package swiper
:ensure t
:bind
(("C-s" . swiper-isearch)
("M-s ." . swiper-isearch-thing-at-point)))
;; Projectile
(use-package projectile
:ensure t
:init
(projectile-mode)
:config
(setq projectile-indexing-method 'native
projectile-enable-caching t
projectile-mode-line-function '(lambda () (format " Prj[%s]" (projectile-project-name)))
;; projectile-svn-command "svn list -R --include-externals . | grep -v '/$' | tr '\\n' '\\0'"
projectile-globally-ignored-directories (append '("*__pycache__/")
projectile-globally-ignored-directories)
projectile-completion-system 'ivy
)
:bind-keymap
("C-c p" . projectile-command-map))
;; Avy -- Jump to visible text
(use-package avy
:ensure t
:config
(global-set-key (kbd "C-:") 'avy-goto-char)
(global-set-key (kbd "C-'") 'avy-goto-char-2)
(global-set-key (kbd "M-g f") 'avy-goto-line)
(global-set-key (kbd "M-g w") 'avy-goto-word-1))
;; Counsel-projectile -- Integrates projectile with Ivy
(use-package counsel-projectile
:ensure t
:if (and (featurep 'counsel) (featurep 'projectile))
:init
(counsel-projectile-mode)
:diminish)
;; Company-mode
(use-package company
:ensure t
:init
(global-company-mode)
:config
(setq company-show-quick-access t)
:bind
(("C-c a" . company-complete-tooltip-row))
:diminish company-mode)
;; Which key
(use-package which-key
:ensure t
:init
(which-key-mode)
:diminish which-key-mode)
;; Magit -- A Git Porcelain inside Emacs.
(use-package magit
:ensure t
:bind (("C-c g g" . magit-status)
("C-c g d" . magit-dispatch)
("C-c g f" . magit-file-dispatch)))
;; Yasnippet
(use-package yasnippet-snippets
:ensure t)
(use-package yasnippet
:ensure t
:after (yasnippet-snippets)
:init
(yas-global-mode)
:diminish yas-minor-mode)
;; Semantic - Source code lexical analysis from CEDET
;; (use-package semantic
;; :init
;; (semantic-mode 1)
;; :config
;; ;; Remove python from semantic
;; (assoc-delete-all 'python-mode semantic-new-buffer-setup-functions))
;; Diminish - needed for proper work of use-package
(use-package diminish
:ensure t)
;; EditorConfig support
(use-package editorconfig
:ensure t
:config
(editorconfig-mode 1)
:diminish)
;; +++
;; Deffered
;; +++-
;; Built-in
;; Flymake -- And shorten the mode-line string.
(use-package flymake
:defer t
:init
(add-hook 'emacs-lisp-mode-hook 'flymake-mode)
:bind (:map flymake-mode-map
("M-n" . flymake-goto-next-error)
("M-p" . flymake-goto-prev-error)))
(defun sch/shorten-flymake-mode-line (ret)
"Change the output of `flymake--mode-line-format'.
RET is the original return from the function."
(setf (seq-elt (car ret) 1) " Fly")
ret)
(advice-add 'flymake--mode-line-format
:filter-return 'sch/shorten-flymake-mode-line)
;; Spell-checking
(use-package flyspell
:defer t
:hook
(text-mode . flyspell-mode)
:diminish)
;; ElDoc -- just diminish the minor mode.
(use-package eldoc
:defer t
:diminish eldoc-mode)
;; Subword -- allows to move on sub-word in CamelCase
(use-package subword
:defer t
:hook
((python-mode clojure-mode c-mode-common typescript-mode org-mode) . subword-mode))
;; Org-mode -- Emacs' flawless organize package.
(use-package org
:defer t
:bind (("C-c o l" . org-store-link)
("C-c o a" . org-agenda)
("C-c o c" . org-capture)
("C-c o b" . org-switchb))
:config
;; Use enhanced exporter if available
(if (require 'ox-confluence-en nil t)
;; In current work place, Confluence doen't support PlantUML, so
;; disable macro export.
(setq ox-confluence-en-use-plantuml-macro nil)
(require 'ox-confluence))
(setq org-directory "~/org"
;; TODO keywords colours
org-todo-keyword-faces '(("TODO" . org-warning)
("PRG" . "yellow")
("WAIT" . "orange")
("DONE" . org-done))
;; File to keep the captured items
org-default-notes-file (concat org-directory "/refile.org")
;; Custom capture templates.
;; NOTE: This is variable from package org-capture...
org-capture-templates '(("t" "Task" entry (file "")
"* TODO %?\n Logged on: %u")
("n" "Note" entry (file "notes.org")
"* %?\n Logged on: %u"))
;; Agenda config
org-agenda-files (concat org-directory "/agenda_files")
org-agenda-restore-windows-after-quit t
org-agenda-todo-list-sublevels nil
;;; In TODO View of agenda, make visible only "open" (with not
;;; active timestamp) TODOs
org-agenda-todo-ignore-with-date t
org-refile-targets '((org-agenda-files . (:regexp . "Tasks$"))
(org-agenda-files . (:level . 1)))
org-refile-use-outline-path t
org-outline-path-complete-in-steps nil
org-plantuml-exec-mode 'plantuml)
;; Load babel evaluation languages support.
(org-babel-do-load-languages 'org-babel-load-languages
'((emacs-lisp . t)
(plantuml . t))))
;; +++-
;; LSP Client -- common for many languages.
(use-package eglot
:ensure t
:defer t
:config
(when (< emacs-major-version 30)
;; `eglot' in Emacs before version 30.* doesn't have support for
;; Lexical (Elixir) LSP. Add support for Lexical in that case.
(add-to-list 'eglot-server-programs
`((elixir-ts-mode heex-ts-mode) .
,(if (and (fboundp 'w32-shell-dos-semantics)
(w32-shell-dos-semantics))
'("language_server.bat")
(eglot-alternatives
'("language_server.sh" "start_lexical.sh"))))))
:bind (:map eglot-mode-map
("C-c e f" . eglot-format))
:hook
((python-mode . eglot-ensure)
(elixir-ts-mode . eglot-ensure)
(go-mode . eglot-ensure)
(typescript-mode . eglot-ensure)))
;; +++- Lisp Modes
(use-package paredit
:ensure t
:defer t
:bind (:map paredit-mode-map
("M-s" . nil)
("M-r" . nil)
("M-?" . nil)
("C-c e s" . paredit-splice-sexp)
("C-c e r" . paredit-raise-sexp)
("C-c e c" . paredit-convolute-sexp))
:hook ((lisp-mode emacs-lisp-mode clojure-mode) . paredit-mode)
:diminish)
;; +++-
;; Clojure
(use-package cider
:ensure t
:defer t
:init
(add-hook 'clojure-mode-hook 'cider-mode))
;; +++-
;; Guile Scheme
(use-package geiser-guile
:ensure t
:defer t
:hook (scheme-mode . geiser-mode))
;; +++-
;; Elixir
(when (>= emacs-major-version 29)
(use-package elixir-ts-mode
:ensure t
:defer t
:if (sch/treesit-available-p 'elixir)
:init
;; Emacs 30 has builtin support for `elixir-mode' and
;; `elixir-ts-mode', so we only remap. Older versions of Emacs will
;; automatically update 'auto-mode-alist' from the autoloads in the
;; (backported/this) MELPA package.
(when (>= emacs-major-version 30)
(push '(elixir-mode . elixir-ts-mode) major-mode-remap-alist))))
;; +++-
;; Python
;; Python mode
(defun sch/python-inline-comment-offset ()
"Set inline offset for comments in Python buffers."
(set (make-local-variable 'comment-inline-offset) 2))
(use-package python
:defer t
:init
(add-hook 'python-mode-hook 'sch/python-inline-comment-offset)
:config
;; Make indentation compatible with black
(setq python-indent-def-block-scale 1))
;; Pyenv
(defface sch/pyenv-face '((t (:weight bold :foreground "#de935f")))
"The face used to highlight the current python on the modeline."
:group 'pyenv)
(defun sch/restart-eglot-on-pyenv-change ()
"Restart eglot LSP when python version is changed."
(and (featurep 'eglot) (eglot-ensure)))
(defun sch/pyenv-modeline-function (current-python)
"Custom mode-line for pyenv.
CURRENT-PYTHON - string, currently selected python version."
`(:eval (if (eq major-mode 'python-mode)
(format "|%s|" (propertize
,current-python
'face
'sch/pyenv-face)))))
(use-package pyenv
:straight (:host github :repo "aiguofer/pyenv.el")
:defer t
:if (executable-find "pyenv")
:init
;; Search for the executable in PATH (why isn't this the default)
(setq pyenv-executable "pyenv")
;; Change mode-line func.
(setq pyenv-modeline-function 'sch/pyenv-modeline-function)
;; TODO: See the comment below for deferring.
(global-pyenv-mode 1)
:bind (("C-c v" . pyenv-use))
:hook (
;; TODO: Find a way to properly defer activating the global minor mode.
;; (python-mode . global-pyenv-mode)
(pyenv-mode . sch/restart-eglot-on-pyenv-change)))
;; Sphinx docstrings generation
(use-package sphinx-doc
:ensure t
:defer t
:init
(add-hook 'python-mode-hook 'sphinx-doc-mode)
:diminish sphinx-doc-mode)
;; Syntax highlight and fill-paragraph for docstrings.
(use-package python-docstring
:ensure t
:defer t
:init
(add-hook 'python-mode-hook 'python-docstring-mode)
:diminish python-docstring-mode)
;; +++-
;; SQL
(use-package sql-indent
:ensure t
:hook
(sql-mode . sqlind-minor-mode))
;; +++-
;; Shell script
(use-package flymake-shellcheck
:ensure t
:defer t
:init
(add-hook 'sh-mode-hook 'flymake-shellcheck-load)
(add-hook 'sh-mode-hook 'flymake-mode))
;; +++-
;; Typescript
(use-package typescript-mode
:ensure t
:defer t
:init
(add-hook 'typescript-mode-hook
(lambda () (setq indent-tabs-mode nil))))
;; +++-
;; Angular
(use-package ng2-mode
:ensure t
:defer t)
;; +++-
;; HTTP
;; Clever way of making requests.
(use-package restclient
:ensure t
:mode ("\\.restclient\\'" . restclient-mode))
;; Support for 'jq'-based hooks in 'restclient'
(use-package restclient-jq
:ensure t
:after restclient) ; note: `:after' uses eval-after-load; `:defer' should not be combined with `:after'!
;; jq-mode -- mainly as dependency for restclient-jq
(use-package jq-mode
:ensure t
:defer t)
;; HTTP requests lib.
(use-package request
:ensure t
:defer t)
;; +++-
;; Dockerfile
(use-package dockerfile-mode
:ensure t
:defer t
:config
(setq dockerfile-enable-auto-indent nil))
;; +++-
;; Kubernetes (old)
;; (use-package kubernetes
;; :ensure t
;; :commands (kubernetes-overview))
;; +++-
;; Kubernetes
(when (>= emacs-major-version 29)
(use-package kele
:ensure t
:bind-keymap
("C-c k" . kele-command-map)
:config
;; Temporary force kubeconfig to the default one
(setq kele-kubeconfig-path "~/.kube/config")))
;; +++-
;; Rego Policy Major Mode
(use-package rego-mode
:ensure t
:defer t)
;; +++-
;; Groovy major mode.
(use-package groovy-mode
:ensure t
:defer t)
;; +++-
;; Misc
;; Org community contributions
;; (use-package org-contrib
;; :straight t
;; :ensure t
;; :defer t)
;; Rainbow-Delimiters -- colors parentheses in programming modes.
;; (use-package rainbow-delimiters
;; :ensure t
;; :defer t
;; :init
;; (add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
;; :diminish rainbow-delimiters-mode)
;; Helm-Gtags -- helm interface to gtags.
;; (use-package helm-gtags
;; :ensure t
;; :if (featurep 'helm)
;; :defer t
;; :init
;; (progn
;; ;; Set the default key mapping
;; (setq helm-gtags-prefix-key "\C-cg"
;; helm-gtags-suggested-key-mapping t
;; helm-gtags-ignore-case t
;; helm-gtags-auto-update t)
;; ;; Enable for C-like modes
;; (add-hook 'c-mode-common-hook 'helm-gtags-mode))
;; :diminish helm-gtags-mode)
;; Counsel-Gtags -- ivy interface to gtags.
(use-package counsel-gtags
:ensure t
:if (featurep 'counsel)
:defer t
:bind (:map counsel-gtags-mode-map
("M-." . counsel-gtags-find-definition)
("M-r" . counsel-gtags-find-reference)
("M-s" . counsel-gtags-find-symbol)
("M-," . counsel-gtags-go-backward))
:init
;; Enabled for C-like modes
(add-hook 'c-mode-common-hook 'counsel-gtags-mode)
:diminish)
;; Amx - smex-like sorting in counsel-M-x.
(use-package amx
:ensure
:defer t)
;; Markdown major mode.
(use-package markdown-mode
:ensure t
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:defer t)
;; PlantUML major mode.
(use-package plantuml-mode
:ensure t
:mode "\\.plantuml\\'"
:config
(setq plantuml-default-exec-mode 'executable)
(setq plantuml-output-type "png")
;; Integrate with org-mode editing
(add-to-list 'org-src-lang-modes '("plantuml" . plantuml)))
;; Epub reader
(use-package nov
:ensure t
:defer t
:mode ("\\.epub\\'" . nov-mode))
;; -----------
;; DEPRECATED!
;; Left here only to illustrate the idea of `local-config',
;; `local-sources', `local-tempaltes'. I've replaced the
;; `local-config' and `local-templates' with new `site-config' and
;; `site-templates'. There is no alternative for `local-sources' for
;; now because I don't have the case, but maybe `straight' will be a
;; solution for that case.
;; +++
;; Installed from source
;; +++- Orgmine
;; + ++-- Orgmine Dependencies
;; (use-package elmine
;; :ensure t
;; :defer t)
;; ----------------------------------
;; Adding local-configs to load-path.
;; (add-to-list 'load-path (file-name-as-directory
;; (expand-file-name "local-configs"
;; user-emacs-directory)))
;; (let ((local-sources-dir (file-name-as-directory
;; (expand-file-name
;; "local-sources"
;; user-emacs-directory))))
;; ;; Orgmine
;; (add-to-list 'load-path (file-name-as-directory
;; (expand-file-name
;; "orgmine"
;; local-sources-dir)))
;; (when (require 'orgmine nil t)
;; (add-hook 'org-mode-hook
;; (lambda () (if (assoc "om_project" org-file-properties)
;; (orgmine-mode))))
;; (require 'orgmine-config))
;; ;; Confluence enhanced exporter
;; (add-to-list 'load-path (file-name-as-directory
;; (expand-file-name
;; "ox-confluence-en"
;; local-sources-dir))))
;; ---------------------
;; ^^^ / DEPRECATED! ^^^
;;; init.el ends here.