-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.el
671 lines (612 loc) · 24.2 KB
/
init.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
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
;;; init --- Summary
;;; Commentary:
;;; Code:
(require 'generic-x)
;;; Custom variables
(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.
'(create-lockfiles nil)
'(enable-recursive-minibuffers t)
'(gc-cons-threshold 16000000)
'(history-length 1000)
'(indent-tabs-mode nil)
'(make-backup-files nil)
'(menu-bar-mode nil)
'(ring-bell-function 'ignore)
'(scroll-margin 0)
'(show-trailing-whitespace t)
'(tab-width 4)
'(tool-bar-mode nil)
'(use-package-always-ensure t)
'(warning-suppress-log-types '((use-package)))
'(warning-suppress-types '((use-package))))
(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.
'(whitespace-tab ((t (:background "black" :foreground "LightYellow" :inverse-video t)))))
(with-eval-after-load 'package
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("jcs-elpa" . "https://jcs-emacs.github.io/jcs-elpa/packages/") t))
(eval-when-compile (require 'use-package))
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(use-package diminish)
(use-package auto-package-update
:custom
(auto-package-update-delete-old-versions t)
(auto-package-update-hide-results t)
:config
(auto-package-update-maybe))
(use-package which-key :diminish :hook (after-init . which-key-mode))
;;; ENV
(setenv "LANG" "ja_JP.UTF-8")
(if (eq system-type 'darwin)
(setenv "TMPDIR" (concat (getenv "HOME") "/.tmp")))
(use-package exec-path-from-shell
:custom
(exec-path-from-shell-variables '("PATH" "MANPATH"))
:config
(when (eq system-type 'darwin)
(exec-path-from-shell-initialize))
(exec-path-from-shell-copy-envs '("UID" "GID")))
;;; asdf
(use-package asdf
:straight (:host github :repo "tabfugnic/asdf.el" :files ("asdf.el"))
:autoload asdf--command asdf--format-output-to-list
:init
(defun asdf-where (plugin ver)
(replace-regexp-in-string "\n\\'" "" (shell-command-to-string (asdf--command "where" plugin ver))))
:config
(if (eq window-system 'ns) (setq asdf-binary (concat "/opt/homebrew/opt/asdf/libexec/" "/bin/asdf")))
(asdf-enable))
(winner-mode 1)
(global-hl-line-mode 1)
(savehist-mode 1)
(save-place-mode 1)
(global-auto-revert-mode 1)
(bind-key "RET" 'newline-and-indent)
(autoload 'winner-undo "winner" "Load winner-undo" t nil)
(bind-keys*
("C-z" . winner-undo)
("C-o" . other-window)
("C-h" . delete-backward-char)
("C-;" . completion-at-point))
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(defalias 'qrr 'query-replace-regexp)
(defalias 'yes-or-no-p 'y-or-n-p)
(defalias 'message-box 'message)
(when (eq (window-system) 'ns)
(set-face-attribute 'default nil :family "Menlo" :height 180)
(set-fontset-font t 'japanese-jisx0208 (font-spec :family "Hiragino Kaku Gothic ProN")))
(when (eq (window-system) 'x)
(set-face-attribute 'default nil :family "Inconsolata" :height 140)
(set-fontset-font t 'japanese-jisx0208 (font-spec :family "Noto Sans CJK JP" :size 28)))
(defvar local-lisp-load-path "~/.emacs.d/lisp")
(custom-set-variables
'(recentf-max-menu-items 1000)
'(recentf-max-saved-items 1000))
(recentf-mode 1)
;;; auth-source
(when (eq system-type 'darwin)
(add-to-list 'auth-sources 'macos-keychain-generic)
(add-to-list 'auth-sources 'macos-keychain-internet))
(use-package auth-source-kwallet
:straight (:host github :repo "phelrine/auth-source-kwallet" :files ("auth-source-kwallet.el"))
:config
(if (executable-find auth-source-kwallet-executable)
(auth-source-kwallet-enable)))
(use-package auth-source-ghcli
:load-path local-lisp-load-path
:autoload auth-source-ghcli-enable
:init
(auth-source-ghcli-enable))
(use-package multiple-cursors
:bind (("C-S-c C-S-c" . mc/edit-lines)
("C->" . mc/mark-next-like-this)
("C-<" . mc/mark-previous-like-this)))
(diminish 'eldoc-mode)
(global-eldoc-mode 1)
(use-package eldoc-box :bind ("C-c h" . eldoc-box-help-at-point))
(use-package ace-window :bind (("C-x o" . ace-window)))
(use-package unicode-fonts :config (unicode-fonts-setup))
;; https://github.com/rainstormstudio/nerd-icons.el#installing-fonts
;; M-x nerd-icons-install-fonts
(use-package nerd-icons-completion
:hook
(after-init . nerd-icons-completion-mode)
(marginalia-mode . nerd-icons-completion-marginalia-setup))
(use-package nerd-icons-dired :diminish :hook (dired-mode . nerd-icons-dired-mode))
(use-package projectile
:diminish
:bind (("C-x p" . projectile-command-map))
:hook (after-init . projectile-mode)
:autoload projectile-project-root
:config
;; FLUTTER
(add-to-list 'projectile-project-root-files-bottom-up "pubspec.yaml")
(add-to-list 'projectile-project-root-files-bottom-up "BUILD"))
(use-package vertico :init (vertico-mode))
(use-package orderless
:custom
(completion-styles '(orderless basic))
(completion-category-overrides '((file (styles basic partial-completion)))))
(use-package marginalia
;; Either bind `marginalia-cycle' globally or only in the minibuffer
:bind (("M-A" . marginalia-cycle)
:map minibuffer-local-map
("M-A" . marginalia-cycle))
;; The :init configuration is always executed (Not lazy!)
:init
(marginalia-mode))
(use-package corfu
:init (global-corfu-mode)
:config
(add-hook 'eshell-mode-hook
(lambda ()
(setq-local corfu-auto nil)
(corfu-mode))))
(use-package cape
:bind (("C-c p p" . completion-at-point) ;; capf
("C-c p d" . cape-dabbrev) ;; or dabbrev-completion
("C-c p f" . cape-file)
("C-c p k" . cape-keyword)
("C-c p :" . cape-emoji))
:commands cape-history
:init
(dolist (func '(cape-dabbrev cape-file cape-elisp-symbol cape-elisp-block cape-keyword))
(add-to-list 'completion-at-point-functions func)))
(use-package kind-icon
:custom
(kind-icon-use-icons nil)
(kind-icon-default-face 'corfu-default) ; to compute blended backgrounds correctly
:config
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))
(use-package dabbrev
;; Swap M-/ and C-M-/
:bind (("M-/" . dabbrev-completion)
("C-M-/" . dabbrev-expand))
;; Other useful Dabbrev configurations.
:custom
(dabbrev-ignored-buffer-regexps '("\\.\\(?:pdf\\|jpe?g\\|png\\)\\'"))
(dabbrev-case-replace nil))
(use-package consult
:bind (("C-x C-r" . consult-recent-file)
([remap switch-to-buffer] . consult-buffer)
([remap isearch-forward] . consult-line)
("C-x C-b" . consult-buffer)
("C-x C-i" . consult-imenu)
("C-c g" . consult-git-grep)
("M-y" . consult-yank-pop))
:hook (completion-list-mode . consult-preview-at-point-mode)
:custom
(xref-show-xrefs-function #'consult-xref)
(xref-show-definitions-function #'consult-xref))
(use-package consult-flycheck
:bind (("C-c C-e" . consult-flycheck)
("C-c e" . consult-flycheck)))
(use-package embark
:bind
(("C-." . embark-act) ;; pick some comfortable binding
("M-." . embark-dwim) ;; good alternative: M-.
([remap describe-bindings] . embark-bindings)) ;; alternative for `describe-bindings'
:init
(add-hook 'which-key-mode-hook (lambda () (setq prefix-help-command #'embark-prefix-help-command)))
;; (setq eldoc-documentation-strategy #'eldoc-documentation-compose-eagerly)
:config
;; Hide the mode line of the Embark live/completions buffers
(add-to-list 'display-buffer-alist
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
nil
(window-parameters (mode-line-format . none)))))
(use-package embark-consult :after (consult embark))
;;; Dired
(use-package dired-hide-dotfiles
:diminish
:bind (:map dired-mode-map (("." . dired-hide-dotfiles-mode)))
:hook (dired-mode . dired-hide-dotfiles-mode))
(use-package copilot
:hook (prog-mode . copilot-mode)
:bind (("C-M-;" . copilot-complete)
("TAB" . my/copilot-accept-completion)
("<backtab>" . copilot-next-completion))
:custom
(copilot-disable-predicates '((lambda () t)))
(copilot-node-executable (concat (asdf-where "nodejs" "20.6.1") "/bin/node"))
:commands copilot-accept-completion
:init
(defun my/copilot-accept-completion ()
(interactive)
(or (copilot-accept-completion)
(indent-for-tab-command))))
(use-package lsp-mode
:diminish
:custom
(lsp-solargraph-use-bundler t)
(lsp-keymap-prefix "C-c l")
:hook
(lsp-mode . lsp-enable-which-key-integration)
(lsp-mode . lsp-completion-mode)
((tsx-ts-mode typescript-ts-mode js-ts-mode) . lsp)
:autoload lsp-rename
:config
(setq read-process-output-max (* 1024 1024))
(custom-set-variables
'(lsp-disabled-clients '((tsx-ts-mode . graphql-lsp) (js-ts-mode . graphql-lsp) (typescript-ts-mode . graphql-lsp)))))
(use-package lsp-treemacs :defer t)
(use-package lsp-ui
:hook (lsp-mode . lsp-ui-mode)
:bind (:map lsp-ui-mode-map
([remap xref-find-definitions] . lsp-ui-peek-find-definitions)
([remap xref-find-references] . lsp-ui-peek-find-references))
:custom
(lsp-ui-sideline-show-code-actions t)
(lsp-ui-doc-show-with-cursor t)
:config
(require 'lsp-graphql))
(use-package string-inflection
:after lsp-mode
:autoload string-inflection-camelcase-function
:init
(with-eval-after-load 'lsp-mode
(defun lsp-rename-snake-to-camel ()
"Rename symbol from snake_case to camelCase."
(interactive)
(lsp-rename (string-inflection-camelcase-function (thing-at-point 'symbol))))))
;;; DAP
(use-package dape :defer t)
;;; git
(use-package magit
:custom (magit-repository-directories (list (cons (concat (getenv "HOME") "/repos/") 1)))
:bind (("C-x g" . magit-status)
([remap vc-dir] . magit-status)))
(use-package difftastic
:after magit
:disabled t
:config
(transient-append-suffix 'magit-diff '(-1 -1)
[("D" "Difftastic diff (dwim)" difftastic-magit-diff)
("S" "Difftastic show" difftastic-magit-show)]))
(use-package forge :after magit :custom (forge-topic-list-limit '(50 . 0)))
(use-package git-gutter :diminish)
(use-package git-gutter-fringe :after git-gutter :config (global-git-gutter-mode t))
(use-package code-review
:straight (:host github :repo "phelrine/code-review" :branch "fix/closql-update")
:defer t)
(use-package igist :custom (igist-current-user-name "phelrine") :commands igist-dispatch)
(use-package browse-at-remote :commands browse-at-remote)
;;; SQL
(use-package sql-ts-mode
:mode ("\\.sql\\'")
:load-path local-lisp-load-path
:hook (sql-ts-mode . (lambda ()
(setq lsp-enable-indentation nil)
(lsp)
(indent-tabs-mode t)))
:init
(put 'lsp-sqls-workspace-config-path 'safe-local-variable 'stringp))
;;; Terminal
(use-package bash-completion
:hook (eshell-mode . bash-completion-capf-nonexclusive)
:config
(bash-completion-setup))
(with-eval-after-load 'eshell
(eval-when-compile (require 'esh-mode))
(require 'pcmpl-gnu)
(bind-keys
:map eshell-mode-map
("C-r" . cape-history)))
(with-eval-after-load 'em-term
(eval-when-compile (require 'em-term))
(add-to-list 'eshell-visual-commands "tig"))
(use-package shell-pop
:custom
(shell-pop-shell-type '("eshell" "*eshell*" (lambda () (eshell))))
(shell-pop-window-size 30)
(shell-pop-window-position "bottom")
:bind (("C-M-p" . shell-pop)))
(use-package yasnippet :diminish yas-minor-mode :hook (prog-mode . yas-minor-mode))
(use-package popwin
:config
(popwin-mode 1)
(nconc popwin:special-display-config
'((" *auto-async-byte-compile*" :noselect t)
("*Warnings*" :noselect t)
("*Rubocopfmt Errors*" :noselect t))))
(use-package open-junk-file :commands open-junk-file)
(use-package solarized-theme :config (load-theme 'solarized-light t))
(use-package doom-modeline :custom (doom-modeline-minor-modes t) :hook (after-init . doom-modeline-mode))
(add-hook 'prog-mode-hook #'display-line-numbers-mode)
(use-package expand-region :bind ("C-M-SPC" . er/expand-region))
(use-package vundo :bind ("C-x u" . vundo))
(use-package volatile-highlights :diminish :hook (after-init . volatile-highlights-mode))
(use-package beacon :diminish beacon-mode :hook (after-init . beacon-mode) :custom (beacon-color "light green"))
(if (locate-library "skk-autoloads")
(bind-key "C-x j" 'skk-mode)
(use-package ddskk
:if (memq window-system '(mac ns x))
:custom (skk-use-jisx0201-input-method t)
:bind ("C-x j" . skk-mode)))
(use-package ddskk-posframe :after ddskk :diminish :config (ddskk-posframe-mode t))
;; flycheck
(use-package flycheck :hook (prog-mode . flycheck-mode) :diminish flycheck-mode :autoload flycheck-add-mode flycheck-add-next-checker)
(use-package flycheck-color-mode-line :hook (flycheck-mode . flycheck-color-mode-line-mode))
;; (use-package flycheck-deno
;; :after flycheck
;; :config
;; (flycheck-deno-setup)
;; (flycheck-add-mode 'deno-lint 'web-mode)
;; (flycheck-add-next-checker 'eglot-check 'deno-lint 'append))
(use-package flycheck-cfn :hook (cfn-mode . flycheck-cfn-setup))
(use-package flycheck-eglot :after (flycheck eglot) :config (global-flycheck-eglot-mode 1))
(use-package cov :custom (cov-coverage-mode t) :commands cov-mode)
(use-package fancy-compilation
:hook (compilation-mode . fancy-compilation-mode)
:custom (fancy-compilation-override-colors nil))
(use-package smartparens
:diminish
:hook
(after-init . smartparens-global-mode)
:config
(require 'smartparens-config))
(use-package rainbow-delimiters :hook (prog-mode . rainbow-delimiters-mode))
;;; Indent
(custom-set-variables
'(whitespace-display-mappings '((space-mark 12288 [9633]) (tab-mark 9 [187 9])))
'(whitespace-space-regexp "\\( +\\)")
'(whitespace-style '(face tabs tab-mark spaces space-mark))
'(whitespace-global-modes '(not dired-mode)))
(diminish 'global-whitespace-mode)
(global-whitespace-mode 1)
(add-hook 'before-save-hook #'delete-trailing-whitespace)
(add-hook 'change-major-mode-after-body-hook
(lambda ()
(when (cl-some #'derived-mode-p '(term-mode magit-popup-mode))
(setq-local show-trailing-whitespace nil))))
(add-hook 'minibuffer-setup-hook (lambda () (setq-local show-trailing-whitespace nil)))
(use-package highlight-indent-guides :diminish :if window-system :hook (prog-mode . highlight-indent-guides-mode))
(use-package indent-tools :bind ("C-c >" . indent-tools-hydra/body))
;;; treesit
(with-eval-after-load 'treesit
(eval-when-compile (require 'treesit))
(custom-set-variables '(treesit-font-lock-level 4))
(add-to-list 'treesit-language-source-alist '(prisma "https://github.com/victorhqc/tree-sitter-prisma")))
(use-package treesit-auto
:custom
(treesit-auto-install 'prompt)
:commands global-treesit-auto-mode treesit-auto-add-to-auto-mode-alist
:init
(global-treesit-auto-mode 1)
:config
(delete 'yaml treesit-auto-langs)
(treesit-auto-add-to-auto-mode-alist 'all))
;;; ChatGPT
(defun pick-openai-key ()
"Pick the OpenAI api key from auth source."
(auth-source-pick-first-password :host "api.openai.com"))
(use-package chatgpt-shell
:custom
((chatgpt-shell-openai-key (pick-openai-key))
(dall-e-shell-openai-key (pick-openai-key))))
(use-package copilot-chat
:custom
(copilot-chat-frontend 'shell-maker)
:config
(require 'copilot-chat-shell-maker)
(push '(shell-maker . copilot-chat-shell-maker-init) copilot-chat-frontend-list)
(copilot-chat-shell-maker-init))
(use-package org
:bind (("C-c l" . org-store-link)
("C-c a" . org-agenda)
("C-c c" . org-capture))
:config
(eval-when-compile
(require 'org)
(require 'org-capture))
(setq org-directory "~/Dropbox/org")
(defvar org-todo-file (concat org-directory "/todo.org"))
(defvar org-query-file (concat org-directory "/query.org"))
(setq org-agenda-files `(,org-todo-file))
(setq org-capture-templates
'(("t" "TODO" entry (file+headline org-todo-file "Tasks")
"** TODO %? \n" :prepend t)
("s" "SQL" entry (file+headline org-query-file "Queries")
"** %?%T\n#+name\n#+begin_src sql\n\n#+end_src\n" :prepend t)))
(use-package ob-typescript)
(org-babel-do-load-languages
'org-babel-load-languages
'((typescript . t)
(sql . t))))
(defun run-local-vars-mode-hook ()
"Run `major-mode' hook after the local variables have been processed."
(run-hooks (intern (concat (symbol-name major-mode) "-local-vars-hook"))))
(add-hook 'hack-local-variables-hook 'run-local-vars-mode-hook)
;;; Emacs Lisp
(add-hook 'emacs-lisp-mode-map-hook
(lambda ()
(add-to-list 'completion-at-point-functions #'cape-file)
(add-to-list 'completion-at-point-functions #'cape-elisp-symbol)
(add-to-list 'completion-at-point-functions #'cape-elisp-block)))
(use-package auto-async-byte-compile :hook (emacs-lisp-mode . enable-auto-async-byte-compile-mode) :disabled)
(use-package eros :hook (emacs-lisp-mode . eros-mode))
;;; Swift
(use-package swift-mode :defer t)
;;; Python
;;; Ruby
(add-hook 'ruby-ts-mode-hook #'eglot-ensure)
(use-package inf-ruby
:hook
((ruby-ts-mode . inf-ruby-minor-mode)
(compilation-filter . inf-ruby-auto-enter-and-focus)))
(use-package robe :hook (ruby-ts-mode . robe-mode))
(use-package rubocopfmt :hook (ruby-ts-mode . rubocopfmt-mode))
(use-package projectile-rails
:after (ruby-ts-mode projectile)
:bind (:map projectile-rails-mode-map
("C-c r" . hydra-projectile-rails/body)
("C-c f" . hydra-projectile-rails-find/body))
;; :hook (find-file . rails-project-find-file-hook)
:autoload projectile-rails-root
:config
(projectile-rails-global-mode t))
(use-package rake :custom (rake-completion-system 'default) :defer t)
(use-package rspec-mode :custom (rspec-key-command-prefix (kbd "C-c s")) :defer t)
(use-package bundler :defer t)
(use-package coverage :defer t)
;;; HAML
(use-package haml-mode :defer t)
(use-package flymake-haml :hook (haml-mode . flymake-haml-load))
;;; Go
(with-eval-after-load 'go-ts-mode
(custom-set-variables '(go-ts-mode-indent-offset tab-width))
(add-hook 'go-ts-mode-hook
(lambda ()
(subword-mode)
(lsp))))
;; https://github.com/golang/tools/blob/master/gopls/doc/emacs.md#configuring-project-for-go-modules-in-emacs
(defun project-find-go-module (dir)
"Search for go.mod file in DIR."
(when-let ((root (locate-dominating-file dir "go.mod")))
(cons 'go-module root)))
(with-eval-after-load 'project
(cl-defmethod project-root ((project (head go-module)))
"Return the root directory of a go module PROJECT."
(cdr project))
(add-hook 'project-find-functions #'project-find-go-module))
(use-package govet :commands govet)
(use-package gotest :defer t)
(use-package go-gen-test :defer t)
(use-package go-impl :commands go-impl)
(use-package go-tag
:bind (:map go-mode-map
("C-c `" . go-tag-add)
("C-u C-c `" . go-tag-remove)))
(use-package go-eldoc :after (go-mode eldoc) :hook (go-mode . go-eldoc-setup))
(use-package go-projectile :after (go-mode projectile))
(use-package go-playground :custom (go-playground-init-command "go mod init snippet") :commands go-playground)
(use-package flycheck-golangci-lint :hook (go-mode . flycheck-golangci-lint-setup))
(use-package go-fill-struct :commands go-fill-struct)
;;; Dart & Flutter
(use-package dart-mode :hook (dart-mode . (lambda () (subword-mode) (eglot-ensure))) :commands dart-mode)
(use-package flutter :after dart-mode)
;;; Gradle
(use-package groovy-mode :defer t)
;;; Web
(use-package web-mode
:custom
(web-mode-markup-indent-offset 2)
(web-mode-css-indent-offset 2)
(web-mode-code-indent-offset 2)
(web-mode-enable-auto-indentation nil)
(web-mode-auto-quote-style 3)
:mode "\\.html?\\'" "\\.erb\\'")
(add-hook 'js-ts-mode-hook
(lambda ()
(setq js-indent-level 2)
(setq tab-width 2)))
(defun kill-jest-process-and-buffer ()
"Kill jest process and buffer."
(interactive)
(delete-process (buffer-name (current-buffer)))
(kill-buffer))
(use-package jest :bind (:map jest-mode-map ("q" . kill-jest-process-and-buffer)))
(use-package vitest :load-path local-lisp-load-path)
(with-eval-after-load 'typescript-ts-mode
(add-hook 'typescript-ts-mode-hook
(lambda()
(cov-mode)
(setq-local cov-lcov-file-name (concat (projectile-project-root) "lcov.info"))
(jest-minor-mode 1))))
(use-package lsp-biome
:straight (:host github :repo "cxa/lsp-biome" :files ("lsp-biome.el"))
:custom
(lsp-biome-organize-imports-on-save t)
(lsp-biome-autofix-on-save t)
(lsp-biome-format-on-save t))
(with-eval-after-load 'compile
(defvar node-error-regexp "^[ ]+at \\(?:[^\(\n]+ \(\\)?\\([a-zA-Z\.0-9_/-]+\\):\\([0-9]+\\):\\([0-9]+\\)\)?$")
(add-to-list 'compilation-error-regexp-alist-alist `(nodejs ,node-error-regexp 1 2 3))
(add-to-list 'compilation-error-regexp-alist 'nodejs))
(use-package npm)
(use-package deno-fmt :defer t)
(use-package prisma-ts-mode
:mode (("\\.prisma\\'" . prisma-ts-mode))
:hook (prisma-ts-mode . eglot-ensure)
:ensure-system-package (prisma-language-server . "npm install -g @prisma/language-server")
:init
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs '(prisma-ts-mode . ("prisma-language-server" "--stdio")))))
(use-package restclient :commands restclient-mode
:config
(use-package restclient-jq))
(use-package graphql-ts-mode
:mode ("\\.graphql\\'" "\\.gql\\'")
:ensure-system-package (graphql-language-server . "npm i -g graphql-language-service-cli")
:init
(with-eval-after-load 'treesit
(add-to-list 'treesit-language-source-alist
'(graphql "https://github.com/bkegley/tree-sitter-graphql"))))
;;; Scheme
(defconst scheme-program-name "gosh -i")
(autoload 'scheme-mode "cmuscheme" "Major mode for Scheme." t)
(autoload 'run-scheme "cmuscheme" "Run an inferior Scheme process." t)
(defun scheme-other-window ()
"Run scheme on other window."
(interactive)
(switch-to-buffer-other-window
(get-buffer-create "*scheme*"))
(run-scheme scheme-program-name))
(defun scheme-mode-setup ()
"Set up scheme mode."
(local-set-key (kbd "C-c s") 'scheme-other-window))
(add-hook 'scheme-mode-hook 'scheme-mode-setup)
;;; Docker
(use-package docker
:custom
(docker-compose-command (or (and (eq system-type 'gnu/linux) "docker compose") "docker-compose"))
:ensure-system-package (docker-langserver . "npm install -g dockerfile-language-server-nodejs")
:bind
("C-c d" . docker)
("C-c C-d" . docker-compose))
(add-hook 'dockerfile-ts-mode-hook #'eglot-ensure)
(use-package docker-compose-mode
:hook (docker-compose-mode . eglot-ensure)
:ensure-system-package (docker-compose-langserver . "npm i -g @microsoft/compose-language-service")
:init
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs '(docker-compose-mode . ("docker-compose-langserver" "--stdio")))))
;;; Markdown
(use-package maple-preview
:straight (:host github :repo "honmaple/emacs-maple-preview" :files ("*.el" "index.html" "static"))
:defer t)
;;; AWS
(use-package aws-switch-profile
:defer t
:commands aws-switch-profile
:straight (:host github :repo "phelrine/aws-switch-profile.el" :files ("aws-switch-profile.el")))
(use-package aws-secretsmanager
:commands aws-secretsmanager-show-secrets-list
:straight (:host github :repo "phelrine/aws-secretsmanager.el" :files ("aws-secretsmanager.el")))
;;; config files
(use-package nginx-mode :mode "/nginx/sites-\\(?:available\\|enabled\\)/")
(use-package json-mode :defer t)
(use-package json-reformat :commands json-reformat-region)
(use-package cfn-mode :defer t)
(use-package lua-mode :defer t)
(use-package yaml-mode :defer t)
(use-package restart-emacs :commands restart-emacs)
(provide 'init)
;;; init.el ends here