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
|
* My emacs config
** Basic configs
#+BEGIN_SRC emacs-lisp
(server-start)
(setq x-alt-keysym 'meta)
(set-keyboard-coding-system 'utf-8)
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(blink-cursor-mode -1)
(setq visible-cursor nil)
(global-hl-line-mode 1)
(global-auto-revert-mode t)
(defun my/disable-scroll-bars (frame)
(modify-frame-parameters frame
'((vertical-scroll-bars . nil)
(horizontal-scroll-bars . nil))))
(add-hook 'after-make-frame-functions 'my/disable-scroll-bars)
(setq default-frame-alist '((font . "mononoki Nerd Font:pixelsize=15")))
;; (set-frame-font "mononoki Nerd Font:pixelsize=15" nil t)
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
(add-hook 'text-mode-hook 'display-line-numbers-mode)
(setq scroll-step 1)
;; (setq scroll-margin 1)
(setq echo-keystrokes 0.1)
(setq initial-scratch-message nil)
(defalias 'yes-or-no-p 'y-or-n-p)
(setq backup-directory-alist '(("." . "/tmp/emacs-backup"))
backup-by-copying t
version-control t
delete-old-versions t
kept-new-versions 20
kept-old-versions 5)
#+END_SRC
** Desktop-save
#+BEGIN_SRC emacs-lisp
(setq desktop-dirname (expand-file-name "desktop" user-emacs-directory)
desktop-base-file-name "emacs.desktop"
desktop-base-lock-name "lock"
desktop-path (list desktop-dirname)
desktop-save t
desktop-files-not-to-save "^$"
desktop-auto-save-timeout 60)
(desktop-save-mode 1)
#+END_SRC
** GC
#+BEGIN_SRC emacs-lisp
(add-hook 'focus-out-hook 'garbage-collect)
(add-hook 'minibuffer-setup-hook 'my/set-max-gc-cons-threshold) ;; defined in early-init.el
(add-hook 'minibuffer-exit-hook 'my/set-default-gc-cons-threshold)
#+END_SRC
** MELPA and non-MELPA
#+BEGIN_SRC emacs-lisp
(require 'package)
(push (expand-file-name "elpa" user-emacs-directory) package-directory-list)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)
(add-to-list 'load-path (expand-file-name "font-lock+" user-emacs-directory))
(add-to-list 'load-path (expand-file-name "header2/" user-emacs-directory))
(add-to-list 'load-path (expand-file-name "all-the-icons/" user-emacs-directory))
(add-to-list 'load-path (expand-file-name "all-the-icons-dired/" user-emacs-directory))
(setq package-selected-packages '(
evil evil-collection evil-leader
evil-search-highlight-persist evil-mc evil-surround evil-ediff
evil-visual-mark-mode evil-nerd-commenter evil-vimish-fold
evil-numbers evil-quickscope
lsp-mode lsp-ui
windresize
yasnippet yasnippet-classic-snippets yasnippet-snippets auto-yasnippet el-autoyas
helm helm-xref helm-lsp helm-etags-plus helm-fuzzy helm-themes helm-make helm-projectile
projectile
org-evil
company company-box company-go company-fuzzy company-nginx
which-key
magit
undo-tree
shell-pop
smartparens
rainbow-delimiters
color-identifiers-mode
ibuffer-vc ibuffer-projectile
eyebrowse
diff-hl
fzf
font-utils
restart-emacs
string-utils
dired-icon
kaolin-themes gruvbox-theme doom-themes spacemacs-theme
doom-modeline
dashboard
org-superstar toc-org
pdf-tools
dockerfile-mode
go-mode
web-mode
ssh sudo-ext
vimish-fold
bind-key
all-the-icons all-the-icons-dired all-the-icons-ibuffer
mutt-mode vimrc-mode nginx-mode gemini-mode yaml-mode crontab-mode
treemacs treemacs-evil treemacs-magit treemacs-projectile treemacs-all-the-icons lsp-treemacs
))
(when (cl-find-if-not #'package-installed-p package-selected-packages)
(package-refresh-contents)
(mapc #'package-install package-selected-packages))
#+END_SRC
** Some org
#+BEGIN_SRC emacs-lisp
;; set key for agenda
;; (require 'org)
;; (global-set-(kbd "C-c a") 'org-agenda)
;;file to save todo items
;; (setq org-agenda-files (quote ("~/.config/emacs/org/todo.org")))
(setq org-log-done 'time)
;;set priority range from A to C with default A
(setq org-highest-priority ?A)
(setq org-lowest-priority ?C)
(setq org-default-priority ?A)
;;set colours for priorities
(setq org-priority-faces '((?A . (:foreground "#F0DFAF" :weight bold))
(?B . (:foreground "LightSteelBlue"))
(?C . (:foreground "OliveDrab"))))
(setq org-todo-keywords
'((sequence "TODO"
"|"
"DONE"
"CANCELED")))
(setq org-log-done 'time)
;;open agenda in current window
;; (setq org-agenda-window-setup (quote current-window))
;;capture todo items using C-c C-t t
;; (define-key global-map (kbd "C-c C-t") 'org-capture)
;; (setq org-capture-templates
;; '(("t" "todo" entry (file+headline "~/.config/emacs/org/todo.org" "Tasks")
;; "* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n")))
;;open agenda in current window
;; (setq org-agenda-window-setup (quote current-window))
;;warn me of any deadlines in next 7 days
;; (setq org-deadline-warning-days 7)
;;show me tasks scheduled or due in next fortnight
;; (setq org-agenda-span (quote fortnight))
;;don't show tasks as scheduled if they are already shown as a deadline
;; (setq org-agenda-skip-scheduled-if-deadline-is-shown t)
;;don't give awarning colour to tasks with impending deadlines
;;if they are scheduled to be done
;; (setq org-agenda-skip-deadline-prewarning-if-scheduled (quote pre-scheduled))
;;don't show tasks that are scheduled or have deadlines in the
;;normal todo list
;; (setq org-agenda-todo-ignore-deadlines (quote all))
;; (setq org-agenda-todo-ignore-scheduled (quote all))
;;sort tasks in order of when they are due and then by priority
;; (setq org-agenda-sorting-strategy
;; (quote
;; ((agenda deadline-up priority-down)
;; (todo priority-down category-keep)
;; (tags priority-down category-keep)
;; (search category-keep))))
(org-babel-do-load-languages
'org-babel-load-languages '((C . t )))
(org-babel-do-load-languages
'org-babel-load-languages '((lisp . t)))
(eval-after-load "org"
'(require 'ox-md nil t))
#+END_SRC
** header2
#+BEGIN_SRC emacs-lisp
#+END_SRC
** Other configs
#+BEGIN_SRC emacs-lisp
(setq evil-want-integration t) ;; This is optional since it's already set to t by default.
(setq evil-want-keybinding nil)
(setq evil-want-C-u-scroll t)
(add-hook 'html-mode-hook
(lambda()
(setq sgml-basic-offset 4)
(setq indent-tabs-mode t)))
#+END_SRC
** Files types attribution
#+BEGIN_SRC emacs-lisp
(add-to-list 'auto-mode-alist '("xinitrc$" . shell-script-mode))
(add-to-list 'auto-mode-alist '("env$" . shell-script-mode))
(add-to-list 'auto-mode-alist '("lfrc$" . vimrc-mode))
(add-to-list 'auto-mode-alist '("muttrc$" . mutt-mode))
(add-to-list 'auto-mode-alist '("dunstrc$" . conf-mode))
(add-to-list 'auto-mode-alist '("loader.conf$" . conf-mode))
(add-to-list 'auto-mode-alist '("mailcap$" . conf-mode))
#+END_SRC
** Core packages
*** Smartparens
#+BEGIN_SRC emacs-lisp
(require 'smartparens-config)
(smartparens-global-mode)
#+END_SRC
*** Evil mode
#+BEGIN_SRC emacs-lisp
(require 'evil)
(require 'evil-collection)
(require 'evil-leader)
(require 'evil-search-highlight-persist)
(require 'org-evil)
(evil-mode t)
(evil-collection-init 'ibuffer)
(evil-collection-init 'magit)
(evil-collection-init 'flymake)
(setq evil-emacs-state-cursor '("#b16286" box))
(setq evil-normal-state-cursor '("#d79921" box))
(setq evil-visual-state-cursor '("#b06597" box))
(setq evil-insert-state-cursor '("#d79921" bar))
(setq evil-replace-state-cursor '("#cc241d" hbar))
(setq evil-operator-state-cursor '("#d79921" hbar))
(evil-define-key 'insert global-map (kbd "C-o") 'delete-other-windows)
(evil-define-key 'insert global-map (kbd "C-k") 'windmove-up)
(evil-define-key 'insert global-map (kbd "C-j") 'windmove-down)
(evil-define-key 'insert global-map (kbd "C-h") 'windmove-left)
(evil-define-key 'insert global-map (kbd "C-l") 'windmove-right)
(evil-define-key 'normal global-map (kbd "C-o") 'delete-other-windows)
(evil-define-key 'normal global-map (kbd "C-k") 'windmove-up)
(evil-define-key 'normal global-map (kbd "C-j") 'windmove-down)
(evil-define-key 'normal global-map (kbd "C-h") 'windmove-left)
(evil-define-key 'normal global-map (kbd "C-l") 'windmove-right)
(global-evil-leader-mode)
(evil-leader/set-leader "\\")
(setq evil-leader/in-all-states 1)
(require 'evil-search-highlight-persist)
(global-evil-search-highlight-persist 1)
(evil-leader/set-key "SPC" 'evil-search-highlight-persist-remove-all)
(global-undo-tree-mode)
(evil-set-undo-system 'undo-tree)
#+END_SRC
*** Evil nerd commenter
#+BEGIN_SRC emacs-lisp
(require 'evil-nerd-commenter)
(evilnc-default-hotkeys)
#+END_SRC
*** Evil surround
#+BEGIN_SRC emacs-lisp
(require 'evil-surround)
(global-evil-surround-mode 1)
#+END_SRC
*** Evil multiple-cursor
#+BEGIN_SRC emacs-lisp
(require 'evil-mc)
(global-evil-mc-mode 1)
#+END_SRC
*** Evil vimish Fold
#+BEGIN_SRC emacs-lisp
(require 'vimish-fold)
(require 'evil-vimish-fold)
(add-hook 'prog-mode-hook 'evil-vimish-fold-mode)
(add-hook 'text-mode-hook 'evil-vimish-fold-mode)
#+END_SRC
*** Evil numbers
#+BEGIN_SRC emacs-lisp
(require 'evil-numbers)
(define-key evil-normal-state-map (kbd "C-c C-a") 'evil-numbers/inc-at-pt)
(define-key evil-normal-state-map (kbd "C-c C-x") 'evil-numbers/dec-at-pt)
#+END_SRC
*** Evil quickscope
#+BEGIN_SRC emacs-lisp
(require 'evil-quickscope)
(global-evil-quickscope-mode 1)
#+END_SRC
*** Dashboard
#+BEGIN_SRC emacs-lisp
(require 'dashboard)
(dashboard-setup-startup-hook)
(setq dashboard-banner-logo-title (concat "Welcome back to Emacs " emacs-version ", partner!")
dashboard-startup-banner "~/pics/profile/caco.png"
;; dashboard-startup-banner 'official
dashboard-set-init-info nil
dashboard-set-footer nil
dashboard-center-content t
dashboard-show-shortcuts nil
dashboard-set-heading-icons t
dashboard-set-file-icons nil
dashboard-set-navigator t
show-week-agenda-p t)
(setq dashboard-items '((projects . 10)
(recents . 10)
(bookmarks . 10)))
(add-to-list 'evil-emacs-state-modes 'dashboard-mode)
#+END_SRC
*** w3m
#+BEGIN_SRC emacs-lisp
;; (require 'w3m-load)
;; (setq w3m-home-page "https://start.duckduckgo.com/")
;; (setq w3m-default-display-inline-images t)
;; (define-key w3m-mode-map "w" 'right-word)
;; (define-key w3m-mode-map "b" 'left-word)
;; (define-key w3m-mode-map "<" 'scroll-left)
;; (define-key w3m-mode-map ">" 'scroll-right)
;; (define-key w3m-mode-map (kbd "C-d") 'evil-scroll-page-down)
;; (define-key w3m-mode-map (kbd "C-u") 'evil-scroll-page-up)
;; (define-key w3m-mode-map "H" 'w3m-view-previous-page)
;; (define-key w3m-mode-map "L" 'w3m-view-next-page)
;; (define-key w3m-mode-map "o" 'w3m-goto-url)
;; (define-key w3m-mode-map "O" 'w3m-goto-url-new-session)
;; (define-key w3m-mode-map "v" 'w3m-view-image)
;; (define-key w3m-mode-map "$" 'w3m-end-of-line)
;; (define-key w3m-mode-map "^" 'w3m-beginning-of-line)
;; (define-key w3m-mode-map (kbd "M-j") 'w3m-next-buffer)
;; (define-key w3m-mode-map (kbd "M-k") 'w3m-previous-buffer)
;; (define-key w3m-mode-map "t" 'w3m-copy-buffer)
#+END_SRC
*** Helm, projectile
#+BEGIN_SRC emacs-lisp
(require 'helm-config)
(require 'helm-misc)
(require 'helm-projectile)
(require 'helm-locate)
(require 'helm-lsp)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-x C-f") #'helm-find-files)
(global-set-key (kbd "M-p") #'helm-projectile-switch-project)
(global-set-key (kbd "C-x C-b") #'helm-mini)
(global-set-key (kbd "C-x p") #'helm-projectile)
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action)
(define-key helm-map (kbd "C-z") 'helm-select-action)
(define-key helm-map (kbd "C-j") 'helm-next-line)
(define-key helm-map (kbd "C-k") 'helm-previous-line)
(define-key helm-find-files-map (kbd "C-h") 'helm-find-files-up-one-level)
(define-key helm-find-files-map (kbd "C-l") 'helm-execute-persistent-action)
(setq helm-quick-update t
helm-bookmark-show-location t
helm-buffers-fuzzy-matching t
helm-make-executable "/usr/local/bin/gmake"
helm-make-nproc 5
helm-split-window-in-side-p t)
(defun helm-my-buffers ()
(interactive)
(let ((helm-ff-transformer-show-only-basename nil))
(helm-other-buffer '(helm-c-source-buffers-list
helm-c-source-elscreen
helm-c-source-projectile-files-list
helm-c-source-ctags
helm-c-source-recentf
helm-c-source-locate)
"*helm-my-buffers*")))
(helm-mode 1)
(projectile-mode +1)
#+END_SRC
*** DOOM Modeline
#+BEGIN_SRC emacs-lisp
(setq display-time-string-forms
'((propertize (concat " " 24-hours ":" minutes " "))))
(require 'doom-modeline)
(doom-modeline-mode 1)
(setq doom-modeline-height 30)
(setq doom-modeline-project-detection 'projectile)
(setq doom-modeline-buffer-file-name-style 'truncate-upto-project)
(setq doom-modeline-icon (display-graphic-p))
(setq doom-modeline-major-mode-icon t)
(setq doom-modeline-major-mode-color-icon t)
(setq doom-modeline-buffer-state-icon t)
(setq doom-modeline-buffer-modification-icon t)
(setq doom-modeline-unicode-fallback t)
(setq doom-modeline-enable-word-count nil)
(setq doom-modeline-buffer-encoding nil)
(setq doom-modeline-indent-info nil)
(setq doom-modeline-checker-simple-format t)
(setq doom-modeline-number-limit 99)
(setq doom-modeline-vcs-max-length 12)
(setq doom-modeline-persp-name t)
(setq doom-modeline-lsp t)
(setq doom-modeline-github nil)
(setq doom-modeline-github-interval (* 30 60))
(setq doom-modeline-modal-icon t)
(setq doom-modeline-gnus nil)
(setq doom-modeline-irc t)
(setq doom-modeline-irc-stylize 'identity)
(setq doom-modeline-env-version t)
(setq doom-modeline-env-python-executable "python-shell-interpreter")
(setq doom-modeline-env-ruby-executable "ruby")
(setq doom-modeline-env-perl-executable "perl")
(setq doom-modeline-env-go-executable "go")
(setq doom-modeline-env-elixir-executable "iex")
(setq doom-modeline-env-rust-executable "rustc")
(setq doom-modeline-env-load-string "...")
(setq doom-modeline-before-update-env-hook nil)
(setq doom-modeline-after-update-env-hook nil)
(display-battery-mode)
(column-number-mode)
(display-time)
(doom-themes-neotree-config)
#+END_SRC
*** Colors and rainbows
#+BEGIN_SRC emacs-lisp
;; (require 'color-identifiers-mode)
;; (global-color-identifiers-mode)
(require 'rainbow-delimiters)
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
#+END_SRC
*** C default style
#+BEGIN_SRC emacs-lisp
(c-add-style "openbsd"
'("bsd"
(c-backspace-function . delete-backward-char)
(c-syntactic-indentation-in-macros . nil)
(c-tab-always-indent . nil)
(c-hanging-braces-alist
(block-close . c-snug-do-while))
(c-offsets-alist
(arglist-cont-nonempty . *)
(statement-cont . *))
(indent-tabs-mode . t)))
(setq c-default-style "openbsd")
#+END_SRC
*** Magit
#+BEGIN_SRC emacs-lisp
(require 'magit)
(defun my/magit-kill-buffers ()
"Restore window configuration and kill all Magit buffers.
Attribution: URL `https://manuel-uberti.github.io/emacs/2018/02/17/magit-bury-buffer/'"
(interactive)
(let ((buffers (magit-mode-get-buffers)))
(magit-restore-window-configuration)
(mapc #'kill-buffer buffers)))
(bind-key "q" #'my/magit-kill-buffers magit-status-mode-map)
(evil-define-key 'insert magit-status-mode-map (kbd "q") #'my/magit-kill-buffers)
(evil-define-key 'normal magit-status-mode-map (kbd "q") #'my/magit-kill-buffers)
#+END_SRC
*** Lock windows
#+BEGIN_SRC emacs-lisp
(defun my/toggle-window-dedicated ()
"Control whether or not Emacs is allowed to display another
buffer in current window."
(interactive)
(message
(if (let (window (get-buffer-window (current-buffer)))
(set-window-dedicated-p window (not (window-dedicated-p window))))
"%s: locked"
"%s is up for grabs")
(current-buffer)))
(global-set-key (kbd "C-c t") 'my/toggle-window-dedicated)
#+END_SRC
*** Tabs and stuff
#+BEGIN_SRC emacs-lisp
(defun minibuffer-keyboard-quit ()
"Abort recursive edit.
In Delete Selection mode, if the mark is active, just deactivate it;
then it takes a second \\[keyboard-quit] to abort the minibuffer."
(interactive)
(if (and delete-selection-mode transient-mark-mode mark-active)
(setq deactivate-mark t)
(when (get-buffer "*Completions*") (delete-windows-on "*Completions*"))
(abort-recursive-edit)))
(define-key evil-normal-state-map [escape] 'keyboard-quit)
(define-key evil-visual-state-map [escape] 'keyboard-quit)
(define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit)
(defun my/insert-tab-char ()
(interactive)
(insert "\t"))
(define-key evil-insert-state-map [tab] 'my/insert-tab-char)
(setq my/tab-stop 4)
(setq-default indent-tabs-mode t)
(setq tab-always-indent 'complete)
(setq-default tab-width my/tab-stop)
(setq tab-width my/tab-stop)
(setq-default c-basic-offset my/tab-stop)
(setq-default cperl-indent-level my/tab-stop)
#+END_SRC
*** ibuffer
#+BEGIN_SRC emacs-lisp
(require 'ibuffer)
(require 'ibuffer-vc)
(require 'ibuffer-projectile)
(add-hook 'ibuffer-hook
(lambda ()
(ibuffer-projectile-set-filter-groups)
(unless (eq ibuffer-sorting-mode 'alphabetic)
(ibuffer-do-sort-by-alphabetic))))
#+END_SRC
*** all the icons
#+BEGIN_SRC emacs-lisp
(require 'font-lock+)
(require 'all-the-icons)
(require 'all-the-icons-dired)
(require 'all-the-icons-ibuffer)
(load "all-the-icons-dired.el")
(add-hook 'dired-mode-hook 'all-the-icons-dired-mode)
(all-the-icons-ibuffer-mode 1)
#+END_SRC
*** which-key
#+BEGIN_SRC emacs-lisp
(require 'which-key)
(which-key-mode)
#+END_SRC
*** shell-pop
#+BEGIN_SRC emacs-lisp
(require 'shell-pop)
(setq my/shell-pop-shell-type
(quote
("ansi-term" "*ansi-term*"
(lambda nil
(ansi-term shell-pop-term-shell)))))
(setq shell-pop-term-shell "/usr/local/bin/zsh")
(add-to-list 'evil-emacs-state-modes 'term-mode)
#+END_SRC
*** org-superstar
#+BEGIN_SRC emacs-lisp
(require 'org-superstar)
(add-hook 'org-mode-hook (lambda () (org-superstar-mode 1)))
#+END_SRC
*** toc-org
#+BEGIN_SRC emacs-lisp
(require 'toc-org)
(add-hook 'org-mode-hook 'toc-org-mode)
;; enable in markdown, too
(add-hook 'markdown-mode-hook 'toc-org-mode)
(define-key markdown-mode-map (kbd "\C-c\C-o") 'toc-org-markdown-follow-thing-at-point)
#+END_SRC
*** lsp, ccls, clangd, company, yasnippet
#+BEGIN_SRC emacs-lisp
(require 'lsp-mode)
(require 'lsp-ui)
;; (require 'ccls)
(require 'company)
(require 'company-box)
(require 'yasnippet)
(require 'yasnippet-snippets)
(require 'yasnippet-classic-snippets)
(yas-reload-all)
(yas-global-mode)
(add-hook 'c-mode-hook 'lsp)
(add-hook 'c++-mode-hook 'lsp)
(add-hook 'perl-mode-hook 'lsp)
(add-hook 'go-mode-hook 'lsp)
(add-hook 'lsp-mode-hook 'lsp-enable-which-key-integration)
(setq lsp-ui-doc-header t
lsp-ui-doc-position 'top
lsp-ui-sideline-enable t)
(setq lsp-enable-indentation nil
lsp-completion-enable t
lsp-headerline-breadcrumb-enable nil)
(setq gc-cons-threshold (* 100 1024 1024)
read-process-output-max (* 1024 1024)
company-idle-delay 0.0
company-minimum-prefix-length 1
lsp-idle-delay 0.1)
(with-eval-after-load 'lsp-mode
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration)
(yas-global-mode))
(add-hook 'after-init-hook 'global-company-mode)
(global-company-mode)
(define-key company-active-map (kbd "C-j") 'company-select-next)
(define-key company-active-map (kbd "C-k") 'company-select-previous)
(define-key company-search-map (kbd "C-j") 'company-select-next)
(define-key company-search-map (kbd "C-k") 'company-select-previous)
(define-key company-search-map (kbd "C-t") 'company-search-toggle-filtering)
(define-key company-search-map (kbd "C-i") 'company-complete-common)
;; (push 'company-lsp company-backends)
;; (setq company-transformers nil company-lsp-async t company-lsp-cache-candidates nil)
(add-hook 'company-mode-hook 'company-box-mode)
(require 'lsp-clangd)
(setq lsp-clangd-executable "/usr/local/llvm13/bin/clangd")
;; (setq ccls-executable "ccls")
;; (defun ccls/callee () (interactive) (lsp-ui-peek-find-custom "$ccls/call" '(:callee t)))
;; (defun ccls/caller () (interactive) (lsp-ui-peek-find-custom "$ccls/call"))
;; (defun ccls/vars (kind) (lsp-ui-peek-find-custom "$ccls/vars" `(:kind ,kind)))
;; (defun ccls/base (levels) (lsp-ui-peek-find-custom "$ccls/inheritance" `(:levels ,levels)))
;; (defun ccls/derived (levels) (lsp-ui-peek-find-custom "$ccls/inheritance" `(:levels ,levels :derived t)))
;; (defun ccls/member (kind) (interactive) (lsp-ui-peek-find-custom "$ccls/member" `(:kind ,kind)))
;; ;; References w/ Role::Role
;; (defun ccls/references-read () (interactive)
;; (lsp-ui-peek-find-custom "textDocument/references"
;; (plist-put (lsp--text-document-position-params) :role 8)))
;; ;; References w/ Role::Write
;; (defun ccls/references-write ()
;; (interactive)
;; (lsp-ui-peek-find-custom "textDocument/references"
;; (plist-put (lsp--text-document-position-params) :role 16)))
;; ;; References w/ Role::Dynamic bit (macro expansions)
;; (defun ccls/references-macro () (interactive)
;; (lsp-ui-peek-find-custom "textDocument/references"
;; (plist-put (lsp--text-document-position-params) :role 64)))
;; ;; References w/o Role::Call bit (e.g. where functions are taken addresses)
;; (defun ccls/references-not-call () (interactive)
;; (lsp-ui-peek-find-custom "textDocument/references"
;; (plist-put (lsp--text-document-position-params) :excludeRole 32)))
;; ;; ccls/vars ccls/base ccls/derived ccls/members have a parameter while others are interactive.
;; ;; (ccls/base 1) direct bases
;; ;; (ccls/derived 1) direct derived
;; ;; (ccls/member 2) => 2 (Type) => nested classes / types in a namespace
;; ;; (ccls/member 3) => 3 (Func) => member functions / functions in a namespace
;; ;; (ccls/member 0) => member variables / variables in a namespace
;; ;; (ccls/vars 1) => field
;; ;; (ccls/vars 2) => local variable
;; ;; (ccls/vars 3) => field or local variable. 3 = 1 | 2
;; ;; (ccls/vars 4) => parameter
;; ;; References whose filenames are under this project
;; (setq ccls-sem-highlight-method 'overlay)
;; (ccls-use-default-rainbow-sem-highlight)
#+END_SRC
*** diff-hl
#+BEGIN_SRC emacs-lisp
(require 'diff-hl)
(global-diff-hl-mode)
(add-hook 'magit-pre-refresh-hook 'diff-hl-magit-pre-refresh)
(add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)
#+END_SRC
*** Saveplace, savehist
#+BEGIN_SRC emacs-lisp
(require 'saveplace)
(add-hook 'after-init-hook 'save-place-mode)
(require 'savehist)
(setq history-length 1000
savehist-additional-variables '(search-ring
regexp-search-ring
extended-command-history)
savehist-autosave-interval 60)
(add-hook 'after-init-hook 'savehist-mode)
#+END_SRC
*** Eyebrowse
#+BEGIN_SRC emacs-lisp
(require 'eyebrowse)
(define-key eyebrowse-mode-map (kbd "M-1") 'eyebrowse-switch-to-window-config-1)
(define-key eyebrowse-mode-map (kbd "M-2") 'eyebrowse-switch-to-window-config-2)
(define-key eyebrowse-mode-map (kbd "M-3") 'eyebrowse-switch-to-window-config-3)
(define-key eyebrowse-mode-map (kbd "M-4") 'eyebrowse-switch-to-window-config-4)
(define-key eyebrowse-mode-map (kbd "M-5") 'eyebrowse-switch-to-window-config-5)
(define-key eyebrowse-mode-map (kbd "M-6") 'eyebrowse-switch-to-window-config-6)
(define-key eyebrowse-mode-map (kbd "M-7") 'eyebrowse-switch-to-window-config-7)
(define-key eyebrowse-mode-map (kbd "M-8") 'eyebrowse-switch-to-window-config-8)
(eyebrowse-mode t)
(setq eyebrowse-new-workspace t)
#+END_SRC
*** web-mode
#+BEGIN_SRC emacs-lisp
(defun my-setup-php ()
;; enable web mode
(web-mode)
;; make these variables local
(make-local-variable 'web-mode-code-indent-offset)
(make-local-variable 'web-mode-markup-indent-offset)
(make-local-variable 'web-mode-css-indent-offset)
;; set indentation, can set different indentation level for different code type
(setq web-mode-code-indent-offset 4)
(setq web-mode-css-indent-offset 4)
(setq web-mode-markup-indent-offset 4))
(add-to-list 'auto-mode-alist '("\\.php$" . my-setup-php))
#+END_SRC
*** undo-tree
#+BEGIN_SRC emacs-lisp
(require 'undo-tree)
(setq undo-tree-auto-save-history nil)
#+END_SRC
*** treemacs
#+BEGIN_SRC emacs-lisp
(require 'treemacs)
(require 'treemacs-evil)
(require 'treemacs-magit)
(require 'treemacs-projectile)
(require 'treemacs-all-the-icons)
(require 'lsp-treemacs)
(progn
(setq treemacs-collapse-dirs (if treemacs-python-executable 3 0)
treemacs-deferred-git-apply-delay 0.5
treemacs-directory-name-transformer #'identity
treemacs-display-in-side-window t
treemacs-eldoc-display 'simple
treemacs-file-event-delay 5000
treemacs-file-extension-regex treemacs-last-period-regex-value
treemacs-file-follow-delay 0.2
treemacs-file-name-transformer #'identity
treemacs-follow-after-init t
treemacs-expand-after-init t
treemacs-find-workspace-method 'find-for-file-or-pick-first
treemacs-git-command-pipe ""
treemacs-goto-tag-strategy 'refetch-index
treemacs-header-scroll-indicators '(nil . "^^^^^^")
treemacs-indentation 2
treemacs-indentation-string " "
treemacs-is-never-other-window nil
treemacs-max-git-entries 5000
treemacs-missing-project-action 'ask
treemacs-move-forward-on-expand nil
treemacs-no-png-images nil
treemacs-no-delete-other-windows t
treemacs-project-follow-cleanup nil
treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory)
treemacs-position 'left
treemacs-read-string-input 'from-child-frame
treemacs-recenter-distance 0.1
treemacs-recenter-after-file-follow nil
treemacs-recenter-after-tag-follow nil
treemacs-recenter-after-project-jump 'always
treemacs-recenter-after-project-expand 'on-distance
treemacs-litter-directories '("/node_modules" "/.venv" "/.cask")
treemacs-show-cursor nil
treemacs-show-hidden-files t
treemacs-silent-filewatch nil
treemacs-silent-refresh nil
treemacs-sorting 'alphabetic-asc
treemacs-select-when-already-in-treemacs 'move-back
treemacs-space-between-root-nodes t
treemacs-tag-follow-cleanup t
treemacs-tag-follow-delay 1.5
treemacs-text-scale nil
treemacs-user-mode-line-format nil
treemacs-user-header-line-format nil
treemacs-wide-toggle-width 70
treemacs-width 35
treemacs-width-increment 1
treemacs-width-is-initially-locked t
treemacs-workspace-switch-cleanup nil)
;; The default width and height of the icons is 22 pixels. If you are
;; using a Hi-DPI display, uncomment this to double the icon size.
;;(treemacs-resize-icons 44)
(treemacs-follow-mode t)
(treemacs-filewatch-mode t)
(treemacs-fringe-indicator-mode 'always)
(when treemacs-python-executable
(treemacs-git-commit-diff-mode t))
(pcase (cons (not (null (executable-find "git")))
(not (null treemacs-python-executable)))
(`(t . t)
(treemacs-git-mode 'deferred))
(`(t . _)
(treemacs-git-mode 'simple)))
(treemacs-hide-gitignored-files-mode nil))
#+END_SRC
** Compilation
*** Close window after errorless compilation
#+BEGIN_SRC emacs-lisp
(defun bury-compile-buffer-if-successful (buffer string)
"Bury a compilation buffer if succeeded without warnings "
(when (and
(buffer-live-p buffer)
(string-match "compilation" (buffer-name buffer))
(string-match "finished" string)
(not
(with-current-buffer buffer
(goto-char (point-min))
(search-forward "warning" nil t))))
(run-with-timer 0.5 nil
(lambda (buf)
(bury-buffer buf)
(switch-to-prev-buffer (get-buffer-window buf) 'kill)
(delete-window))
buffer)))
(add-hook 'compilation-finish-functions 'bury-compile-buffer-if-successful)
#+END_SRC
** Other key bindings
#+BEGIN_SRC emacs-lisp
(defun my/nothing ())
(global-set-key [f1] 'shell-pop)
(global-set-key [f2] 'treemacs)
(global-set-key [f3] 'flymake-show-diagnostics-buffer)
(global-set-key [f4] 'helm-make-projectile)
(global-set-key [f5] 'undo-tree-visualize)
(global-set-key (kbd "C-x d") 'dired)
(global-set-key (kbd "C-x b") 'ibuffer)
(global-set-key (kbd "M-9") 'shell-command)
(global-set-key (kbd "M-0") 'async-shell-command)
(global-set-key (kbd "M-j") 'next-buffer)
(global-set-key (kbd "M-k") 'previous-buffer)
(shell-pop--set-shell-type 'my/shell-pop-shell-type my/shell-pop-shell-type)
#+END_SRC
|