blob: 0b1dcf6b6d48afc61c99ce82a1c891524d873c29 (
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
|
;;; Code:
(set-language-environment "UTF-8")
(set-default-coding-systems 'utf-8)
;; Initialization screen
(setq fancy-splash-image "~/.emacs.d/images/true.png")
(setq inhibit-startup-screen t
initial-scratch-message nil
sentence-end-double-space nil
ring-bell-function 'ignore
frame-resize-pixelwise t)
;; Backup files
(setq make-backup-files nil
auto-save-default nil
create-lockfiles nil)
; Inhibit C-z
(when (display-graphic-p)
(global-unset-key (kbd "C-z"))
(global-unset-key (kbd "C-x C-z")))
(setq delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
(set-face-attribute 'default nil
:family "JetBrains Mono"
:height 100
:weight 'normal
:width 'normal)
; Taken from: https://emacs.stackexchange.com/questions/55059/ligatures-with-the-jetbrains-mono-font
(defconst jetbrains-ligature-mode--ligatures
'("-->" "//" "/**" "/*" "*/" "<!--" ":=" "->>" "<<-" "->" "<-"
"<=>" "==" "!=" "<=" ">=" "=:=" "!==" "&&" "||" "..." ".."
"|||" "///" "&&&" "===" "++" "--" "=>" "|>" "<|" "||>" "<||"
"|||>" "<|||" ">>" "<<" "::=" "|]" "[|" "{|" "|}"
"[<" ">]" ":?>" ":?" "/=" "[||]" "!!" "?:" "?." "::"
"+++" "??" "###" "##" ":::" "####" ".?" "?=" "=!=" "<|>"
"<:" ":<" ":>" ">:" "<>" "***" ";;" "/==" ".=" ".-" "__"
"=/=" "<-<" "<<<" ">>>" "<=<" "<<=" "<==" "<==>" "==>" "=>>"
">=>" ">>=" ">>-" ">-" "<~>" "-<" "-<<" "=<<" "---" "<-|"
"<=|" "/\\" "\\/" "|=>" "|~>" "<~~" "<~" "~~" "~~>" "~>"
"<$>" "<$" "$>" "<+>" "<+" "+>" "<*>" "<*" "*>" "</>" "</" "/>"
"<->" "..<" "~=" "~-" "-~" "~@" "^=" "-|" "_|_" "|-" "||-"
"|=" "||=" "#{" "#[" "]#" "#(" "#?" "#_" "#_(" "#:" "#!" "#="
"&="))
(sort jetbrains-ligature-mode--ligatures (lambda (x y) (> (length x) (length y))))
(dolist (pat jetbrains-ligature-mode--ligatures)
(set-char-table-range composition-function-table
(aref pat 0)
(nconc (char-table-range composition-function-table (aref pat 0))
(list (vector (regexp-quote pat)
0
'compose-gstring-for-graphic)))))
;; Don't ask to kill when we have an open line number
(setq-default confirm-kill-processes nil)
;; Line highlighting
(global-hl-line-mode 1)
;; Initial major mode
(setq initial-major-mode 'text-mode)
;; Auto revert mode to reload disk
(global-auto-revert-mode t)
;; menu bars
(menu-bar-mode -1)
(toggle-scroll-bar -1)
(tool-bar-mode -1)
(setq mac-shift-modifier 'meta)
;; Modeline
(use-package mood-line
;; Enable mood-line
:config
(mood-line-mode))
;; Disable major modes on long lines
(global-so-long-mode 1)
;; Ability to fold regions
(add-hook 'javascript-mode-hook (lambda () (hs-minor-mode 1)))
(add-hook 'typescript-mode-hook (lambda () (hs-minor-mode 1)))
(add-hook 'c-mode-hook (lambda () (hs-minor-mode 1)))
(add-hook 'python-mode-hook (lambda () (hs-minor-mode 1)))
(add-hook 'emacs-lisp-mode-hook (lambda () (hs-minor-mode 1)))
(bind-key* (kbd "C-<tab>") 'hs-toggle-hiding)
;; Default Values
(setq-default indent-tabs-mode nil) ; use spaces only if nil
(setq-default tab-width 2) ; Assuming you want your tabs to be four spaces wide
;; Cursor
(setq-default cursor-type 'bar)
(blink-cursor-mode 1)
;; Line numbers
(global-display-line-numbers-mode 1)
;; Show number of matches
(setq isearch-lazy-highlight t)
(setq isearch-lazy-count t)
;; Fringe
(setq-default left-fringe-width 20)
(setq-default right-fringe-width 20)
;; Margin
(use-package perfect-margin
:ensure t
:config
(perfect-margin-mode 1)
)
;; Highlight todos
(use-package hl-todo
:ensure t
:config
(global-hl-todo-mode 1)
)
;; Delete highlighted selection
(delete-selection-mode 1)
(use-package vertico
:ensure t
:init
(vertico-mode)
;; Different scroll margin
;; (setq vertico-scroll-margin 0)
;; Show more candidates
;; (setq vertico-count 20)
;; Grow and shrink the Vertico minibuffer
;; (setq vertico-resize t)
;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
;; (setq vertico-cycle t)
)
(use-package orderless
:ensure t
:init
;; Configure a custom style dispatcher (see the Consult wiki)
;; (setq orderless-style-dispatchers '(+orderless-consult-dispatch orderless-affix-dispatch)
;; orderless-component-separator #'orderless-escapable-split-on-space)
(setq completion-styles '(orderless basic)
completion-ignore-case t
completion-category-defaults nil
completion-category-overrides '((file (styles partial-completion)))))
;; Enable rich annotations using the Marginalia package
(use-package marginalia
:ensure t
;; Bind `marginalia-cycle' locally in the minibuffer. To make the binding
;; available in the *Completions* buffer, add it to the
;; `completion-list-mode-map'.
:bind (:map minibuffer-local-map
("M-A" . marginalia-cycle))
;; The :init section is always executed.
:init
;; Marginalia must be actived in the :init section of use-package such that
;; the mode gets enabled right away. Note that this forces loading the
;; package.
(marginalia-mode))
(use-package rg
:ensure t)
;; Projectile for project navigation
(use-package projectile
:ensure t
:config
(projectile-mode +1)
;(setq projectile-switch-project-action 'treemacs-add-and-display-current-project-exclusively)
(setq projectile-indexing-method 'native)
(setq projectile-enable-caching t)
(setq projectile-use-git-grep t)
(add-to-list 'projectile-globally-ignored-directories "node_modules")
(add-to-list 'projectile-globally-ignored-directories "elpa")
(add-to-list 'projectile-globally-ignored-directories "build")
(add-to-list 'projectile-globally-ignored-directories "dist")
(add-to-list 'projectile-project-root-files "package.json")
(add-to-list 'projectile-globally-ignored-files "package-lock.json")
(define-key projectile-mode-map (kbd "C-c p f") 'projectile-ripgrep)
(define-key projectile-mode-map (kbd "C-c p o") 'projectile-switch-project)
(define-key projectile-mode-map (kbd "C-c p p") 'projectile-find-file)
)
;; Git
(use-package git-gutter
:ensure t
:hook (prog-mode . git-gutter-mode)
:config
(setq git-gutter:update-interval 1)
(setq git-gutter:window-width 1))
(use-package git-gutter-fringe
:ensure t
:config
(define-fringe-bitmap 'git-gutter-fr:added [224] nil nil '(center repeated))
(define-fringe-bitmap 'git-gutter-fr:modified [224] nil nil '(center repeated))
(define-fringe-bitmap 'git-gutter-fr:deleted [128 192 224 240] nil nil 'bottom))
(use-package magit
:ensure t)
;; icons
(use-package all-the-icons
:ensure t
:if (display-graphic-p))
;; Global key binds
(bind-key* (kbd "M-.") 'xref-find-definitions)
(bind-key* (kbd "C-x k") 'kill-this-buffer)
(use-package company
:ensure t
:defer t
:init (add-hook 'after-init-hook 'global-company-mode)
:config
(setq company-minimum-prefix-length 2
company-tooltip-limit 10
company-backends '((company-capf company-gtags company-elisp company-css company-dabbrev company-nxml))
company-dabbrev-downcase nil
)
)
(use-package company-quickhelp
:ensure t
:defer t
:init (company-quickhelp-mode 1)
:config
(setq company-quickhelp-color-background (face-attribute 'default :background))
)
;; Eglot
(use-package eglot
:custom
(eglot-autoshutdown t)
:ensure t
:bind ("<f2>" . #'eglot-rename)
:config
(add-to-list 'eglot-server-programs '((c++-mode c-mode) "clangd-18"))
(add-to-list 'eglot-server-programs `((dart-mode) "/home/matthew/Programs/flutter/bin/dart" "language-server"))
(add-hook 'c-mode-common-hook 'eglot-ensure)
(add-hook 'dart-mode-hook 'eglot-ensure))
;; (set-face-underline 'eglot-highlight-symbol-face t)
(bind-key* (kbd "M-n") 'flymake-goto-next-error)
(bind-key* (kbd "M-p") 'flymake-goto-prev-error)
;; Vterm
(defun vterm-mode-set-colors()
"Set the colors of vterm to match my personal taste."
(setq-local global-hl-line-mode nil)
;(turn-off-evil-mode)
(display-line-numbers-mode -1)
(setq left-fringe-width 0)
(setq right-fringe-width 0)
(set-window-fringes (selected-window) 0 0 nil)
(face-remap-add-relative 'default '(:background "#232627"))
(face-remap-add-relative 'default '(:foreground"#fcfcfc"))
)
;; Line movement
(use-package drag-stuff
:config
(drag-stuff-global-mode)
;; Note: I do NOT use (drag-stuff-define-keys) because I want M-<LEFT/RIGHT> to work in org mode
(define-key drag-stuff-mode-map (drag-stuff--kbd 'up) 'drag-stuff-up)
(define-key drag-stuff-mode-map (drag-stuff--kbd 'down) 'drag-stuff-down)
)
;; Snippets
(use-package yasnippet
:ensure t
:config
;(setq yas-snippet-dirs
; '("~/.emacs.d/snippets" ;; personal snippets
; ))
(yas-global-mode 1)
(bind-key* (kbd "C-c y i") 'yas/insert-snippet)
)
(use-package yasnippet-snippets
:ensure t)
(use-package ledger-mode
:ensure t
:config
(add-to-list 'auto-mode-alist '("\\.ledger\\'" . ledger-mode)))
(use-package plantuml-mode
:ensure t
:config
(add-to-list 'auto-mode-alist '("\\.puml\\'" . plantuml-mode))
(setq plantuml-jar-path "~/.emacs.d/plantuml-1.2023.11.jar")
(setq plantuml-default-exec-mode 'jar)
(setq plantuml-indent-level 4))
(add-hook 'plantuml-mode-hook
(lambda ()
(setq indent-line-function (lambda () 'noindent))))
(provide 'general)
;;; general.el ends here
|