-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.el
332 lines (277 loc) · 10.7 KB
/
config.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
;; Place your private configuration here! Remember, you do not need to run 'doom
;; sync' after modifying this file!
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets.
(setq user-full-name "royokong"
user-mail-address "[email protected]")
(setenv "PATH" (concat "/opt/homebrew/bin/" ":" (getenv "PATH")))
;; Doom exposes five (optional) variables for controlling fonts in Doom. Here
;; are the three important ones:
;;
;; + `doom-font'
;; + `doom-variable-pitch-font'
;; + `doom-big-font' -- used for `doom-big-font-mode'; use this for
;; presentations or streaming.
;;
;; They all accept either a font-spec, font string ("Input Mono-12"), or xlfd
;; font string. You generally only need these two:
;; (setq doom-font (font-spec :family "monospace" :size 12 :weight 'semi-light)
;; doom-variable-pitch-font (font-spec :family "sans" :size 13))
;; There are two ways to load a theme. Both assume the theme is installed and
;; available. You can either set `doom-theme' or manually load a theme with the
;; `load-theme' function. This is the default:
(setq doom-theme 'doom-nord)
(setq doom-font (font-spec :family "Roboto Mono" :size 14)
doom-unicode-font (font-spec :family "苹方-简"))
;;(setq doom-font (font-spec :family "Monego" :size 14))
;; If you use `org' and don't want your org files in the default location below,
;; change `org-directory'. It must be set before org loads!
(setq org-directory "~/org/")
;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
;;(setq display-line-numbers-type t)
(setq display-line-numbers-type 'relative)
;; proxy
(setq url-proxy-services
'(("no_proxy" . "^\\(localhost\\|10\\..*\\|192\\.168\\..*\\)")
("http" . "127.0.0.1:1087")
("https" . "127.0.0.1:1087")))
;; gc set up
;; use default value, sweet point for me
(after! gcmh
(setq gcmh-high-cons-threshold 1073741824))
;; not ignore some repos in local path
(defun my-doom-project-ignored-p-around (orig-fn project-root)
"Around advice for `doom-project-ignored-p` to not ignore some project roots."
(unless (string-match-p "lsp-bridge" project-root)
(funcall orig-fn project-root)))
(advice-add 'doom-project-ignored-p :around #'my-doom-project-ignored-p-around)
;; Here are some additional functions/macros that could help you configure Doom:
;;
;; - `load!' for loading external *.el files relative to this one
;; - `use-package!' for configuring packages
;; - `after!' for running code after a package has loaded
;; - `add-load-path!' for adding directories to the `load-path', relative to
;; this file. Emacs searches the `load-path' when you load packages with
;; `require' or `use-package'.
;; - `map!' for binding new keys
;;
;; To get information about any of these functions/macros, move the cursor over
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
;; This will open documentation for it, including demos of how they are used.
;;
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
;; they are implemented.
;;
;;(after! evil-snipe (evil-snipe-mode -1))
(remove-hook 'doom-first-input-hook #'evil-snipe-mode)
(setq avy-all-windows t)
(setq avy-background t)
;; not use ESC as prefix key
(define-key key-translation-map (kbd "ESC") (kbd "C-g"))
(set-popup-rule! "^\*doom:scra.*" :side 'right :size 0.5 :vslot -4 :select t :quit nil :ttl nil)
(add-hook 'doom-after-init-hook
(lambda ()
;; vimish fold mode
(vimish-fold-global-mode 1)))
(add-hook 'doom-first-buffer-hook
(lambda ()
;; sort tab on
(sort-tab-turn-on)
(global-company-mode -1)
(toggle-frame-maximized-or-fullframe)
;; init holo-layer
;; (add-to-list 'load-path "~/holo-layer")
;; (setq holo-layer-enable-cursor-animation t)
;; (require 'holo-layer)
;; (holo-layer-enable)
;; face
(set-fontset-font t 'han (font-spec :family "苹方-简"))
(set-fontset-font t 'unicode "Apple Color Emoji" nil 'append)))
(after! python
(set-repl-handler! 'python-mode #'+python/open-ipython-repl)
(add-hook 'python-mode-hook
(lambda()
;;(smartparens-mode -1)
(setq-local dash-docs-docsets '("PyTorch" "transformers" "Python 3"))
(setq-local dash-docs-browser-func 'browse-url)
(which-function-mode 1))))
;; enable local and eval in .dir-local
(setq enable-local-eval t)
(setq enable-local-variables t)
(after! highlight-symbol
(set-face-attribute 'highlight-symbol-face nil :inherit 'evil-ex-lazy-highlight))
(setq +lookup-provider-url-alist (append +lookup-provider-url-alist
'(("Google scholar" "https://scholar.google.com/scholar?q=%s"))))
;; word contains underscores
(after! python
(add-hook 'python-mode-hook
(lambda() (modify-syntax-entry ?_ "w"))))
(after! vterm
(add-hook 'vterm-mode-hook
(lambda() (modify-syntax-entry ?_ "w"))))
(add-hook 'emacs-lisp-mode-hook
(lambda() (modify-syntax-entry ?- "w")))
;; theme
(defun toggle-dark-light-theme ()
(interactive)
(let ((dark-theme (equal doom-theme 'doom-nord)))
(if dark-theme
(load-theme 'ef-summer)
(load-theme 'doom-nord)
;; reload to doom-nord again to
;; avoid blink in echo area
(load-theme 'doom-nord))
(when (featurep 'holo-layer)
(setq holo-layer-cursor-color (face-background 'cursor))
(holo-layer-restart-process))
;; fontify *-ts-mod
(set-face-attribute 'font-lock-property-use-face nil
:foreground (face-foreground 'font-lock-constant-face)
:slant 'italic)
(set-face-attribute 'font-lock-variable-use-face nil
:foreground (face-foreground 'default))
(if dark-theme
(set-face-attribute 'font-lock-preprocessor-face nil
:foreground (face-foreground 'font-lock-variable-name-face)))
(when (featurep 'lsp-bridge)
(run-with-timer 0.1 nil
#'(lambda()
(set-face-background 'acm-frame-default-face (face-attribute 'default :background))
(set-face-background 'acm-frame-select-face (face-attribute 'highlight :background))
(set-face-foreground 'acm-frame-select-face (face-attribute 'highlight :foreground))
(lsp-bridge-restart-process)
(acm-reset-colors)
(when (buffer-live-p acm-buffer)
(kill-buffer acm-buffer)
(kill-buffer acm-doc-buffer)
(kill-buffer lsp-bridge-diagnostic-buffer)))))))
;; vertico support pyim
(after! vertico
(require 'pyim)
(pyim-default-scheme 'pyim-shuangpin)
(defun my-orderless-regexp (orig-func component)
(let ((result (funcall orig-func component)))
(pyim-cregexp-build result)))
(advice-add 'orderless-regexp :around #'my-orderless-regexp))
;; use ts mode
(when (and (featurep 'treesit)
(treesit-available-p))
(add-to-list 'major-mode-remap-alist '(python-mode . python-ts-mode))
(add-to-list 'major-mode-remap-alist '(json-mode . json-ts-mode))
(add-to-list 'major-mode-remap-alist '(sh-mode . bash-ts-mode)))
(defun toggle-emacs-proxy ()
(interactive)
(cond ((equal url-proxy-services nil)
(setq url-proxy-services
'(("no_proxy" . "^\\(localhost\\|10\\..*\\|192\\.168\\..*\\)")
("http" . "127.0.0.1:1087")
("https" . "127.0.0.1:1087")))
(setq eaf-proxy-host "127.0.0.1"
eaf-proxy-port "1087"
eaf-proxy-type "http")
(setenv "https_proxy" "http://127.0.0.1:1087")
(setenv "http_proxy" "http://127.0.0.1:1087")
(setenv "NO_PROXY" "127.0.0.1")
(setenv "ALL_PROXY" "socks://172.0.0.1:1080"))
(t
(setq url-proxy-services nil)
(setq eaf-proxy-host ""
eaf-proxy-port ""
eaf-proxy-type "")
(setenv "https_proxy" nil)
(setenv "http_proxy" nil)
(setenv "ALL_PROXY" nil)))
;; restart
(copilot-diagnose)
(lsp-bridge-restart-process))
(defvar hide-modeline-check-timer nil)
;; add idle timer to ensure modeline is hidden
(setq hide-modeline-check-timer
(run-with-idle-timer
2 t
(lambda()
(cl-loop for buffer in '("*sort-tab*" " *lsp-bridge-diagnostic*")
do (when (get-buffer buffer)
(with-current-buffer buffer
(when mode-line-format
(setq mode-line-format nil))))))))
(load! "+bindings")
(load! "+patches")
(load! "+local")
;; configs
(when (treesit-available-p)
(load! "configs/init-ts-mode"))
;;
(load! "configs/init-imenu")
;;
(load! "configs/init-treemacs")
;;
(load! "configs/init-doom-modeline")
;;
(load! "configs/init-evil")
;;
(load! "configs/init-wakatime")
;;
(load! "configs/init-vterm")
;;
(load! "configs/init-ivy-posframe")
;;
(load! "configs/init-ein-notebook")
;;
(load! "configs/init-netease-music")
;;
(load! "configs/init-rime")
;;
(load! "configs/init-telega")
;;
(load! "configs/init-realgud")
;;
(load! "configs/init-blink-search")
;;
(load! "configs/init-color-rg")
;;
(load! "configs/init-pdf-search")
;;
(load! "configs/init-elfeed")
;;
(load! "configs/init-sort-tab")
;;
(load! "configs/init-org")
;;
(load! "configs/init-org-noter")
;;
(load! "configs/init-eaf")
;;
(load! "configs/init-corfu")
;;
(load! "configs/init-lsp-bridge")
;;
(load! "configs/init-elisp")
;;
(load! "configs/init-magit")
;;
(load! "configs/init-copilot")
;;(doom-load-packages-incrementally '(python treesit acm lsp-bridge corfu))
(doom-load-packages-incrementally '(corfu))
(doom-load-packages-incrementally '(zmq citar elfeed jupyter evil-org))
(doom-load-packages-incrementally '(telega pdf-tools org-noter))
;; tools
(add-to-list 'load-path "/Users/royokong/.doom.d/tools/")
(use-package! start-sync :after (:any vterm python sh-script))
(use-package! work-remote-tmux :after (:any vterm python sh-script))
(use-package! quick-open :after dired)
(use-package! translate-shell :commands (translate-shell translate-rewrite))
(use-package! get-gpu-status :commands get-gpu-status)
(use-package! hl-evil :after (:any vterm python sh-script))
(use-package! doctor-chatgpt :after doctor)
;;(load! "tools/start-sync")
;;
;;(load! "tools/quick-open")
;;
;;(load! "tools/trans")
;;
;;(load! "tools/work-remote-tmux")
;;
;;(load! "tools/get-gpu-status")