merge: branch 'feature/treesit'

Fix: #7742
Fix: #7623
Fix: #7593
This commit is contained in:
Henrik Lissner
2025-08-31 14:55:37 +02:00
120 changed files with 1513 additions and 1069 deletions

View File

@@ -11,11 +11,11 @@ This module provides support for [[https://elixir-lang.org/][Elixir programming
** Module flags
- +lsp ::
Enable LSP support for ~elixir-mode~. Requires [[doom-module::tools lsp]] and a langserver
(supports [[https://github.com/elixir-lsp/elixir-ls/][elixir-ls]]).
Enable LSP support for ~elixir-mode~. Requires [[doom-module::tools lsp]] and a
langserver (supports [[https://github.com/elixir-lsp/elixir-ls/][elixir-ls]]).
- +tree-sitter ::
Leverages tree-sitter for better syntax highlighting and structural text
editing. Requires [[doom-module::tools tree-sitter]].
editing. Requires Emacs 30.1+ and [[doom-module::tools tree-sitter]].
** Packages
- [[doom-package:elixir-mode]]

View File

@@ -8,14 +8,8 @@
;;
;;; Packages
(use-package! elixir-mode
:defer t
:init
;; Disable default smartparens config. There are too many pairs; we only want
;; a subset of them (defined below).
(provide 'smartparens-elixir)
:config
(set-ligatures! 'elixir-mode
(defun +elixir-common-config (mode)
(set-ligatures! mode
;; Functional
:def "def"
:lambda "fn"
@@ -29,7 +23,7 @@
:return "return" :yield "use")
;; ...and only complete the basics
(sp-with-modes 'elixir-mode
(sp-with-modes mode
(sp-local-pair "do" "end"
:when '(("RET" "<evil-ret>"))
:unless '(sp-in-comment-p sp-in-string-p)
@@ -37,16 +31,41 @@
(sp-local-pair "do " " end" :unless '(sp-in-comment-p sp-in-string-p))
(sp-local-pair "fn " " end" :unless '(sp-in-comment-p sp-in-string-p)))
(when (modulep! +lsp +tree-sitter)
(add-hook 'elixir-ts-mode-local-vars-hook #'lsp! 'append))
(when (modulep! +lsp)
(add-hook (intern (format "%s-local-vars-hook" mode)) #'lsp! 'append)))
(use-package! elixir-mode
:defer t
:init
;; Disable default smartparens config. There are too many pairs; we only want
;; a subset of them (defined below).
(provide 'smartparens-elixir)
(when (modulep! +lsp)
(add-hook 'elixir-mode-local-vars-hook #'lsp! 'append)
(after! lsp-mode
(add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]_build\\'")))
:config
(+elixir-common-config 'elixir-mode))
(when (modulep! +tree-sitter)
(add-hook 'elixir-mode-local-vars-hook #'tree-sitter! 'append)))
(use-package! elixir-ts-mode ; 30.1+ only
:when (modulep! +tree-sitter)
:defer t
:init
(set-tree-sitter! 'elixir-mode 'elixir-ts-mode
'((elixir :url "https://github.com/elixir-lang/tree-sitter-elixir"
:commit "02a6f7fd4be28dd94ee4dd2ca19cb777053ea74e")
(heex :url "https://github.com/phoenixframework/tree-sitter-heex"
:commit "f6b83f305a755cd49cf5f6a66b2b789be93dc7b9")))
:config
(+elixir-common-config 'elixir-ts-mode))
(use-package! heex-ts-mode
:when (modulep! +tree-sitter)
:when (fboundp 'heex-ts-mode) ; 30.1+ only
:mode "\\.[hl]?eex\\'")
(use-package! flycheck-credo

View File

@@ -4,3 +4,7 @@
(assert! (or (not (modulep! +tree-sitter))
(modulep! :tools tree-sitter))
"This module requires (:tools tree-sitter)")
(assert! (or (not (modulep! +tree-sitter))
(fboundp 'elixir-ts-mode))
"Can't find `elixir-ts-mode'; Emacs 30.1+ is required")