-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.el
More file actions
197 lines (168 loc) · 7.89 KB
/
config.el
File metadata and controls
197 lines (168 loc) · 7.89 KB
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
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
;; ---------------------------------------------------------------------------
;; PERSONAL IDENTITY & VISUALS
;; ---------------------------------------------------------------------------
(setq user-full-name "Tom Ridge"
user-mail-address "tomridge2@gmail.com")
(setq doom-theme 'doom-one)
(setq display-line-numbers-type t)
(setq org-directory "~/org/")
;; Set Font size
(setq doom-font (font-spec :family "Fira Code" :size 14)
doom-big-font (font-spec :family "Fira Code" :size 24)
doom-variable-pitch-font (font-spec :family "Ubuntu" :size 16))
;; Performance tweaks for bidirectional text
(setq-default bidi-display-reordering nil
bidi-paragraph-direction 'left-to-right)
(setq bidi-inhibit-bpa t)
;; ---------------------------------------------------------------------------
;; PROJECTILE
;; ---------------------------------------------------------------------------
(setq projectile-project-search-path '(("~/projects/" . 2))
projectile-auto-update-cache t
projectile-indexing-method 'hybrid)
;; ---------------------------------------------------------------------------
;; GLOBAL LSP CONFIGURATION (General UI & Performance)
;; ---------------------------------------------------------------------------
(after! lsp-mode
(setq lsp-lens-enable t
lsp-ui-peek-enable t
lsp-ui-doc-enable nil
lsp-ui-doc-position 'bottom
lsp-ui-doc-max-height 70
lsp-ui-doc-max-width 150
lsp-ui-sideline-show-diagnostics t
lsp-ui-sideline-show-hover nil
lsp-ui-sideline-show-code-actions t
lsp-ui-sideline-diagnostic-max-lines 20
lsp-ui-sideline-ignore-duplicate t
lsp-ui-sideline-enable t)
(setq lsp-file-watch-ignored
'(".idea" ".ensime_cache" ".eunit" "node_modules"
".git" ".hg" ".fslckout" "_FOSSIL_"
".bzr" "_darcs" ".tox" ".svn" ".stack-work"
"build" "_build" "deps" "postgres-data")))
;; ---------------------------------------------------------------------------
;; ELIXIR & HEEX CONFIGURATION
;; ---------------------------------------------------------------------------
;; Enable LSP for Elixir and HEEx Tree-sitter modes
(add-hook 'elixir-ts-mode-hook #'lsp-deferred)
(add-hook 'heex-ts-mode-hook #'lsp-deferred)
;; ElixirLS Specific Settings
(setq lsp-elixir-suggest-specs t
lsp-elixir-dialyzer-enabled t
lsp-elixir-signature-after-complete t
lsp-elixir-enable-test-lenses t)
;; Workaround to enable running credo after lsp
(defvar-local my/flycheck-local-cache nil)
(defun my/flycheck-checker-get (fn checker property)
(or (alist-get property (alist-get checker my/flycheck-local-cache))
(funcall fn checker property)))
(advice-add 'flycheck-checker-get :around 'my/flycheck-checker-get)
(add-hook 'lsp-managed-mode-hook
(lambda ()
(when (derived-mode-p 'elixir-mode 'elixir-ts-mode)
(setq my/flycheck-local-cache '((lsp . ((next-checkers . (elixir-credo)))))))))
;; Fix duplicate "end" insertion in all Elixir modes
(after! smartparens
(dolist (mode '(elixir-mode elixir-ts-mode))
(sp-local-pair mode "for" "end" :actions nil)
(sp-local-pair mode "if" "end" :actions nil)
(sp-local-pair mode "case" "end" :actions nil)
(sp-local-pair mode "cond" "end" :actions nil)
(sp-local-pair mode "unless" "end" :actions nil)
(sp-local-pair mode "with" "end" :actions nil)
(sp-local-pair mode "try" "end" :actions nil)
(sp-local-pair mode "fn" "end" :actions nil)
(sp-local-pair mode "do" "end" :actions nil)
(sp-local-pair mode "def" "end" :actions nil)
(sp-local-pair mode "defp" "end" :actions nil)
(sp-local-pair mode "defmodule" "end" :actions nil)
(sp-local-pair mode "defimpl" "end" :actions nil)))
;; ---------------------------------------------------------------------------
;; WEB, TAILWIND & EMMET
;; ---------------------------------------------------------------------------
(use-package! lsp-tailwindcss
:init (setq lsp-tailwindcss-add-on-mode t))
(after! web-mode
(setq web-mode-enable-auto-pairing t
web-mode-enable-css-colorization t
web-mode-engines-alist nil))
(use-package! emmet-mode
:hook (elixir-ts-mode . emmet-mode)
:config
(add-to-list 'emmet-jsx-major-modes 'elixir-ts-mode)
(setq emmet-expand-jsx-className? nil
emmet-move-cursor-between-quotes t))
;; Emmet: Replace className with class in Elixir files
(defadvice! +emmet-elixir-classname-to-class-a (fn &rest args)
:around #'emmet-make-html-tag
(let ((result (apply fn args)))
(if (derived-mode-p 'elixir-ts-mode)
(replace-regexp-in-string " className=" " class=" result)
result)))
(after! elixir-ts-mode
(set-company-backend! 'elixir-ts-mode
'(:separate company-emmet company-yasnippet company-capf))
;; Bind TAB to indent/expand
(map! :map elixir-ts-mode-map
:i [tab] #'+web/indent-or-yas-or-emmet-expand
:i "TAB" #'+web/indent-or-yas-or-emmet-expand))
;; ---------------------------------------------------------------------------
;; TREE-SITTER TEXT OBJECTS & EVIL
;; ---------------------------------------------------------------------------
(require 'treesit)
(global-evil-matchit-mode 1)
;; Define Elixir "do...end" block selection
(defun +elixir/inner-do-block (count &optional beg end type)
"Select the inner content of an Elixir do...end block."
(interactive "p")
(when-let* ((node (treesit-node-at (point)))
(do-node (treesit-parent-until node (lambda (n) (equal (treesit-node-type n) "do_block")))))
(let* ((children (treesit-node-children do-node))
(start (treesit-node-end (car children)))
(end (treesit-node-start (car (last children)))))
(evil-range start end))))
(defun +elixir/outer-do-block (count &optional beg end type)
"Select the entire Elixir do...end block."
(interactive "p")
(when-let* ((node (treesit-node-at (point)))
(do-node (treesit-parent-until node (lambda (n) (equal (treesit-node-type n) "do_block")))))
(evil-range (treesit-node-start do-node) (treesit-node-end do-node))))
;; Bindings for Elixir blocks and generic Tree-sitter calls
(after! elixir-ts-mode
(map! :map elixir-ts-mode-map :textobj "b" #'+elixir/inner-do-block #'+elixir/outer-do-block)
(define-key evil-inner-text-objects-map "b" #'+elixir/inner-do-block)
(define-key evil-outer-text-objects-map "b" #'+elixir/outer-do-block))
(after! evil-textobj-tree-sitter
(define-key evil-inner-text-objects-map "g" (evil-textobj-tree-sitter-get-textobj "call.outer"))
(define-key evil-outer-text-objects-map "g" (evil-textobj-tree-sitter-get-textobj "call.outer")))
;; ---------------------------------------------------------------------------
;; OTHER LANGUAGES
;; ---------------------------------------------------------------------------
(setq org-babel-python-command "python3")
;; roblox luau
;; (after! projectile
;; (projectile-register-project-type 'roblox-luau
;; '("default.project.json")
;; :project-file "default.project.json"
;; :compile "lune run build"
;; :test "lune run test"
;; ;; Changed :run to :run-command for compatibility
;; :run-command "rojo serve"
;; :src-dir "src/"))
(use-package! eglot-luau
:after eglot
:init
(setq eglot-luau-rojo-sourcemap-enabled t
eglot-luau-rojo-sourcemap-includes-non-scripts t
eglot-luau-auto-update-roblox-docs t
eglot-luau-auto-update-roblox-types t
eglot-luau-fflag-overrides '(("LuauSolverV2" "True")))
:hook
(lua-mode . eglot-luau-setup)
(lua-mode . eglot-ensure))
(add-to-list 'auto-mode-alist '("\\.luau\\'" . lua-mode))
;; (use-package! mise
;; :config
;; (add-hook 'after-init-hook #'global-mise-mode))