-
Notifications
You must be signed in to change notification settings - Fork 0
/
emacs
2344 lines (2086 loc) · 84.5 KB
/
emacs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;; -*- lexical-binding: t -*-
;;; package --- Summary
;; my emacs config
;;; Commentary:
;; I use evil-mode everywhere, and the config is based on use-package and general
;;; Code:
(setq lexical-binding t)
;; for native-comp branch
(when (fboundp 'native-compile-async)
(if (y-or-n-p "async compile?")
(setq comp-async-jobs-number 4 ;; not using all cores
comp-deferred-compilation t
;; comp-deferred-compilation-black-list
;; '()
)
(setq comp-deferred-compilation nil)))
;;; speed up startup using Ambrevar's suggestions: (reset later by loading gcmh)
(setq gc-cons-threshold (* 64 1024 1024)
gc-cons-percentage 0.6)
;;; Temporarily disable the file name handler.
(setq default-file-name-handler-alist file-name-handler-alist)
(setq file-name-handler-alist nil)
(defun ambrevar-reset-file-name-handler-alist ()
(setq file-name-handler-alist
(append default-file-name-handler-alist
file-name-handler-alist))
(cl-delete-duplicates file-name-handler-alist :test 'equal))
(add-hook 'after-init-hook #'ambrevar-reset-file-name-handler-alist)
;;;
(setq user-emacs-directory "~/.config/emacs/")
(setq custom-file (concat user-emacs-directory "custom.el"))
(load custom-file t)
;; todo change for 27
;; (setq package-enable-at-startup nil) ; tells emacs not to load any packages before starting up
;; the following lines tell emacs where on the internet to look up
;; for new packages.
(setq package-archives '(("org" . "http://orgmode.org/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")))
;; todo change for 27
;; (package-initialize)
;; Bootstrap quelpa
(unless (package-installed-p 'quelpa)
(with-temp-buffer
(url-insert-file-contents "https://github.com/quelpa/quelpa/raw/master/quelpa.el")
(eval-buffer)
(quelpa-self-upgrade)))
(quelpa
'(quelpa-use-package
:fetcher git
:url "https://github.com/quelpa/quelpa-use-package.git"))
(require 'quelpa-use-package)
;; not needed if using quelpa
;; ;; Bootstrap `use-package'
;; (unless (package-installed-p 'use-package) ; unless it is already installed
;; (package-refresh-contents) ; updage packages archive
;; (package-install 'use-package)) ; and install the most recent version of use-package
;; (require 'use-package)
(setq use-package-always-ensure t)
;; defaults suggested by blog and extended by me
(setq frame-inhibit-implied-resize t) ; reddit suggestion by hlissner
;; (setq initial-major-mode 'fundamental-mode) ; s.a.
(setq delete-old-versions -1) ; delete excess backup versions silently
(setq version-control t) ; use version control
(setq vc-make-backup-files t) ; make backups file even when in version controlled dir
(setq backup-directory-alist `(("." . ,(concat user-emacs-directory "backups")))) ; which directory to put backups file
(setq vc-follow-symlinks t) ; don't ask for confirmation when opening symlinked file
(setq auto-save-file-name-transforms `((".*" ,(concat user-emacs-directory "auto-save-list/") t))) ;transform backups file name
(setq inhibit-startup-screen t) ; inhibit startup screen
(setq ring-bell-function 'ignore) ; silent bell when you make a mistake
(set-language-environment "UTF-8")
(setq sentence-end-double-space nil) ; sentence SHOULD end with only a point.
;; (setq default-fill-column 80) ; toggle wrapping text at the 80th character
;; (setq default-major-mode 'text-mode)
(blink-cursor-mode -1)
(setq revert-without-query '("*pdf")) ; automatically revert pdf-files
(add-to-list 'default-frame-alist
'(font . "Source Code Pro"))
(add-hook 'focus-out-hook (lambda () (when buffer-file-name (save-buffer))))
(recentf-mode 1)
(setq delete-by-moving-to-trash t)
(setq-default indent-tabs-mode nil)
(display-time-mode)
(setq display-time-24hr-format t
display-time-default-load-average nil)
(setq
initial-scratch-message
"(print \"Welcome\") \n \n(async-shell-command \"yay --sudoloop -Syu\") \n \n(shell-command-to-string \"acpi -b\") \n")
; print a default message in the empty scratch buffer opened at startup
(defalias 'yes-or-no-p 'y-or-n-p) ;reduce typing effort
(customize-set-variable 'compilation-scroll-output t)
(electric-pair-mode 1) ;close brackets
(electric-indent-mode)
(show-paren-mode 1)
(push '(?< . ?>) electric-pair-pairs) ;add angle brackets to electric pairs (autoclose brackets)
;; howard abrams yt video
(defadvice transpose-words
(before my/transpose-words)
(when (looking-at "$")
(backward-word 1)))
(ad-activate 'transpose-words)
;; useful functions
(defun system-name= (&rest names)
(cl-some
(lambda (name)
(string-equal name (system-name)))
names))
(defun shutdown ()
(interactive)
(cond
((system-name= "klingenberg-laptop") (async-shell-command "sudo shutdown"))
(t (shell-command "shutdown now"))))
(defun reboot ()
(interactive)
(async-shell-command "sudo reboot now"))
(defvar browser
(cond
;; ((system-name= "klingenberg-tablet") "next")
((system-name= "klingenberg-laptop") "epiphany")
(t "firefox")))
(defun find-config-file ()
"Open Emacs configuration file."
(interactive)
(find-file (concat user-emacs-directory "init.el")))
(defun load-config-file ()
"Load Emacs configuration file."
(interactive)
(load-file (concat user-emacs-directory "init.el")))
(defun find-dotfile-dir ()
"Open dotfile directory."
(interactive)
(find-file "~/.dotfiles/dotfiles/"))
(defun find-todo ()
"Open dotfile directory."
(interactive)
(find-file "~/Documents/TODO.org")
(calendar))
;; Taken from StackOverflow
(defun my/show-file-name ()
"Show the full path file name in the minibuffer."
(interactive)
(kill-new (buffer-file-name))
(message (buffer-file-name)))
(defun my/get-rid-of-mouse ()
"Move the mouse to the bottom right corner of the screen"
(interactive)
(shell-command "xdotool mousemove 100000 100000")) ; extremely high numbers to ensure the cursor goes to the bottom right regardless of display size
(defun my--convert-to-pdf (filename)
(shell-command (concat "unoconv " filename)))
(defun my/dired-convert-to-pdf ()
(interactive)
(mapc #'my--convert-to-pdf (dired-get-marked-files))
(ranger-refresh))
(defun my/brightness+ ()
(interactive)
(shell-command "xbacklight -inc 10"))
(defun my/brightness- ()
(interactive)
(shell-command "xbacklight -dec 10"))
(defun my/fix-touchscreen ()
(when (system-name= "klingenberg-tablet")
(shell-command "xinput --map-to-output $(xinput list --id-only \"ELAN Touchscreen\") eDP1")))
(defun my/open-url (url)
(start-process-shell-command
"" nil (concat browser
url)))
(defun my/close-buffer ()
(interactive)
(unless (equalp (buffer-name) "*scratch*")
(kill-this-buffer))
(when (< 1 (length (window-list)))
(evil-window-delete)))
(defun my/add-to-path (path)
"Add path to PATH."
(setenv "PATH" (concat
path
":"
(getenv "PATH")))
(add-to-list 'exec-path path))
(defun my/remove-hook-interactively ()
"Remove hook interactively."
(interactive)
(let* ((hook (intern (completing-read "hook: "
obarray
(lambda (symbol) (string-suffix-p "hook" (format "%s" symbol))))))
(fun (intern (completing-read "fun: " (eval hook)))))
(remove-hook hook fun)))
;; (defmacro ! (&rest args)
;; "convenient way to execute shell commands from scratch buffer"
;; `(shell-command (mapcar #'write-to-string ,args)))
(defun fdy-mount (source target)
"Mount a directory from fdy windows remote server."
(async-shell-command (concat
"sudo /usr/bin/mount //dc1/"
source
" "
target
" -t cifs -o username=klingenberg,noexec,uid=klingenberg")))
(defun qmount (location)
"Shortcuts for mounting frequent locations,"
(interactive)
(apply #'fdy-mount
(cond ((string= location "lectures") '("misc/fdy-lectures.git" "~/git/mnt/fdy-lectures.git"))
((string= location "klausuren") '("lehre/TM1/Klausuren.git" "~/git/mnt/Klausuren.git"))
((string= location "bosss") '("bosss/users/klingenberg/root.git" "~/git/mnt/bosss.git"))
((string= location "publications") '("misc/fdy-publications.git" "~/git/mnt/fdy-publications.git"))
((string= location "misc") '("misc" "~/misc"))
((string= location "scratch") '("scratch" "~/scratch"))
((string= location "backup") '("backup" "~/backup"))
((string= location "lehre") '("lehre" "~/lehre")))))
(defun ambrevar-toggle-window-split ()
"Switch between vertical and horizontal split.
It only works for frames with exactly two windows.
\(Credits go to ambrevar and his awesome blog\)"
(interactive)
(if (= (count-windows) 2)
(let* ((this-win-buffer (window-buffer))
(next-win-buffer (window-buffer (next-window)))
(this-win-edges (window-edges (selected-window)))
(next-win-edges (window-edges (next-window)))
(this-win-2nd (not (and (<= (car this-win-edges)
(car next-win-edges))
(<= (cadr this-win-edges)
(cadr next-win-edges)))))
(splitter
(if (= (car this-win-edges)
(car (window-edges (next-window))))
'split-window-horizontally
'split-window-vertically)))
(delete-other-windows)
(let ((first-win (selected-window)))
(funcall splitter)
(if this-win-2nd (other-window 1))
(set-window-buffer (selected-window) this-win-buffer)
(set-window-buffer (next-window) next-win-buffer)
(select-window first-win)
(if this-win-2nd (other-window 1))))))
(defun my/indent-buffer ()
"Indent the entire buffer using evil-indent."
(interactive)
(save-excursion
(evil-indent (point-min) (point-max))))
;; Credit goes to https://stackoverflow.com/questions/18102004/emacs-evil-mode-how-to-create-a-new-text-object-to-select-words-with-any-non-sp
(defmacro define-and-bind-text-object (key start-regex end-regex)
(let ((inner-name (make-symbol "inner-name"))
(outer-name (make-symbol "outer-name")))
`(progn
(evil-define-text-object ,inner-name (count &optional beg end type)
(evil-select-paren ,start-regex ,end-regex beg end type count nil))
(evil-define-text-object ,outer-name (count &optional beg end type)
(evil-select-paren ,start-regex ,end-regex beg end type count t))
(define-key evil-inner-text-objects-map ,key ',inner-name)
(define-key evil-outer-text-objects-map ,key ',outer-name))))
;; packages with configuration
(use-package gcmh
:config
(gcmh-mode 1))
(use-package general
:init
(setq general-override-states '(insert
emacs
hybrid
normal
visual
motion
operator
replace))
:config
(general-evil-setup t)
(general-auto-unbind-keys)
(general-create-definer my/leader-def
:keymaps 'override
:prefix "SPC"
:global-prefix "s-SPC"
:states '(motion normal emacs))
(general-create-definer my/local-leader-def
:keymaps 'override
:prefix "-"
:states '(motion normal))
(general-create-definer my/local-insert-leader-def
:keymaps 'override
:prefix "C-c"
:states '(motion normal emacs))
(general-nmap "Y" "y$")
(general-define-key "ESC" 'keyboard-quit :which-key "abort command")
(general-define-key "TAB" 'company-complete :which-key "trigger completion")
(general-define-key
;; :keymaps 'override
:states 'normal
"gb" '(pop-tag-mark :which-key "go back"))
(general-define-key
:keymaps 'override
:states 'insert
"M-t" '(transpose-words :which-key "transpose-words"))
;; many spacemacs bindings go here
(my/leader-def
"SPC" '(helm-M-x :which-key "M-x")
"a" '(:ignore t :which-key "applications")
"ad" '(deer :which-key "call deer")
"ab" '(eww :which-key "open browser")
"aB" '(helm-eww-bookmarks :which-key "open browser bookmarks")
"am" '(gnus :which-key "open unread mail")
"ap" '(helm-system-packages :which-key "package management")
"ao" '(sx-search :which-key "search stackoverflow")
"ar" '(md4rd :which-key "reddit")
"ag" '(go-play :which-key "play the game of go")
"ae" '(elfeed :which-key "open elfeed")
"at" '(shell :which-key "open shell")
"aS" '(eshell :which-key "open existing eshell")
"as" '((lambda () (interactive) (eshell 'N)) :which-key "open new eshell")
"g" '(:ignore t :which-key "git")
;; "/" '(helm-occur t :which-key "helm-occur")
"cc" '(org-capture :which-key "org capture")
"f" '(:ignore t :which-key "file")
"fs" '(save-buffer :which-key "save file")
"fS" '(write-file :which-key "save file as")
"ff" '(helm-find-files :which-key "find file")
"fed" '(find-config-file :which-key "find config file")
"fer" '(load-config-file :which-key "load config file")
"feD" '(find-dotfile-dir :which-key "find dotfile directory")
"ft" '(find-todo :which-key "find todo file")
"fz" '((lambda () (interactive) (switch-to-buffer "*scratch*")) :which-key "find scratch buffer")
"fp" '(helm-locate :which-key "helm-locate")
"fg" '(helm-do-grep-ag :which-key "helm-ag")
"b" '(:ignore t :which-key "buffer")
"bb" '(helm-mini :which-key "switch buffer")
"be" '(helm-exwm :which-key "switch to exwm buffer")
"bd" '(kill-this-buffer :which-key "kill buffer")
"m" '(imenu t :which-key "imenu")
"w" '(:ignore t :which-key "window management")
"w TAB" '(evil-switch-to-windows-last-buffer :which-key switch to last buffer)
;; "w2" 'spacemacs/layout-double-columns
;; "w3" 'spacemacs/layout-triple-columns
;; "wb" 'spacemacs/switch-to-minibuffer-window
"wd" 'evil-window-delete
"wH" 'evil-window-move-far-left
"wh" 'evil-window-left
"wJ" 'evil-window-move-very-bottom
"wj" 'evil-window-down
"wK" 'evil-window-move-very-top
"wk" 'evil-window-up
"wL" 'evil-window-move-far-right
"wl" 'evil-window-right
"wm" 'delete-other-windows
"ws" 'split-window-below
"wS" 'split-window-below-and-focus
"w-" 'split-window-below
"wU" 'winner-redo
"wu" 'winner-undo
"wv" 'split-window-right
"wV" 'split-window-right-and-focus
"ww" 'other-window
"w=" 'balance-windows
"r" '(:ignore t :which-key "recent-files")
"rr" 'helm-recentf
"w+" '(ambrevar-toggle-window-split :which-key "toggle window split")
"e" '(:ignore t :which-key "eval elisp")
"ee" 'eval-last-sexp
"ef" 'eval-defun
"ep" 'eval-print-last-sexp
"er" 'eval-expression
"i" '(:ignore :which-key "internet")
"id" '((lambda () (interactive) (my/open-url "https://www.dazn.com")) :which-key "dazn")
"ig" '((lambda () (interactive) (my/open-url "https://www.dragongoserver.net/status.php")) :which-key "dgs")
"iy" '((lambda () (interactive) (my/open-url "https://www.youtube.com/")) :which-key "youtube")
"d" '(my/youtube-dl :which-key "youtube download")
"ss" 'shutdown
"sr" 'reboot
"sl" (lambda () (interactive) (shell-command "/usr/bin/slock"))))
(use-package mini-modeline
:custom
mini-modeline-enhance-visual nil
:config
(setq display-time-default-load-average nil)
(setq display-time-load-average-threshold 10000000)
(setq mini-modeline-r-format
'("%e" mode-line-front-space
;; mode-line-mule-info
;; mode-line-client
;; mode-line-modified
;; mode-line-remote
;; mode-line-frame-identification
mode-line-buffer-identification
vc-mode
" " mode-line-position " "
;; evil-mode-line-tag
;; mode-line-modes
mode-name
" "
mode-line-misc-info
(:eval (format (concat "<%s> "
(unless (null (my/exwm-get-other-workspace)) "[%s] "))
exwm-workspace-current-index
(my/exwm-get-other-workspace)))
" |"
mode-line-end-spaces))
(mini-modeline-mode 1))
(use-package evil
:init
(setq evil-want-keybinding nil)
(setq evil-want-integration t)
:config (evil-mode 1))
(use-package evil-collection
:after (evil helm)
:init
(setq evil-collection-setup-minibuffer t)
:config
(evil-collection-init))
(use-package evil-surround
:config
(global-evil-surround-mode 1)
(evil-define-key 'operator global-map "s" 'evil-surround-edit)
(evil-define-key 'operator global-map "S" 'evil-Surround-edit)
(evil-define-key 'visual global-map "s" 'evil-surround-region)
(evil-define-key 'visual global-map "gS" 'evil-Surround-region))
(use-package evil-snipe
:diminish evil-snipe-local-mode
:config
(setq evil-snipe-scope 'visible)
(evil-snipe-mode 1)
(evil-snipe-override-mode 1)
(evil-define-key 'visual evil-snipe-local-mode-map "z" 'evil-snipe-s)
(evil-define-key 'visual evil-snipe-local-mode-map "Z" 'evil-snipe-S))
(use-package evil-easymotion
:config
(evilem-default-keybindings "z"))
(use-package evil-commentary
:diminish evil-commentary-mode
:init (evil-commentary-mode))
(use-package evil-args
:config
;; bind evil-args text objects
(define-key evil-inner-text-objects-map "a" 'evil-inner-arg)
(define-key evil-outer-text-objects-map "a" 'evil-outer-arg)
(general-define-key
:keymaps 'override
:states 'normal
"gl" 'evil-forward-arg
"gh" 'evil-backward-arg
"gK" 'evil-jump-out-args))
(use-package evil-iedit-state
:config
(general-define-key
:keymaps 'override
:states 'normal
"C-s" 'iedit-mode))
(use-package evil-mc
:diminish evil-mc-mode
:config
(global-evil-mc-mode 1))
;; (use-package evil-owl
;; :diminish evil-owl-mode
;; :config
;; (evil-owl-mode))
(use-package evil-exchange
:config
(evil-exchange-install))
(use-package evil-matchit
:config
(global-evil-matchit-mode 1))
(use-package expand-region
:custom
expand-region-contract-fast-key "X"
:config
(general-define-key
:keymaps 'override
:states 'visual
"x" 'er/expand-region))
(use-package vdiff
:config
(evil-define-key 'normal vdiff-mode-map "," vdiff-mode-prefix-map))
(use-package vdiff-magit
:config
(define-key magit-mode-map "e" 'vdiff-magit-dwim)
(define-key magit-mode-map "E" 'vdiff-magit)
(transient-suffix-put 'magit-dispatch "e" :description "vdiff (dwim)")
(transient-suffix-put 'magit-dispatch "e" :command 'vdiff-magit-dwim)
(transient-suffix-put 'magit-dispatch "E" :description "vdiff")
(transient-suffix-put 'magit-dispatch "E" :command 'vdiff-magit))
;; (use-package windower
;; :config
;; (global-set-key (kbd "s-M-h") 'windower-move-border-left)
;; (global-set-key (kbd "s-M-j") 'windower-move-border-below)
;; (global-set-key (kbd "s-M-k") 'windower-move-border-above)
;; (global-set-key (kbd "s-M-l") 'windower-move-border-right)
;; (global-set-key (kbd "s-H") 'windower-swap-left)
;; (global-set-key (kbd "s-J") 'windower-swap-below)
;; (global-set-key (kbd "s-K") 'windower-swap-above)
;; (global-set-key (kbd "s-L") 'windower-swap-right))
(use-package which-key
:defer t
:init (which-key-mode)
:diminish which-key-mode)
(my/leader-def
"l" '(:ignore :which-key "bookmarks")
"lm" '(bookmark-set :which-key "set bookmark")
"ll" '(bookmark-jump :which-key "jump to bookmark"))
;; (use-package bufler
;; :config
;; (require 'helm-bufler)
;; (bufler-mode))
;;appearance
;; (use-package zenburn-theme
;; :config
;; (load-theme 'zenburn t))
;; (use-package cyberpunk-theme :ensure t)
;; (use-package doom-themes
;; :config
;; (load-theme 'doom-dark+ t))
;; (use-package modus-operandi-theme
;; :config
;; (load-theme 'modus-operandi t))
(use-package modus-vivendi-theme
:config
(load-theme 'modus-vivendi t))
;; (use-package eziam-dusk-theme
;; :ensure eziam-theme)
(use-package smooth-scrolling
:config
(smooth-scrolling-mode 1))
(use-package auto-dim-other-buffers
:config
(setq auto-dim-other-buffers-face nil)
(auto-dim-other-buffers-mode 1))
;; eshell
(defun my/eshell-delete-line ()
(interactive)
(eshell-bol)
(kill-line))
(defun my/eshell-change-line ()
(interactive)
(my/eshell-delete-line)
(evil-insert 1))
(setq eshell-cmpl-ignore-case t)
(use-package eshell-prompt-extras
:config
(setq eshell-highlight-prompt t
eshell-prompt-function 'epe-theme-lambda))
(use-package fish-completion)
(use-package bash-completion)
(use-package pcomplete-extension)
(use-package pcmpl-args)
(use-package pcmpl-git)
(use-package esh-autosuggest
:hook (eshell-mode . esh-autosuggest-mode))
;; ranger
(use-package ranger
:commands ranger
:config
(general-define-key
:keymaps 'ranger-normal-mode-map
"cp" '(my/dired-convert-to-pdf :which-key "convert to pdf")
"gr" '(ranger-refresh :which-key "refresh"))
(setq ranger-cleanup-eagerly t)
(ranger-override-dired-mode t))
;; (use-package ivy :ensure t
;; :diminish (ivy-mode . "") ; does not display ivy in the modeline
;; :init (ivy-mode 1) ; enable ivy globally at startup
;; :config
;; (setq ivy-use-virtual-buffers t) ; extend searching to bookmarks and …
;; (setq ivy-height 20) ; set height of the ivy window
;; (setq ivy-count-format "(%d/%d) ") ; count format, from the ivy help page
;; )
(use-package pulseaudio-control
:custom
(pulseaudio-control-volume-step "5%")
:config
(setq pulseaudio-control--volume-maximum '(("percent" . 110)
("decibels" . 2.5)
("raw" . 72000))))
(use-package helm
:diminish helm-mode
:defer t
:after helm-exwm
:config
(general-define-key
:keymaps 'helm-find-files-map
"M-H" 'left-char
"M-L" 'right-char
"M-y" 'helm-ff-run-copy-file
"M-r" 'helm-ff-run-rename-file
"M-s" 'helm-ff-run-find-file-as-root
"M-o" 'helm-ff-run-switch-other-window
"M-O" 'helm-ff-run-switch-other-frame
"M-SPC" 'helm-toggle-visible-mark-forward
"M-RET" 'helm-ff-run-open-file-with-default-tool)
(general-define-key
:keymaps 'helm-buffer-map
"M-SPC" 'helm-toggle-visible-mark-forward
"M-d" 'helm-buffer-run-kill-persistent)
(setq completion-styles `(basic partial-completion emacs22 initials
,(if (version<= emacs-version "27.0") 'helm-flex 'flex)))
(setq helm-mode-fuzzy-match t)
(setq helm-completion-in-region-fuzzy-match t)
(setq helm-M-x-fuzzy-match t)
(setq helm-buffers-fuzzy-matching t)
(setq helm-completion-in-region-fuzzy-match t)
(setq helm-file-cache-fuzzy-match t)
(setq helm-imenu-fuzzy-match t)
(setq helm-mode-fuzzy-match t)
(setq helm-locate-fuzzy-match t)
(setq helm-quick-update t)
(setq helm-recentf-fuzzy-match t)
(setq helm-exwm-emacs-buffers-source (helm-exwm-build-emacs-buffers-source))
(setq helm-exwm-source (helm-exwm-build-source))
(setq helm-mini-default-sources `(helm-exwm-emacs-buffers-source
helm-exwm-source
helm-source-recentf))
(helm-mode 1))
(use-package helm-exwm)
(use-package helm-dictionary)
(use-package helm-tramp)
(use-package helm-unicode)
(use-package helm-flycheck)
(use-package helm-swoop
:config
(general-define-key
:states '(override normal visual)
"/" '(lambda () (interactive)
(let ((helm-swoop-pre-input-function
(lambda () "")))
(helm-swoop)))
"?" '(lambda () (interactive)
(let ((helm-swoop-pre-input-function
(lambda () "")))
(helm-swoop)))
"n" '(lambda () (interactive)
(let ((helm-swoop-pre-input-function
(lambda () (if (boundp 'helm-swoop-pattern)
helm-swoop-pattern ""))))
(helm-swoop)))
"N" '(lambda () (interactive)
(let ((helm-swoop-pre-input-function
(lambda () (if (boundp 'helm-swoop-pattern)
helm-swoop-pattern ""))))
(helm-swoop)))
"*" 'helm-swoop
"#" 'helm-swoop)
(define-key helm-swoop-map (kbd "M-i") 'helm-multi-swoop-current-mode-from-helm-swoop))
(use-package company
:diminish company-mode
:config
(add-to-list 'company-backends 'company-omnisharp)
(setq company-dabbrev-downcase nil)
(setq read-file-name-completion-ignore-case t)
(global-company-mode 1))
;; abbrev mode
(setq abbrev-file-name ;; tell emacs where to read abbrev
(concat user-emacs-directory "abbrev-snippets.el"))
;; definitions from...
(setq save-abbrevs 'silently)
(setq-default abbrev-mode nil)
(use-package yasnippet
:diminish yas-minor-mode
:config
(yas-global-mode 1))
(use-package yasnippet-snippets
:after yasnippet)
(use-package projectile
:diminish projectile-mode
:defer t
:config
(my/leader-def
:states 'normal
"p" 'projectile-command-map)
(projectile-mode 1))
(use-package helm-projectile
:after projectile
:config
(helm-projectile-on))
(use-package projectile-ripgrep)
(use-package magit
:commands magit-status
:general (my/leader-def
"gs" '(magit-status :which-key "git status")))
(use-package evil-magit)
(use-package vc-msg
:general (my/leader-def
"gb" '(vc-msg-show :which-key "git blame")))
(defun doc-view-setup ()
;; open docx as text
(define-derived-mode
pandoc-view-mode
markdown-mode
"pandoc-view-mode"
"View pandoc processing of docx file using markdown mode."
(erase-buffer)
(let* ((pandoc (executable-find "pandoc")))
(insert (shell-command-to-string
(concat pandoc " --wrap=none " (shell-quote-argument (buffer-file-name)) " -t markdown"))))
(not-modified)
(read-only-mode t))
;; (add-to-list 'auto-mode-alist '("\\.docx\\'" . pandoc-view-mode))
(my/local-leader-def
:keymaps 'doc-view-mode-map
"p" 'pandoc-view-mode ; TODO create toggle function
"d" 'doc-view-mode)
(general-define-key
:states 'normal
:keymaps 'doc-view-mode-map
"j" 'doc-view-next-page
"k" 'doc-view-previous-page
"<down>" 'doc-view-next-page
"<up>" 'doc-view-previous-page))
(doc-view-setup)
(unless (system-name= "localhost" "lina")
(use-package pdf-tools
:defer t
:init
(pdf-tools-install)
:magic ("%PDF" . pdf-view-mode)
:config
(add-hook 'pdf-view-mode-hook 'pdf-view-midnight-minor-mode)
(add-hook 'pdf-view-mode-hook 'auto-revert-mode)
(setq-default pdf-view-display-size 'fit-page)
(setq pdf-view-continuous nil)
(evil-collection-init 'pdf)
(setq pdf-view-midnight-colors '("WhiteSmoke" . "gray16"))
:general
(general-define-key
:states '(motion normal)
:keymaps 'pdf-view-mode-map
;; evil-style bindings
;; "SPC" nil ;TODO where to put this globally?
"-" nil ;TODO where to put this globally?
"j" '(pdf-view-scroll-up-or-next-page :which-key "scroll down")
"k" '(pdf-view-scroll-down-or-previous-page :which-key "scroll up")
"<down>" 'pdf-view-scroll-up-or-next-page
"<up>" 'pdf-view-scroll-down-or-previous-page
;; "j" '(pdf-view-next-line-or-next-page :which-key "scroll down")
;; "k" '(pdf-view-previous-line-or-previous-page :which-key "scroll up")
"L" '(image-forward-hscroll :which-key "scroll right")
"H" '(image-backward-hscroll :which-key "scroll left")
"l" '(pdf-view-next-page :which-key "page down")
"h" '(pdf-view-previous-page :which-key "page up")
"u" '(pdf-view-scroll-down-or-previous-page :which-key "scroll down")
"d" '(pdf-view-scroll-up-or-next-page :which-key "scroll up")
"/" '(isearch-forward :which-key search forward)
"?" '(isearch-backward :which-key search backward)
"0" '(image-bol :which-key "go left")
"$" '(image-eol :which-key "go right"))
(my/local-leader-def
;; :states 'normal
:keymaps 'pdf-view-mode-map
;; Scale/Fit
;; "f" nil
"fw" '(pdf-view-fit-width-to-window :which-key "fit width")
"fh" '(pdf-view-fit-height-to-window :which-key "fit heigth")
"fp" '(pdf-view-fit-page-to-window :which-key "fit page")
"a" '(:ignore :which-key "annotations")
"at" '(pdf-annot-add-text-annotation :which-key "text")
"ah" '(pdf-annot-add-highlight-markup-annotation :which-key "highlight")
"ao" '(pdf-annot-add-strikeout-markup-annotation :which-key "strikeout")
"aD" '(pdf-annot-delete :which-key "delete")
"m" '(pdf-view-set-slice-using-mouse :which-key "slice using mouse")
"b" '(pdf-view-set-slice-from-bounding-box :which-key "slice from bounding box")
"R" '(pdf-view-reset-slice :which-key "reset slice")
"zr" '(pdf-view-scale-reset :which-key "zoom reset"))))
;; prettify stuff
;; (set-fontset-font "fontset-default" '(#x1d4d0 . #x1d4e2) "Symbola")
(global-prettify-symbols-mode 1)
(defvar global-prettify-symbols-alist '(("lambda" . 955)
("*" . 215)
("/" . 247)
("<=" . ?≤)
(">=" . ?≥)))
(defun my/setup-pretty-symbols (list)
(mapc (lambda (pair) (push pair prettify-symbols-alist))
(append
global-prettify-symbols-alist
list)))
(defun my/lisp-setup-pretty-symbols ()
(my/setup-pretty-symbols
'(("defun" . 8518))))
(add-hook 'lisp-mode-hook #'my/lisp-setup-pretty-symbols)
(defun my/csharp-setup-pretty-symbols ()
(my/setup-pretty-symbols
'(("!=" . 8800)
("==" . 65309)
("=" . 8592)
("int" . 8484)
("double" . 8477)
("bool" . 8492)
("string" . 963)
("String" . 963)
("void" . 8709)
("new" . 9733)
("this" . 964)
("List" . 8466)
;; ("[]" . #x2a02)
;; ("Dictionary" . #x1d507)
("public" . 8511)
("protected" . 8508)
("not" . 10071)
("for" . 8704)
("foreach" . 8704)
("in" . 8712)
("var" . 957)
("delegate" . 955)
("return" . 10235)
("get" . 10548)
("set" . 10549)
("null" . 8709)
("true" . 10003)
("false" . 10007))))
;; (add-hook 'csharp-mode-hook #'my/csharp-setup-pretty-symbols)
(use-package pretty-mode
:config
(pretty-activate-groups
'(:sub-and-superscripts :greek :arithmetic-nary :equality :ordering :ordering-double :ordering-triple :arrows :arrows-twoheaded :punctuation :logic :sets)))
;;exwm
(if (not (system-name= "lina"))
(progn
(use-package xelb)
(use-package exwm
:init
(server-start)
:config
(evil-set-initial-state 'exwm-mode 'emacs)
(setq mouse-autoselect-window nil
focus-follows-mouse nil)
(exwm-enable))
;; taken from https://github.com/dakra/dmacs/blob/master/init.org#exwm
(use-package windmove)
;; Switching workspaces
(defun exwm-workspace-switch-previous (p)
"Switch to previous workspace"
(interactive "p")
(if (< (- exwm-workspace-current-index p) 0)
(exwm-workspace-switch (1- (length exwm-workspace--list)))
(exwm-workspace-switch (- exwm-workspace-current-index p))))
(defun exwm-workspace-switch-next (p)
"Switch to next workspace"
(interactive "p")
(if (> (+ exwm-workspace-current-index p) (1- (length exwm-workspace--list)))
(exwm-workspace-switch 0)
(exwm-workspace-switch (+ exwm-workspace-current-index p))))
(defun exwm-windmove-left (&optional arg)
"Like windmove-left but go to previous workspace if there is window on the left."
(interactive "P")
(if (or (<= exwm-connected-displays 1) (windmove-find-other-window 'left arg))
(windmove-do-window-select 'left arg)
;; No window to the left
;; Switch to previous workspace and select rightmost window
;; (exwm-workspace-switch-previous 1)
;; (while (windmove-find-other-window 'right arg)
;; (windmove-do-window-select 'right arg))
))
(defun exwm-windmove-right (&optional arg)
"Like windmove-right but go to previous workspace if there is a window on the right."
(interactive "P")
(if (or (<= exwm-connected-displays 1) (windmove-find-other-window 'right arg))
(windmove-do-window-select 'right arg)
;; No window to the left
;; Switch to next workspace and select leftmost window
;; (exwm-workspace-switch-next 1)
;; (while (windmove-find-other-window 'left arg)
;; (windmove-do-window-select 'left arg))
))
(defun exwm-windmove-down (&optional arg)
"Like windmove-down but switch monitors if there is no window and active minibuffer below"
(interactive "P")
(let ((active-minibuffer-below-p
(and (minibuffer-window-active-p (minibuffer-window))
(eq (minibuffer-window) (windmove-find-other-window 'down arg)))))
(if (or (<= exwm-connected-displays 1)