feat(erlang): add treesit support

This commit is contained in:
Henrik Lissner
2025-08-27 17:19:08 +02:00
parent bee45157c6
commit 3d2abf8b05
3 changed files with 18 additions and 4 deletions

View File

@@ -5,9 +5,16 @@
:mode ("/rebar\\.config\\(?:\\.script\\)?\\'" . erlang-mode)
:mode ("/\\(?:app\\|sys\\)\\.config\\'" . erlang-mode)
:config
(set-formatter! 'erlfmt '("rebar3" "fmt" "-") :modes '(erlang-mode))
(set-formatter! 'erlfmt '("rebar3" "fmt" "-")
:modes '(erlang-mode erlang-ts-mode))
(when (modulep! +lsp)
(add-hook 'erlang-mode-local-vars-hook #'lsp! 'append))
(add-hook 'erlang-mode-local-vars-hook #'lsp! 'append)))
(when (modulep! +tree-sitter)
(add-hook 'erlang-mode-local-vars-hook #'tree-sitter! 'append)))
(use-package! erlang-ts
:when (modulep! +tree-sitter)
:when (fboundp 'erlang-ts-mode)
:defer t
:init
(set-tree-sitter! 'erlang-mode 'erlang-ts-mode
'((erlang "https://github.com/WhatsApp/tree-sitter-erlang"))))

View File

@@ -5,6 +5,10 @@
(modulep! :tools lsp))
"This module requires (:tools lsp)")
(assert! (or (not (modulep! +tree-sitter))
(modulep! :tools tree-sitter))
"This module requires (:tools tree-sitter)")
(when (modulep! :editor format)
(unless (and (executable-find "rebar3") (zerop (car (doom-call-process "rebar3" "fmt" "-v"))))
(warn! "Couldn't find erlfmt. Formatting will be disabled.")))

View File

@@ -2,3 +2,6 @@
;;; lang/erlang/packages.el
(package! erlang :pin "b9d3ec017da091168918a2901a1cef4cb062fd2a")
(when (modulep! +tree-sitter)
(package! erlang-ts :pin "eb579dd55fbb2cf721290939e7b3a50be19c0305"))