-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost-init.el
More file actions
963 lines (828 loc) · 34.7 KB
/
post-init.el
File metadata and controls
963 lines (828 loc) · 34.7 KB
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
;;; post-init.el --- DESCRIPTION -*- no-byte-compile: t; lexical-binding: t; -*-
;; Native compilation enhances Emacs performance by converting Elisp code into
;; native machine code, resulting in faster execution and improved
;; responsiveness.
;;
;; Ensure adding the following compile-angel code at the very beginning
;; of your `~/.emacs.d/post-init.el` file, before all other packages.
(use-package compile-angel
:demand t
:ensure t
:custom
;; Set `compile-angel-verbose` to nil to suppress output from compile-angel.
;; Drawback: The minibuffer will not display compile-angel's actions.
(compile-angel-verbose t)
:config
;; The following directive prevents compile-angel from compiling your init
;; files. If you choose to remove this push to `compile-angel-excluded-files'
;; and compile your pre/post-init files, ensure you understand the
;; implications and thoroughly test your code. For example, if you're using
;; the `use-package' macro, you'll need to explicitly add:
;; (eval-when-compile (require 'use-package))
;; at the top of your init file.
(push "/init.el" compile-angel-excluded-files)
(push "/early-init.el" compile-angel-excluded-files)
(push "/pre-init.el" compile-angel-excluded-files)
(push "/post-init.el" compile-angel-excluded-files)
(push "/pre-early-init.el" compile-angel-excluded-files)
(push "/post-early-init.el" compile-angel-excluded-files)
;; A local mode that compiles .el files whenever the user saves them.
;; (add-hook 'emacs-lisp-mode-hook #'compile-angel-on-save-local-mode)
;; A global mode that compiles .el files prior to loading them via `load' or
;; `require'. Additionally, it compiles all packages that were loaded before
;; the mode `compile-angel-on-load-mode' was activated.
(compile-angel-on-load-mode 1))
;; Corfu enhances in-buffer completion by displaying a compact popup with
;; current candidates, positioned either below or above the point. Candidates
;; can be selected by navigating up or down.
(use-package corfu
:ensure t
:commands (corfu-mode global-corfu-mode)
:hook ((prog-mode . corfu-mode)
(shell-mode . corfu-mode)
(eshell-mode . corfu-mode))
:custom
;; Hide commands in M-x which do not apply to the current mode.
(read-extended-command-predicate #'command-completion-default-include-p)
;; Disable Ispell completion function. As an alternative try `cape-dict'.
(text-mode-ispell-word-completion nil)
(tab-always-indent 'complete)
;; Enable Corfu
:config
(global-corfu-mode))
;; Cape, or Completion At Point Extensions, extends the capabilities of
;; in-buffer completion. It integrates with Corfu or the default completion UI,
;; by providing additional backends through completion-at-point-functions.
(use-package cape
:ensure t
:commands (cape-dabbrev cape-file cape-elisp-block)
:bind ("C-c p" . cape-prefix-map)
:init
;; Add to the global default value of `completion-at-point-functions' which is
;; used by `completion-at-point'.
(add-hook 'completion-at-point-functions #'cape-dabbrev)
(add-hook 'completion-at-point-functions #'cape-file)
(add-hook 'completion-at-point-functions #'cape-elisp-block))
;; Vertico provides a vertical completion interface, making it easier to
;; navigate and select from completion candidates (e.g., when `M-x` is pressed).
(use-package vertico
;; (Note: It is recommended to also enable the savehist package.)
:ensure t
:config
(vertico-mode))
;; The flyspell package is a built-in Emacs minor mode that provides
;; on-the-fly spell checking. It highlights misspelled words as you type,
;; offering interactive corrections. In text modes, it checks the entire buffer,
;; while in programming modes, it typically checks only comments and strings. It
;; integrates with external spell checkers like aspell, hunspell, or
;; ispell to provide suggestions and corrections.
;;
;; NOTE: flyspell-mode can become slow when using Aspell, especially with large
;; buffers or aggressive suggestion settings like --sug-mode=ultra. This
;; slowdown occurs because Flyspell checks words dynamically as you type or
;; navigate text, requiring frequent communication between Emacs and the
;; external Aspell process. Each check involves sending words to Aspell and
;; receiving results, which introduces overhead from process invocation and
;; inter-process communication.
(use-package ispell
:ensure nil
:commands (ispell ispell-minor-mode)
:custom
;; Set the ispell program name to aspell
(ispell-program-name "aspell")
;; Define the "en_US" spell-check dictionary locally, telling Emacs to use
;; UTF-8 encoding, match words using alphabetic characters, allow apostrophes
;; inside words, treat non-alphabetic characters as word boundaries, and pass
;; -d en_US to the underlying spell-check program.
(ispell-local-dictionary-alist
'(("en_US" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_US") nil utf-8)))
;; Configures Aspell's suggestion mode to "ultra", which provides more
;; aggressive and detailed suggestions for misspelled words. The language
;; is set to "en_US" for US English, which can be replaced with your desired
;; language code (e.g., "en_GB" for British English, "de_DE" for German).
(ispell-extra-args '(; "--sug-mode=ultra"
"--lang=en_US")))
;; The flyspell package is a built-in Emacs minor mode that provides
;; on-the-fly spell checking. It highlights misspelled words as you type,
;; offering interactive corrections.
(use-package flyspell
:ensure nil
:commands flyspell-mode
:hook
(; (prog-mode . flyspell-prog-mode)
(text-mode . (lambda()
(if (or (derived-mode-p 'yaml-mode)
(derived-mode-p 'yaml-ts-mode)
(derived-mode-p 'ansible-mode))
(flyspell-prog-mode 1)
(flyspell-mode 1)))))
:config
;; Remove strings from Flyspell
(setq flyspell-prog-text-faces (delq 'font-lock-string-face
flyspell-prog-text-faces))
;; Remove doc from Flyspell
(setq flyspell-prog-text-faces (delq 'font-lock-doc-face
flyspell-prog-text-faces)))
;;; from LibreOffice
;;; johne@Johns-MacBook-Air dict-en % cp -p *.dic ~/Library/Spelling
;;; johne@Johns-MacBook-Air dict-en % cp -p *.aff ~/Library/Spelling
;;; https://github.com/MArpogaus/emacs.d
;; (use-package jinx
;; :if (executable-find "enchant-2")
;; :custom
;; (jinx-languages "en_US")
;; :bind (("M-$" . jinx-correct)
;; ("C-M-$" . jinx-languages))
;; :hook
;; (elpaca-after-init . global-jinx-mode))
;; Vertico leverages Orderless' flexible matching capabilities, allowing users
;; to input multiple patterns separated by spaces, which Orderless then
;; matches in any order against the candidates.
(use-package orderless
:ensure t
:custom
(completion-styles '(orderless basic))
(completion-category-defaults nil)
(completion-category-overrides '((file (styles partial-completion)))))
;; Marginalia allows Embark to offer you preconfigured actions in more contexts.
;; In addition to that, Marginalia also enhances Vertico by adding rich
;; annotations to the completion candidates displayed in Vertico's interface.
(use-package marginalia
:ensure t
:commands (marginalia-mode marginalia-cycle)
:hook (after-init . marginalia-mode))
;; Embark integrates with Consult and Vertico to provide context-sensitive
;; actions and quick access to commands based on the current selection, further
;; improving user efficiency and workflow within Emacs. Together, they create a
;; cohesive and powerful environment for managing completions and interactions.
(use-package embark
;; Embark is an Emacs package that acts like a context menu, allowing
;; users to perform context-sensitive actions on selected items
;; directly from the completion interface.
:ensure t
:commands (embark-act
embark-dwim
embark-export
embark-collect
embark-bindings
embark-prefix-help-command)
:bind
(("C-." . embark-act) ;; pick some comfortable binding
("C-;" . embark-dwim) ;; good alternative: M-.
("C-h B" . embark-bindings)) ;; alternative for `describe-bindings'
:init
(setq prefix-help-command #'embark-prefix-help-command)
:config
;; Hide the mode line of the Embark live/completions buffers
(add-to-list 'display-buffer-alist
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
nil
(window-parameters (mode-line-format . none)))))
(use-package embark-consult
:ensure t
:hook
(embark-collect-mode . consult-preview-at-point-mode))
;; Consult offers a suite of commands for efficient searching, previewing, and
;; interacting with buffers, file contents, and more, improving various tasks.
(use-package consult
:ensure t
:bind (;; C-c bindings in `mode-specific-map'
("C-c M-x" . consult-mode-command)
("C-c h" . consult-history)
("C-c k" . consult-kmacro)
("C-c m" . consult-man)
("C-c i" . consult-info)
([remap Info-search] . consult-info)
;; C-x bindings in `ctl-x-map'
("C-x M-:" . consult-complex-command)
("C-x b" . consult-buffer)
("C-x 4 b" . consult-buffer-other-window)
("C-x 5 b" . consult-buffer-other-frame)
("C-x t b" . consult-buffer-other-tab)
("C-x r b" . consult-bookmark)
("C-x p b" . consult-project-buffer)
;; Custom M-# bindings for fast register access
("M-#" . consult-register-load)
("M-'" . consult-register-store)
("C-M-#" . consult-register)
;; Other custom bindings
("M-y" . consult-yank-pop)
;; M-g bindings in `goto-map'
("M-g e" . consult-compile-error)
("M-g f" . consult-flymake)
("M-g g" . consult-goto-line)
("M-g M-g" . consult-goto-line)
("M-g o" . consult-outline)
("M-g m" . consult-mark)
("M-g k" . consult-global-mark)
("M-g i" . consult-imenu)
("M-g I" . consult-imenu-multi)
;; M-s bindings in `search-map'
("M-s d" . consult-find)
("M-s c" . consult-locate)
("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)
("M-s k" . consult-keep-lines)
("M-s u" . consult-focus-lines)
;; Isearch integration
("M-s e" . consult-isearch-history)
:map isearch-mode-map
("M-e" . consult-isearch-history)
("M-s e" . consult-isearch-history)
("M-s l" . consult-line)
("M-s L" . consult-line-multi)
;; Minibuffer history
:map minibuffer-local-map
("M-s" . consult-history)
("M-r" . consult-history))
;; Enable automatic preview at point in the *Completions* buffer.
:hook (completion-list-mode . consult-preview-at-point-mode)
:init
;; Optionally configure the register formatting. This improves the register
(setq register-preview-delay 0.5
register-preview-function #'consult-register-format)
;; Optionally tweak the register preview window.
(advice-add #'register-preview :override #'consult-register-window)
;; Use Consult to select xref locations with preview
(setq xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref)
;; Aggressive asynchronous that yield instantaneous results. (suitable for
;; high-performance systems.) Note: Minad, the author of Consult, does not
;; recommend aggressive values.
;; Read: https://github.com/minad/consult/discussions/951
;;
;; However, the author of minimal-emacs.d uses these parameters to achieve
;; immediate feedback from Consult.
;; (setq consult-async-input-debounce 0.02
;; consult-async-input-throttle 0.05
;; consult-async-refresh-delay 0.02)
:config
(consult-customize
consult-theme :preview-key '(:debounce 0.2 any)
consult-ripgrep consult-git-grep consult-grep
consult-bookmark consult-recent-file consult-xref
;; consult--source-bookmark consult--source-file-register
;; consult--source-recent-file consult--source-project-recent-file
;; :preview-key "M-."
:preview-key '(:debounce 0.4 any))
(setq consult-narrow-key "<"))
;; (mapc #'disable-theme custom-enabled-themes) ; Disable all active themes
;; (load-theme 'modus-vivendi t) ; Load the built-in theme
;; The stripspace Emacs package provides stripspace-local-mode, a minor mode
;; that automatically removes trailing whitespace and blank lines at the end of
;; the buffer when saving.
(use-package stripspace
:ensure t
:commands stripspace-local-mode
;; Enable for prog-mode-hook, text-mode-hook, conf-mode-hook
:hook ((prog-mode . stripspace-local-mode)
(text-mode . stripspace-local-mode)
(conf-mode . stripspace-local-mode))
:custom
;; The `stripspace-only-if-initially-clean' option:
;; - nil to always delete trailing whitespace.
;; - Non-nil to only delete whitespace when the buffer is clean initially.
;; (The initial cleanliness check is performed when `stripspace-local-mode'
;; is enabled.)
(stripspace-only-if-initially-clean nil)
;; Enabling `stripspace-restore-column' preserves the cursor's column position
;; even after stripping spaces. This is useful in scenarios where you add
;; extra spaces and then save the file. Although the spaces are removed in the
;; saved file, the cursor remains in the same position, ensuring a consistent
;; editing experience without affecting cursor placement.
(stripspace-restore-column t))
;; stuck on this issue
;;(setq google-this-keybind (kbd "C-x g"))
;;(global-set-key (kbd "C-x g") 'google-this-mode-submap)
(use-package google-this
:config
(google-this-mode 1))
;; Org mode is a major mode designed for organizing notes, planning, task
;; management, and authoring documents using plain text with a simple and
;; expressive markup syntax. It supports hierarchical outlines, TODO lists,
;; scheduling, deadlines, time tracking, and exporting to multiple formats
;; including HTML, LaTeX, PDF, and Markdown.
(use-package org
:ensure t
:commands (org-mode org-version)
:mode
("\\.org\\'" . org-mode)
:custom
(org-hide-leading-stars t)
(org-startup-indented t)
(org-adapt-indentation nil)
(org-edit-src-content-indentation 0)
;; (org-fontify-done-headline t)
;; (org-fontify-todo-headline t)
;; (org-fontify-whole-heading-line t)
;; (org-fontify-quote-and-verse-blocks t)
(org-startup-truncated t))
;; emacs use package org-bullets
(use-package org-bullets
:after org
:hook (org-mode . org-bullets-mode)
:custom
(org-bullets-bullet-list '("◉" "○" "●" "○" "●" "○" "●")))
;; https://kaksikoivua.hashnode.dev/emacs-warning-on-macos-ls-does-not-support-dired
;; without use-package
(when (and (eq system-type 'darwin) (executable-find "gls"))
(setq insert-directory-program "gls"))
;; https://www.gnu.org/software/emacs/manual/html_mono/modus-themes.html#Enable-and-load
(mapc #'disable-theme custom-enabled-themes)
(load-theme 'modus-vivendi :no-confirm)
;; The markdown-mode package provides a major mode for Emacs for syntax
;; highlighting, editing commands, and preview support for Markdown documents.
;; It supports core Markdown syntax as well as extensions like GitHub Flavored
;; Markdown (GFM).
(use-package markdown-mode
:commands (gfm-mode
gfm-view-mode
markdown-mode
markdown-view-mode)
:mode (("\\.markdown\\'" . markdown-mode)
("\\.md\\'" . markdown-mode)
("README\\.md\\'" . gfm-mode))
:bind
(:map markdown-mode-map
("C-c C-e" . markdown-do)))
;; 14 pt font size
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(blink-cursor-mode nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:family "Menlo" :foundry "nil" :slant normal :weight regular :height 140 :width normal)))))
;; (use-package erc
;; :config
;; ;; Set nickname and server
;; (setq erc-nick "jeis4wpi"
;; erc-server "irc.freenode.net"
;; erc-port 6697)
;;
;; ;; Enable TLS (use erc-tls)
;; (setq erc-tls-verify nil) ; Optional: disable certificate verification
;;
;; ;; Auto-join channels after identifying
;; (setq erc-autojoin-channels-alist '(("irc.freenode.net" . ("#emacs" "#emacs-beginners"))))
;;
;; ;; Auto-reconnect on disconnect
;; (setq erc-server-auto-reconnect t)
;;
;; ;; Enable auto-join and logging
;; (erc-autojoin-mode t)
;; (require 'erc-log)
;; (erc-log-mode t)
;; (setq erc-log-channels-directory "~/.erc/logs/")
;; )
;;; emacs use package php mode example configs
(use-package php-mode
:ensure t
:mode (("\\.php\\'" . php-mode)
("\\.inc\\'" . php-mode)
("\\.module\\'" . php-mode))
:hook (php-mode . (lambda ()
(emmet-mode +1)
(flycheck-mode +1)
(company-mode +1)
(eldoc-mode +1)
(smartparens-strict-mode +1)))
:init
(setq flycheck-phpcs-standard "PSR2"
flycheck-php-executable "/usr/bin/php"
flycheck-php-phpcs-executable "~/.composer/vendor/bin/phpcs"
flycheck-php-phpmd-executable "~/.composer/vendor/bin/phpmd"))
;; (use-package mmm-mode
;; :ensure t
;; :config
;; (setq mmm-global-mode 'maybe)
;; (mmm-add-mode-ext-class nil "\\.php\\'" 'html-php)
;; (mmm-add-classes
;; '((html-php
;; :submode php-mode
;; :front "<\\?\$$php\$$?"
;; :back "\\?>")))
;;; mmm-mode use package emacs config didn't work ?
(use-package mmm-mode
:ensure t
:config
(mmm-add-mode-ext-class 'latex-mode nil 'latex-python)
(setq mmm-global-mode 'maybe))
;;; use package emmet-mode emacs modern example
(use-package emmet-mode
:ensure t
:after (web-mode css-mode scss-mode)
:commands (emmet-mode emmet-expand-line)
:config
;; Move cursor between quotes after expansion
(setq emmet-move-cursor-between-quotes t)
;; Disable auto-indentation after insert (optional)
(add-hook 'emmet-mode-hook (lambda () (setq emmet-indent-after-insert nil)))
;; Auto-enable on relevant modes
(add-hook 'sgml-mode-hook 'emmet-mode)
(add-hook 'web-mode-hook 'emmet-mode)
(add-hook 'css-mode-hook 'emmet-mode)
;; Key binding: C-j to expand line
:bind ("C-j" . emmet-expand-line)
;; Optional: Customize keymap for navigation
:bind (:map emmet-mode-keymap
("C-c [" . emmet-prev-edit-point)
("C-c ]" . emmet-next-edit-point))
)
;;; my configs - middle
(display-time)
(defun kill-default-buffer ()
"Kill buffer without prompt"
(interactive)
(let (kill-buffer-query-functions) (kill-buffer)))
(global-set-key (kbd "C-x k") 'kill-default-buffer)
(add-to-list 'major-mode-remap-alist '(perl-mode . cperl-mode))
(defun perltidy-region ()
"Run perltidy on the current region."
(interactive)
(save-excursion
(shell-command-on-region (point) (mark) "perltidy -q" nil t)))
(defun perltidy-defun ()
"Run perltidy on the current defun."
(interactive)
(save-excursion (mark-defun)
(perltidy-region)))
(add-to-list 'auto-mode-alist '("\\.pg\\'" . cperl-mode))
;; use global dirvis
;;(dirvish-override-dired-mode)
;;; end my configs - middle
;; Tree-sitter in Emacs is an incremental parsing system introduced in Emacs 29
;; that provides precise, high-performance syntax highlighting. It supports a
;; broad set of programming languages, including Bash, C, C++, C#, CMake, CSS,
;; Dockerfile, Go, Java, JavaScript, JSON, Python, Rust, TOML, TypeScript, YAML,
;; Elisp, Lua, Markdown, and many others.
(use-package treesit-auto
:ensure t
:custom
(treesit-auto-install 'prompt)
:config
(treesit-auto-add-to-auto-mode-alist 'all)
(global-treesit-auto-mode))
;; This automates the process of updating installed packages
(use-package auto-package-update
:ensure t
:custom
;; Set the number of days between automatic updates.
;; Here, packages will only be updated if at least 7 days have passed
;; since the last successful update.
(auto-package-update-interval 7)
;; Suppress display of the *auto-package-update results* buffer after updates.
;; This keeps the user interface clean and avoids unnecessary interruptions.
(auto-package-update-hide-results t)
;; Automatically delete old package versions after updates to reduce disk
;; usage and keep the package directory clean. This prevents the accumulation
;; of outdated files in Emacs’s package directory, which consume
;; unnecessary disk space over time.
(auto-package-update-delete-old-versions t)
;; Uncomment the following line to enable a confirmation prompt
;; before applying updates. This can be useful if you want manual control.
;; (auto-package-update-prompt-before-update t)
:config
;; Run package updates automatically at startup, but only if the configured
;; interval has elapsed.
(auto-package-update-maybe)
;; Schedule a background update attempt daily at 10:00 AM.
;; This uses Emacs' internal timer system. If Emacs is running at that time,
;; the update will be triggered. Otherwise, the update is skipped for that
;; day. Note that this scheduled update is independent of
;; `auto-package-update-maybe` and can be used as a complementary or
;; alternative mechanism.
(auto-package-update-at-time "10:00"))
(use-package avy
:ensure t
:commands (avy-goto-char
avy-goto-char-2
avy-next)
:init
(global-set-key (kbd "C-'") 'avy-goto-char-2))
;; Apheleia is an Emacs package designed to run code formatters (e.g., Shfmt,
;; Black and Prettier) asynchronously without disrupting the cursor position.
(use-package apheleia
:ensure t
:commands (apheleia-mode
apheleia-global-mode)
:hook ((prog-mode . apheleia-mode)))
;; Helpful is an alternative to the built-in Emacs help that provides much more
;; contextual information.
(use-package helpful
:ensure t
:commands (helpful-callable
helpful-variable
helpful-key
helpful-command
helpful-at-point
helpful-function)
:bind
([remap describe-command] . helpful-command)
([remap describe-function] . helpful-callable)
([remap describe-key] . helpful-key)
([remap describe-symbol] . helpful-symbol)
([remap describe-variable] . helpful-variable)
:custom
(helpful-max-buffers 7))
;; Enables automatic indentation of code while typing
(use-package aggressive-indent
:ensure t
:commands aggressive-indent-mode
:hook
(emacs-lisp-mode . aggressive-indent-mode))
;; Highlights function and variable definitions in Emacs Lisp mode
(use-package highlight-defined
:ensure t
:commands highlight-defined-mode
:hook
(emacs-lisp-mode . highlight-defined-mode))
;; Prevent parenthesis imbalance
(use-package paredit
:ensure t
:commands paredit-mode
:hook
(emacs-lisp-mode . paredit-mode)
:config
(define-key paredit-mode-map (kbd "RET") nil))
;; For paredit+Evil mode users: enhances paredit with Evil mode compatibility
;; --------------------------------------------------------------------------
;; (use-package enhanced-evil-paredit
;; :ensure t
;; :commands enhanced-evil-paredit-mode
;; :hook
;; (paredit-mode . enhanced-evil-paredit-mode))
;; Displays visible indicators for page breaks
(use-package page-break-lines
:ensure t
:commands (page-break-lines-mode
global-page-break-lines-mode)
:hook
(emacs-lisp-mode . page-break-lines-mode))
;; Provides functions to find references to functions, macros, variables,
;; special forms, and symbols in Emacs Lisp
(use-package elisp-refs
:ensure t
:commands (elisp-refs-function
elisp-refs-macro
elisp-refs-variable
elisp-refs-special
elisp-refs-symbol))
;; Allow Emacs to upgrade built-in packages, such as Org mode
(setq package-install-upgrade-built-in t)
;; When Delete Selection mode is enabled, typed text replaces the selection
;; if the selection is active.
(delete-selection-mode 1)
;; Display the current line and column numbers in the mode line
(setq line-number-mode t)
(setq column-number-mode t)
(setq mode-line-position-column-line-format '("%l:%C"))
;; Display of line numbers in the buffer:
;; (setq-default display-line-numbers-type 'relative)
(dolist (hook '(prog-mode-hook text-mode-hook conf-mode-hook))
(add-hook hook #'display-line-numbers-mode))
;; Set the maximum level of syntax highlighting for Tree-sitter modes
(setq treesit-font-lock-level 4)
(use-package which-key
:ensure nil ; builtin
:commands which-key-mode
:hook (after-init . which-key-mode)
:custom
(which-key-idle-delay 1.5)
(which-key-idle-secondary-delay 0.25)
(which-key-add-column-padding 1)
(which-key-max-description-length 40))
(unless (and (eq window-system 'mac)
(bound-and-true-p mac-carbon-version-string))
;; Enables `pixel-scroll-precision-mode' on all operating systems and Emacs
;; versions, except for emacs-mac.
;;
;; Enabling `pixel-scroll-precision-mode' is unnecessary with emacs-mac, as
;; this version of Emacs natively supports smooth scrolling.
;; https://bitbucket.org/mituharu/emacs-mac/commits/65c6c96f27afa446df6f9d8eff63f9cc012cc738
(setq pixel-scroll-precision-use-momentum nil) ; Precise/smoother scrolling
(pixel-scroll-precision-mode 1))
;; Display the time in the modeline
(add-hook 'after-init-hook #'display-time-mode)
;; Paren match highlighting
(add-hook 'after-init-hook #'show-paren-mode)
;; Track changes in the window configuration, allowing undoing actions such as
;; closing windows.
(add-hook 'after-init-hook #'winner-mode)
(use-package uniquify
:ensure nil
:custom
(uniquify-buffer-name-style 'reverse)
(uniquify-separator "•")
(uniquify-after-kill-buffer-p t))
;; Window dividers separate windows visually. Window dividers are bars that can
;; be dragged with the mouse, thus allowing you to easily resize adjacent
;; windows.
;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Window-Dividers.html
(add-hook 'after-init-hook #'window-divider-mode)
;; Constrain vertical cursor movement to lines within the buffer
(setq dired-movement-style 'bounded-files)
;; Dired buffers: Automatically hide file details (permissions, size,
;; modification date, etc.) and all the files in the `dired-omit-files' regular
;; expression for a cleaner display.
(add-hook 'dired-mode-hook #'dired-hide-details-mode)
;; Hide files from dired
(setq dired-omit-files (concat "\\`[.]\\'"
"\\|\\(?:\\.js\\)?\\.meta\\'"
"\\|\\.\\(?:elc|a\\|o\\|pyc\\|pyo\\|swp\\|class\\)\\'"
"\\|^\\.DS_Store\\'"
"\\|^\\.\\(?:svn\\|git\\)\\'"
"\\|^\\.ccls-cache\\'"
"\\|^__pycache__\\'"
"\\|^\\.project\\(?:ile\\)?\\'"
"\\|^flycheck_.*"
"\\|^flymake_.*"))
;;
;; this blocks pg files in OPL AS* stats dir
;;;(add-hook 'dired-mode-hook #'dired-omit-mode)
;; dired: Group directories first
(with-eval-after-load 'dired
(let ((args "--group-directories-first -ahlv"))
(when (or (eq system-type 'darwin) (eq system-type 'berkeley-unix))
(if-let* ((gls (executable-find "gls")))
(setq insert-directory-program gls)
(setq args nil)))
(when args
(setq dired-listing-switches args))))
;; Enables visual indication of minibuffer recursion depth after initialization.
(add-hook 'after-init-hook #'minibuffer-depth-indicate-mode)
;; Configure Emacs to ask for confirmation before exiting
(setq confirm-kill-emacs 'y-or-n-p)
;; Enabled backups save your changes to a file intermittently
(setq make-backup-files t)
(setq vc-make-backup-files t)
(setq kept-old-versions 10)
(setq kept-new-versions 10)
;; When tooltip-mode is enabled, certain UI elements (e.g., help text,
;; mouse-hover hints) will appear as native system tooltips (pop-up windows),
;; rather than as echo area messages. This is useful in graphical Emacs sessions
;; where tooltips can appear near the cursor.
(setq tooltip-hide-delay 20) ; Time in seconds before a tooltip disappears (default: 10)
(setq tooltip-delay 0.4) ; Delay before showing a tooltip after mouse hover (default: 0.7)
(setq tooltip-short-delay 0.08) ; Delay before showing a short tooltip (Default: 0.1)
(tooltip-mode 1)
;; Configure the built-in Emacs server to start after initialization,
;; allowing the use of the emacsclient command to open files in the
;; current session.
(use-package server
:ensure nil
:commands server-start
:hook
(after-init . server-start))
;;; emacs ein config use package
(use-package ein
:ensure t
:config
;; Optional: Customize EIN behavior
(setq ein:notebook-external-browser "firefox") ; or your preferred browser
(setq ein:output-area-in-notebook-mode t) ; Show outputs inline
(setq ein:local-url "http://localhost:8888") ; Default Jupyter server URL
)
;;; seemed to get stuck on combobulate wtih Mickey's treesit grammer automatic installs
;;; manual install by M-x treesit-install-language-grammar
;;; https://github.com/mickeynp/combobulate?tab=readme-ov-file#complete-example-with-tree-sitter-grammar-installation
;;; https://github.com/mickeynp/combobulate
;; (use-package treesit
;; :mode (("\\.tsx\\'" . tsx-ts-mode))
;; :preface
;; (defun mp-setup-install-grammars ()
;; "Install Tree-sitter grammars if they are absent."
;; (interactive)
;; (dolist (grammar
;; ;; Note the version numbers. These are the versions that
;; ;; are known to work with Combobulate *and* Emacs.
;; '((css . ("https://github.com/tree-sitter/tree-sitter-css" "v0.20.0"))
;; (go . ("https://github.com/tree-sitter/tree-sitter-go" "v0.20.0"))
;; (html . ("https://github.com/tree-sitter/tree-sitter-html" "v0.20.1"))
;; (javascript . ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.20.1" "src"))
;; (json . ("https://github.com/tree-sitter/tree-sitter-json" "v0.20.2"))
;; (markdown . ("https://github.com/ikatyang/tree-sitter-markdown" "v0.7.1"))
;; (python . ("https://github.com/tree-sitter/tree-sitter-python" "v0.20.4"))
;; (rust . ("https://github.com/tree-sitter/tree-sitter-rust" "v0.21.2"))
;; (toml . ("https://github.com/tree-sitter/tree-sitter-toml" "v0.5.1"))
;; (tsx . ("https://github.com/tree-sitter/tree-sitter-typescript" "v0.20.3" "tsx/src"))
;; (typescript . ("https://github.com/tree-sitter/tree-sitter-typescript" "v0.20.3" "typescript/src"))
;; (yaml . ("https://github.com/ikatyang/tree-sitter-yaml" "v0.5.0"))))
;; (add-to-list 'treesit-language-source-alist grammar)
;; ;; Only install `grammar' if we don't already have it
;; ;; installed. However, if you want to *update* a grammar then
;; ;; this obviously prevents that from happening.
;; (unless (treesit-language-available-p (car grammar))
;; (treesit-install-language-grammar (car grammar)))))
;;
;; ;; Optional. Combobulate works in both xxxx-ts-modes and
;; ;; non-ts-modes.
;;
;; ;; You can remap major modes with `major-mode-remap-alist'. Note
;; ;; that this does *not* extend to hooks! Make sure you migrate them
;; ;; also
;; (dolist (mapping
;; '((python-mode . python-ts-mode)
;; (css-mode . css-ts-mode)
;; (typescript-mode . typescript-ts-mode)
;; (js2-mode . js-ts-mode)
;; (bash-mode . bash-ts-mode)
;; (conf-toml-mode . toml-ts-mode)
;; (go-mode . go-ts-mode)
;; (css-mode . css-ts-mode)
;; (json-mode . json-ts-mode)
;; (js-json-mode . json-ts-mode)))
;; (add-to-list 'major-mode-remap-alist mapping))
;; :config
;; (mp-setup-install-grammars)
;; ;; Do not forget to customize Combobulate to your liking:
;; ;;
;; ;; M-x customize-group RET combobulate RET
;; ;;
;; (use-package combobulate
;; :custom
;; ;; You can customize Combobulate's key prefix here.
;; ;; Note that you may have to restart Emacs for this to take effect!
;; (combobulate-key-prefix "C-c o")
;; :hook ((prog-mode . combobulate-mode))
;; ;; Amend this to the directory where you keep Combobulate's source
;; ;; code.
;; :load-path ("/Users/johne/Public/combobulate")))
;;; https://github.com/MArpogaus/emacs.d
;;; https://lucidmanager.org/productivity/read-rss-feeds-with-emacs-and-elfeed/
;; Configure Elfeed
(use-package elfeed
:custom
(elfeed-db-directory
(expand-file-name "elfeed" user-emacs-directory))
(elfeed-show-entry-switch 'display-buffer)
:bind
("C-c w e" . elfeed))
;;; https://unwoundstack.com/blog/emacs-as-a-rust-ide.html
;; rust might be TODO work?
;; dotnet tool install --global csharp-ls
;; export PATH="$PATH:/Users/johne/.dotnet/tools"
;;;
;; (use-package lsp-mode
;; :ensure t
;; :hook ((csharp-mode . lsp)
;; (csharp-mode . lsp-ui-mode))
;; :init (setq lsp-keymap-prefix "C-c l")
;; :commands lsp)
;;; emacs swift lsp config use package
;;; https://www.swift.org/documentation/articles/zero-to-swift-emacs.html
;;; Add MELPA and bootstrap use-package
;; (require 'package)
;; (setq package-enable-at-startup nil)
;; (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
;; (package-initialize)
;;
;; (unless (package-installed-p 'use-package)
;; (package-refresh-contents)
;; (package-install 'use-package))
;; (eval-when-compile (require 'use-package))
;;; Locate sourcekit-lsp executable
(defun find-sourcekit-lsp ()
(or (executable-find "sourcekit-lsp")
(and (eq system-type 'darwin)
(string-trim (shell-command-to-string "xcrun -f sourcekit-lsp")))
"/usr/local/swift/usr/bin/sourcekit-lsp"))
;;; Swift development packages
;; (use-package editorconfig
;; :ensure t
;; :config (editorconfig-mode +1))
;;
;; (use-package swift-mode
;; :ensure t
;; :mode "\\.swift\\'"
;; :interpreter "swift")
;;
;; (use-package rainbow-delimiters
;; :ensure t
;; :hook ((prog-mode . rainbow-delimiters-mode)))
;;
;; (use-package company
;; :ensure t
;; :config (global-company-mode +1))
;;
;; (use-package lsp-mode
;; :ensure t
;; :commands lsp
;; :hook ((swift-mode . lsp)))
;;
;; (use-package lsp-ui
;; :ensure t)
;;
;; (use-package lsp-sourcekit
;; :ensure t
;; :after lsp-mode
;; :custom
;; (lsp-sourcekit-executable (find-sourcekit-lsp) "Find sourcekit-lsp"))