mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
feat(elixir): add treesit support
This commit is contained in:
@ -11,11 +11,11 @@ This module provides support for [[https://elixir-lang.org/][Elixir programming
|
|||||||
|
|
||||||
** Module flags
|
** Module flags
|
||||||
- +lsp ::
|
- +lsp ::
|
||||||
Enable LSP support for ~elixir-mode~. Requires [[doom-module::tools lsp]] and a langserver
|
Enable LSP support for ~elixir-mode~. Requires [[doom-module::tools lsp]] and a
|
||||||
(supports [[https://github.com/elixir-lsp/elixir-ls/][elixir-ls]]).
|
langserver (supports [[https://github.com/elixir-lsp/elixir-ls/][elixir-ls]]).
|
||||||
- +tree-sitter ::
|
- +tree-sitter ::
|
||||||
Leverages tree-sitter for better syntax highlighting and structural text
|
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
|
** Packages
|
||||||
- [[doom-package:elixir-mode]]
|
- [[doom-package:elixir-mode]]
|
||||||
|
@ -8,14 +8,8 @@
|
|||||||
;;
|
;;
|
||||||
;;; Packages
|
;;; Packages
|
||||||
|
|
||||||
(use-package! elixir-mode
|
(defun +elixir-common-config (mode)
|
||||||
:defer t
|
(set-ligatures! mode
|
||||||
: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
|
|
||||||
;; Functional
|
;; Functional
|
||||||
:def "def"
|
:def "def"
|
||||||
:lambda "fn"
|
:lambda "fn"
|
||||||
@ -29,7 +23,7 @@
|
|||||||
:return "return" :yield "use")
|
:return "return" :yield "use")
|
||||||
|
|
||||||
;; ...and only complete the basics
|
;; ...and only complete the basics
|
||||||
(sp-with-modes 'elixir-mode
|
(sp-with-modes mode
|
||||||
(sp-local-pair "do" "end"
|
(sp-local-pair "do" "end"
|
||||||
:when '(("RET" "<evil-ret>"))
|
:when '(("RET" "<evil-ret>"))
|
||||||
:unless '(sp-in-comment-p sp-in-string-p)
|
:unless '(sp-in-comment-p sp-in-string-p)
|
||||||
@ -37,16 +31,22 @@
|
|||||||
(sp-local-pair "do " " end" :unless '(sp-in-comment-p sp-in-string-p))
|
(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)))
|
(sp-local-pair "fn " " end" :unless '(sp-in-comment-p sp-in-string-p)))
|
||||||
|
|
||||||
(when (modulep! +lsp +tree-sitter)
|
(when (modulep! +lsp)
|
||||||
(add-hook 'elixir-ts-mode-local-vars-hook #'lsp! 'append))
|
(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)
|
(when (modulep! +lsp)
|
||||||
(add-hook 'elixir-mode-local-vars-hook #'lsp! 'append)
|
|
||||||
(after! lsp-mode
|
(after! lsp-mode
|
||||||
(add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]_build\\'")))
|
(add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]_build\\'")))
|
||||||
|
:config
|
||||||
(when (modulep! +tree-sitter)
|
(+elixir-common-config 'elixir-mode)
|
||||||
(add-hook 'elixir-mode-local-vars-hook #'tree-sitter! 'append))
|
|
||||||
|
|
||||||
(after! highlight-numbers
|
(after! highlight-numbers
|
||||||
(puthash 'elixir-mode
|
(puthash 'elixir-mode
|
||||||
@ -54,6 +54,29 @@
|
|||||||
highlight-numbers-modelist)))
|
highlight-numbers-modelist)))
|
||||||
|
|
||||||
|
|
||||||
|
(use-package! elixir-ts-mode
|
||||||
|
:when (modulep! +tree-sitter)
|
||||||
|
:when (fboundp 'elixir-ts-mode) ; 30.1+ only
|
||||||
|
:defer t
|
||||||
|
:init
|
||||||
|
(set-tree-sitter! 'elixir-mode 'elixir-ts-mode
|
||||||
|
'((elixir :url "https://github.com/elixir-lang/tree-sitter-elixir"
|
||||||
|
:rev "v0.3.3")
|
||||||
|
(heex :url "https://github.com/phoenixframework/tree-sitter-heex"
|
||||||
|
:rev "v0.7.0")))
|
||||||
|
:config
|
||||||
|
;; HACK: Rely on `major-mode-remap-defaults'.
|
||||||
|
(cl-callf2 rassq-delete-all 'php-ts-mode auto-mode-alist)
|
||||||
|
|
||||||
|
(+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
|
(use-package! flycheck-credo
|
||||||
:when (modulep! :checkers syntax -flymake)
|
:when (modulep! :checkers syntax -flymake)
|
||||||
:after elixir-mode
|
:after elixir-mode
|
||||||
|
@ -4,3 +4,7 @@
|
|||||||
(assert! (or (not (modulep! +tree-sitter))
|
(assert! (or (not (modulep! +tree-sitter))
|
||||||
(modulep! :tools tree-sitter))
|
(modulep! :tools tree-sitter))
|
||||||
"This module requires (: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")
|
||||||
|
@ -26,10 +26,8 @@
|
|||||||
(css "https://github.com/tree-sitter/tree-sitter-css" nil nil nil nil)
|
(css "https://github.com/tree-sitter/tree-sitter-css" nil nil nil nil)
|
||||||
(dart "https://github.com/ast-grep/tree-sitter-dart" nil nil nil nil)
|
(dart "https://github.com/ast-grep/tree-sitter-dart" nil nil nil nil)
|
||||||
(dockerfile "https://github.com/camdencheek/tree-sitter-dockerfile" nil nil nil nil)
|
(dockerfile "https://github.com/camdencheek/tree-sitter-dockerfile" nil nil nil nil)
|
||||||
(elixir "https://github.com/elixir-lang/tree-sitter-elixir" nil nil nil nil)
|
|
||||||
(go "https://github.com/tree-sitter/tree-sitter-go" nil nil nil nil)
|
(go "https://github.com/tree-sitter/tree-sitter-go" nil nil nil nil)
|
||||||
(gomod "https://github.com/camdencheek/tree-sitter-go-mod" nil nil nil nil)
|
(gomod "https://github.com/camdencheek/tree-sitter-go-mod" nil nil nil nil)
|
||||||
(heex "https://github.com/phoenixframework/tree-sitter-heex" nil nil nil nil)
|
|
||||||
(html "https://github.com/tree-sitter/tree-sitter-html" nil nil nil nil)
|
(html "https://github.com/tree-sitter/tree-sitter-html" nil nil nil nil)
|
||||||
(java "https://github.com/tree-sitter/tree-sitter-java" nil nil nil nil)
|
(java "https://github.com/tree-sitter/tree-sitter-java" nil nil nil nil)
|
||||||
(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "master" "src" nil nil)
|
(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "master" "src" nil nil)
|
||||||
|
Reference in New Issue
Block a user