Last active
October 14, 2021 00:01
-
-
Save ananthakumaran/ed91ef5a7bbf679cdf13e8a65ea54abe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defface tree-sitter-hl-face:warning | |
'((default :inherit font-lock-warning-face)) | |
"Face for parser errors" | |
:group 'tree-sitter-hl-faces) | |
(defun hook/tree-sitter-common () | |
(unless font-lock-defaults | |
(setq font-lock-defaults '(nil))) | |
(setq tree-sitter-hl-use-font-lock-keywords nil) | |
(tree-sitter-mode +1) | |
(tree-sitter-hl-mode +1)) | |
(defun hook/elixir-tree-sitter () | |
(setq | |
tree-sitter-hl-default-patterns | |
(read | |
(concat | |
"[" | |
(s-replace "#match?" ".match?" | |
(f-read-text (expand-file-name "~/work/repos/tree-sitter-elixir/queries/highlights.scm"))) | |
"]"))) | |
(hook/tree-sitter-common)) | |
(use-package tree-sitter | |
:ensure t | |
:hook ((elixir-mode . hook/elixir-tree-sitter)) | |
:custom-face | |
(tree-sitter-hl-face:operator ((t))) | |
(tree-sitter-hl-face:variable ((t))) | |
(tree-sitter-hl-face:function.method.call ((t))) | |
(tree-sitter-hl-face:property ((t))) | |
:config | |
(setq tree-sitter-debug-highlight-jump-region t) | |
(setq tree-sitter-debug-jump-buttons t)) | |
(use-package tree-sitter-langs | |
:ensure t | |
:after tree-sitter | |
:config | |
(add-to-list 'tree-sitter-major-mode-language-alist '(elixir-mode . elixir))) | |
(provide 'init-tree-sitter) |
I'd love to help test this out, but I am using doom. Given Doom has very specific loading requirements, would it be possible to make a version that works for doom? 🤞
I don't personally use doom, but if you can get tree-sitter working for any language, then adding support for elixir should be straightforward.
@jsmestad
Here is my tree-sitter config with doom emacs:
(use-package! tree-sitter
:init
(defface tree-sitter-hl-face:warning
'((default :inherit font-lock-warning-face))
"Face for parser errors"
:group 'tree-sitter-hl-faces)
(defun hook/tree-sitter-common ()
(unless font-lock-defaults
(setq font-lock-defaults '(nil)))
(setq tree-sitter-hl-use-font-lock-keywords nil)
(tree-sitter-mode +1)
(tree-sitter-hl-mode +1))
(defun hook/elixir-tree-sitter ()
(require 'f)
(require 's)
(setq tree-sitter-hl-default-patterns
(read
(concat
"["
(s-replace "#match?" ".match?"
(f-read-text (expand-file-name "~/Projects/ananthakumaran/tree-sitter-elixir/queries/highlights.scm")))
"]")))
(hook/tree-sitter-common))
:hook ((elixir-mode . hook/elixir-tree-sitter))
:custom-face
(tree-sitter-hl-face:operator ((t)))
(tree-sitter-hl-face:variable ((t)))
(tree-sitter-hl-face:function.method.call ((t)))
(tree-sitter-hl-face:property ((t))))
(use-package! tree-sitter-langs
:after tree-sitter
:config
(add-to-list 'tree-sitter-major-mode-language-alist '(elixir-mode . elixir)))
From my quick testing, everything works well
Thanks that worked perfectly!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd love to help test this out, but I am using doom. Given Doom has very specific loading requirements, would it be possible to make a version that works for doom? 🤞