summaryrefslogtreecommitdiff
path: root/emacs/init.el
blob: 36c32b3b4e5c03530d72ff8aa855dbee74a3ccbd (plain)
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
;;; -*- lexical-binding: t -*-

(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.
 '(comment-style 'extra-line)
 '(connection-local-criteria-alist
   '(((:application tramp :protocol "kubernetes")
      tramp-kubernetes-connection-local-default-profile)
     ((:application tramp :protocol "flatpak")
      tramp-container-connection-local-default-flatpak-profile
      tramp-flatpak-connection-local-default-profile)
     ((:application tramp)
      tramp-connection-local-default-system-profile
      tramp-connection-local-default-shell-profile)
     ((:application eshell) eshell-connection-default-profile)))
 '(connection-local-profile-alist
   '((tramp-flatpak-connection-local-default-profile
      (tramp-remote-path "/app/bin" tramp-default-remote-path "/bin"
                         "/usr/bin" "/sbin" "/usr/sbin"
                         "/usr/local/bin" "/usr/local/sbin"
                         "/local/bin" "/local/freeware/bin"
                         "/local/gnu/bin" "/usr/freeware/bin"
                         "/usr/pkg/bin" "/usr/contrib/bin" "/opt/bin"
                         "/opt/sbin" "/opt/local/bin"))
     (tramp-kubernetes-connection-local-default-profile
      (tramp-config-check . tramp-kubernetes--current-context-data)
      (tramp-extra-expand-args 97
                               (tramp-kubernetes--container
                                (car tramp-current-connection))
                               104
                               (tramp-kubernetes--pod
                                (car tramp-current-connection))
                               120
                               (tramp-kubernetes--context-namespace
                                (car tramp-current-connection))))
     (tramp-container-connection-local-default-flatpak-profile
      (tramp-remote-path "/app/bin" tramp-default-remote-path "/bin"
                         "/usr/bin" "/sbin" "/usr/sbin"
                         "/usr/local/bin" "/usr/local/sbin"
                         "/local/bin" "/local/freeware/bin"
                         "/local/gnu/bin" "/usr/freeware/bin"
                         "/usr/pkg/bin" "/usr/contrib/bin" "/opt/bin"
                         "/opt/sbin" "/opt/local/bin"))
     (tramp-connection-local-darwin-ps-profile
      (tramp-process-attributes-ps-args "-acxww" "-o"
                                        "pid,uid,user,gid,comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
                                        "-o" "state=abcde" "-o"
                                        "ppid,pgid,sess,tty,tpgid,minflt,majflt,time,pri,nice,vsz,rss,etime,pcpu,pmem,args")
      (tramp-process-attributes-ps-format (pid . number)
                                          (euid . number)
                                          (user . string)
                                          (egid . number) (comm . 52)
                                          (state . 5) (ppid . number)
                                          (pgrp . number)
                                          (sess . number)
                                          (ttname . string)
                                          (tpgid . number)
                                          (minflt . number)
                                          (majflt . number)
                                          (time . tramp-ps-time)
                                          (pri . number)
                                          (nice . number)
                                          (vsize . number)
                                          (rss . number)
                                          (etime . tramp-ps-time)
                                          (pcpu . number)
                                          (pmem . number) (args)))
     (tramp-connection-local-busybox-ps-profile
      (tramp-process-attributes-ps-args "-o"
                                        "pid,user,group,comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
                                        "-o" "stat=abcde" "-o"
                                        "ppid,pgid,tty,time,nice,etime,args")
      (tramp-process-attributes-ps-format (pid . number)
                                          (user . string)
                                          (group . string) (comm . 52)
                                          (state . 5) (ppid . number)
                                          (pgrp . number)
                                          (ttname . string)
                                          (time . tramp-ps-time)
                                          (nice . number)
                                          (etime . tramp-ps-time)
                                          (args)))
     (tramp-connection-local-bsd-ps-profile
      (tramp-process-attributes-ps-args "-acxww" "-o"
                                        "pid,euid,user,egid,egroup,comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
                                        "-o"
                                        "state,ppid,pgid,sid,tty,tpgid,minflt,majflt,time,pri,nice,vsz,rss,etimes,pcpu,pmem,args")
      (tramp-process-attributes-ps-format (pid . number)
                                          (euid . number)
                                          (user . string)
                                          (egid . number)
                                          (group . string) (comm . 52)
                                          (state . string)
                                          (ppid . number)
                                          (pgrp . number)
                                          (sess . number)
                                          (ttname . string)
                                          (tpgid . number)
                                          (minflt . number)
                                          (majflt . number)
                                          (time . tramp-ps-time)
                                          (pri . number)
                                          (nice . number)
                                          (vsize . number)
                                          (rss . number)
                                          (etime . number)
                                          (pcpu . number)
                                          (pmem . number) (args)))
     (tramp-connection-local-default-shell-profile
      (shell-file-name . "/bin/sh") (shell-command-switch . "-c"))
     (tramp-connection-local-default-system-profile
      (path-separator . ":") (null-device . "/dev/null"))
     (eshell-connection-default-profile (eshell-path-env-list))))
 '(custom-enabled-themes '(tmu-custom))
 '(custom-safe-themes
   '("6dafb31ade9ff07229faaf05c41c2ae475c44731362b792f65f3930b1a2c9cfd"
     "dc77e008092a5a4aa6b6ed8e4826bebf8f2fb930a8de073bf7f458efd884cca8"
     "d1ff3e66028f9c527298580d2a64f9e3280f07f9e94d4dada72b67ef15069441"
     "3d4e3644e237a95683daa73e397c4c0d1ae06bbaaf8040104232591a28bc1315"
     "12a07bc38295e4b06a8965db261f51ea7ea61fbf91b3ef41298bbb549d1d9403"
     default))
 '(ede-project-directories
   '("/home/tmu/Desktop/eway/sway" "/home/tmu/Desktop/eway/cage"
     "/home/tmu/Desktop/eway/wlroots" "/home/tmu/Desktop/eway/comp"
     "/home/tmu/Desktop/eway"))
 '(menu-bar-mode nil)
 '(package-selected-packages
   '(haskell-mode pyim-wbdict solarized-theme evil-commentary
                  frog-jump-buffer evil-collection evil-easymotion
                  sideline-flymake sideline-lsp tree-sitter company-go
                  pyim-basedict evil-snipe evil-surround 2048-game
                  evil ibuffer-project persp-mode-projectile-bridge
                  persp-mode fish-mode chinese-conv esup buffer-move
                  flymake-diagnostic-at-point emms-state
                  emms-player-simple-mpv eshell-fringe-status esh-help
                  eshell-vterm rustic benchmark-init ivy-prescient eat
                  emms eyebrowse highlight dumb-jump volume workgroups
                  async bongo hydra free-keys gxref fold-this xelb
                  oauth2 imenu-anywhere popwin folding gdscript-mode))
 '(scroll-bar-mode nil)
 '(tool-bar-mode nil)
 '(transient-mark-mode nil)
 '(whitespace-style
   '(face trailing tabs lines-tail missing-newline-at-eof indentation
          space-after-tab space-before-tab tab-mark)))

;; (use-package benchmark-init
;;   :ensure t
;;   :config
;;   ;; To disable collection of benchmark data after init is done.
;;   (add-hook 'after-init-hook 'benchmark-init/deactivate))

(setq gc-cons-threshold most-positive-fixnum)

(add-hook 'emacs-startup-hook
          (lambda ()
            (setq gc-cons-threshold (expt 2 23))))

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-initialize)

;; stuff I will always want
(electric-pair-mode 1)
(global-hl-line-mode 1)
(global-auto-revert-mode 1)

;; spelling
(require 'spell-fu)
(setq ispell-personal-dictionary "/home/tmu/.aspell.en.pws")
(add-hook 'text-mode-hook (lambda () (spell-fu-mode 1)))

;; dictionaries
(define-prefix-command 'dict-map)
(global-set-key (kbd "M-l") 'dict-map)
(define-keymap :full nil
  :parent nil
  :suppress nil
  :keymap nil
  :name "dict-map"
  :prefix 'dict-map
  (kbd "w") 'sdcv-search-input
  (kbd "c") (lambda () (interactive)
              (activate-input-method 'pyim)
              (sdcv-search-input (read-from-minibuffer "Chinese Word: "
                                                       nil nil nil
                                                       nil nil t))
              (activate-input-method nil)))

;; nice startup
(require 'iimage)
(setq inhibit-startup-screen t)
(setq initial-scratch-message (concat (propertize ";; " 'invisible t)
      "</home/tmu/.emacs.d/splashLaputa.png>
;; scratch for lisp evaluation and unsaved text

"))
(add-hook 'emacs-startup-hook (lambda ()
                                (with-current-buffer "*scratch*"
                                  (iimage-mode 1))))

;; transparancy
(add-to-list 'default-frame-alist '(alpha-background . 90)) ; For all new frames
(defun toggle-frame-transparency ()
  "Toggle transparency."
  (interactive)
  (let ((alpha-transparency 90))
    (if (eq alpha-transparency (frame-parameter nil 'alpha-background))
        (set-frame-parameter nil 'alpha-background 100)
      (set-frame-parameter nil 'alpha-background alpha-transparency))))

;; custom func keybinds
(global-set-key (kbd "M-w") 'copy-region-as-kill) ;;make copying not flash cursor
(defun wrap-region-paren ()
  "Wraps the region in parens.
Similar to pressing ( with the region active."
  (interactive)
  (let ((beg (region-beginning))
        (end (region-end)))
    (save-excursion
      (goto-char beg)
      (insert "(")
      (goto-char (+ end 1))
      (insert ")")
    )))
(global-set-key (kbd "M-(") 'wrap-region-paren)
(defun zap-whitespace ()
  "zaps the whitespace around the point in both directions"
  (interactive)
  (push-mark)
  (skip-chars-backward " \t\n")
  (push-mark)
  (skip-chars-forward " \t\n")
  (delete-region (mark) (point))
  (pop-mark)
  (goto-char (mark))
  (pop-mark))
(global-set-key (kbd "M-z") 'zap-whitespace)
(defun wrap-sexp (&optional arg)
  "Wraps the following sexp in a pair of parens.
Places inside the new pair, with prefix arg do the same backwards, pushing the
mark.  Does the same of ARG number sexps if given"
  (interactive "P")
  (message "%s" arg)
  (if arg
      (progn
        (push-mark)
        (insert-pair -1 ?\( ?\)))
    (insert-pair 1 ?\( ?\))))
(global-set-key (kbd "C-M-z") 'wrap-sexp)

;;move buffers between windows in a convient way
(require 'buffer-move)
(global-set-key (kbd "C-x -") 'buf-move-right)

;; quick window switching
(global-set-key (kbd "M-o") 'other-window)

;; save/restore window config
(setq current-saved-layout ?0)
(seq-do (lambda (number)
          (let* ((string (int-to-string number))
                 (char (string-to-char string))
                 (key (kbd (concat "M-" string))))
            (global-unset-key key)
            (global-set-key key (lambda ()
                                  (interactive)
                                  (window-configuration-to-register current-saved-layout)
                                  (unless (window-configuration-p (car (get-register char)))
                                    (window-configuration-to-register char))
                                  (jump-to-register char)
                                  (setq current-saved-layout char)))))
        '(0 1 2 3 4 5 6 7 8 9))

;; get me a calculator
(global-unset-key (kbd "M-c"))
(global-set-key (kbd "M-c") 'calc)

;; buffer kills
(global-unset-key (kbd "M-k"))
(global-set-key (kbd "M-k") 'kill-current-buffer)
(global-set-key (kbd "M-K") 'kill-buffer-and-window)

;; latex stuff
(require 'tex-mode)
(define-key latex-mode-map (kbd "C-c m") (lambda () (interactive)
                                           (push-mark)
                                           (insert "\\[\n\n\\]")
                                           (indent-region (mark) (point))
                                           (pop-mark)
                                           (previous-line)
                                           (indent-for-tab-command)
                                           ))

(add-hook 'tex-mode-hook (lambda ()
                           (setq-local compile-command
                                       (concat "pdflatex " (shell-quote-argument (buffer-file-name))))
                           (add-hook 'after-save-hook 'recompile 0 t)))

;; better minibuffer complete
(use-package vertico
  :init
  (vertico-mode)
  (vertico-flat-mode)
  (setq vertico-cycle t))

(use-package orderless
  :ensure t
  :custom
  (completion-styles '(orderless partial-completion flex basic))
  (orderless-matching-styles '(orderless-literal orderless-regexp orderless-prefixes))
  ;; (orderless-skip-highlighting t)
  ;; (selectrum-highlight-candidates-function #'orderless-highlight-matches)
  )

(use-package which-key
  :ensure t
  :init
  (which-key-mode))

;; better in-buffer completion
;; (require 'company)
;; (add-hook 'prog-mode-hook (lambda ()
;;                          (company-mode 1)))
;; (global-unset-key (kbd "M-/"))
;; (global-set-key (kbd "M-/") 'company-complete)

;; mail stuff
(autoload 'mu4e "~/.emacs.d/mail.el" "mu4e stuff" t)

;; music
;; (autoload 'youtube-dl-enqueue "~/.emacs.d/youtube-dl.el" "download from youtube" t)

;; (emms-all)
;; (require 'emms-info-native)
;; (defun emms-file-info (track)
;;   "Sets info of a track based on it's file name. Expects Artist - Album - Track.ext."
;;   (when (emms-track-file-p track)
;;     (let* ((file-name (emms-track-name track))
;;            (tags (string-split (car (seq-reverse (string-split file-name "/"))) " - ")))
;;       (emms-track-set track 'info-artist (car tags))
;;       (emms-track-set track 'info-album (car (cdr tags)))
;;       (emms-track-set track 'info-title (car (cdr (cdr tags)))))))

;; (setq emms-player-list '(emms-player-mpv)
;;       emms-info-functions '(emms-file-info)
;;       emms-source-file-directory-tree-function 'emms-source-file-directory-tree-find)

;; (require 'emms-state)
;; ;; see single header, loaded AFTER this for more about emms-state


;; allow using emacsclient
(load "server")
(unless (server-running-p) (server-start))

;; mutli frame stuff
(global-set-key (kbd "C-x C-C") 'save-buffers-kill-terminal)
(global-set-key (kbd "C-x C-c") (lambda ()
                                  (interactive)
                                  (if (eq 1 (length (frame-list)))
                                      ;; sole frame, exit
                                      (save-buffers-kill-terminal)
                                    (delete-frame))))

;; don't ask about killing buffers
(setq kill-buffer-query-functions (delq 'process-kill-buffer-query-function kill-buffer-query-functions))

;; don't ask about kill processes
(setq confirm-kill-processes nil)

(autoload 'async-eval "~/.emacs.d/async-eval.el" "evaluate in another emacs process" t)

;; evil mode stuff
(setq
      evil-want-keybinding nil
      evil-want-integration t)
;; evil-want-C-d-scroll nil
;;       evil-want-C-w-delete nil
;;       evil-disable-insert-state-bindings t
;;       evil-respect-visual-line-mode t
(require 'evil)
(when (require 'evil-collection nil t)
  (evil-collection-init))
(evil-mode 1)
(evilem-default-keybindings "SPC")
(define-key evil-motion-state-map (kbd "TAB") 'indent-for-tab-command)
(use-package evil-surround
  :ensure t
  :config
  (global-evil-surround-mode 1))
(use-package evil-snipe
  :ensure t
  :config
  (evil-snipe-mode +1)
  (evil-snipe-override-mode +1)
  (setq evil-snipe-scope 'buffer)
  (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))
(define-key evil-insert-state-map (kbd "C-d") 'delete-char)
(define-key evil-insert-state-map (kbd "C-e") 'move-end-of-line)
(define-key evil-insert-state-map (kbd "C-a") 'move-beginning-of-line)
(define-key evil-normal-state-map (kbd "M-.") 'xref-find-definitions)
(define-key evil-normal-state-map (kbd "C-t") 'transpose-chars)

(add-hook 'prog-mode-hook (lambda ()
                           (modify-syntax-entry ?_ "w") ))

;;; sashka bindings
;; movement
(defun evil-window-split-and-switch ()
  "Split the window vertically and switch to the new buffer."
  (interactive)
  (evil-window-split)
  (other-window 1))

(defun evil-window-vsplit-and-switch ()
  "Split the window horizontally and switch to the new buffer."
  (interactive)
  (evil-window-vsplit)
  (other-window 1))

(evil-define-key 'normal global-map (kbd "SPC i") 'imenu)
(evil-define-key 'normal global-map (kbd "SPC RET") 'vterm)
(evil-define-key 'normal global-map (kbd "SPC v") 'vterm)
(evil-define-key 'normal global-map (kbd "SPC !") 'abort-recursive-edit)
(evil-define-key 'normal global-map (kbd "SPC f f")  'find-file)

(evil-define-key 'normal global-map (kbd "SPC SPC SPC j") 'evil-window-split-and-switch)
(evil-define-key 'normal global-map (kbd "SPC SPC SPC k") 'evil-window-split-and-switch)
(evil-define-key 'normal global-map (kbd "SPC SPC SPC h") 'evil-window-vsplit-and-switch)
(evil-define-key 'normal global-map (kbd "SPC SPC SPC l") 'evil-window-vsplit-and-switch)
(evil-define-key 'normal global-map (kbd "SPC SPC h") 'evil-window-left)
(evil-define-key 'normal global-map (kbd "SPC SPC j") 'evil-window-down)
(evil-define-key 'normal global-map (kbd "SPC SPC k") 'evil-window-up)
(evil-define-key 'normal global-map (kbd "SPC SPC l") 'evil-window-right)
(evil-define-key 'normal global-map (kbd "SPC SPC w") 'delete-window)
(evil-define-key 'normal global-map (kbd "SPC SPC q") 'delete-window)
(evil-define-key 'normal global-map (kbd "SPC SPC b") 'balance-windows)
(evil-define-key 'normal global-map (kbd "SPC s s") 'save-buffer)
(evil-define-key 'normal global-map (kbd "SPC s f")  'counsel-find-file)
(evil-define-key 'normal global-map (kbd "SPC s r")  'counsel-rg)
(evil-define-key 'normal global-map (kbd "SPC ;") 'frog-jump-buffer)

;; frog jump stuff
(add-hook 'frog-menu-after-init-hook (lambda ()
                                       (setq-local avy-background nil)))

(load-file "~/.emacs.d/coding-config.el")

;; (load-file "~/.emacs.d/single-header.el")

(put 'dired-find-alternate-file 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'list-timers 'disabled nil)
(put 'narrow-to-region 'disabled nil)

;; no tabs
(setq-default indent-tabs-mode nil)

;; input method stuff
(setq rime-translate-keybindings
      '("C-f" "C-b" "C-n" "C-p" "C-g" "<left>" "<right>" "<up>" "<down>" "<prior>" "<next>" "<delete>"))
(setq rime-share-data-dir "~/.local/share/fcitx5/rime")
(setq rime-show-candidate 'popup)


(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.
 '(frog-menu-posframe-background-face ((t (:background "RoyalBlue4"))))
 '(minibuffer-prompt ((t (:background "gray10" :foreground "cyan" :box nil :weight bold))))
 '(vterm-color-blue ((t (:inherit ansi-color-bright-green)))))
(put 'downcase-region 'disabled nil)