feat(julia): add treesit support

This commit is contained in:
Henrik Lissner
2025-05-08 01:18:07 -04:00
parent e6caaef9e6
commit 46b87362f7
4 changed files with 23 additions and 9 deletions

View File

@ -15,11 +15,11 @@ This module adds support for [[https://julialang.org/][the Julia language]] to D
** Module flags ** Module flags
- +lsp :: - +lsp ::
Enable LSP support for ~julia-mode~. Requires [[doom-module::tools lsp]] and a langserver Enable LSP support for ~julia-mode~. Requires [[doom-module::tools lsp]] and a
(supports LanguageServer.jl). langserver (supports LanguageServer.jl).
- +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 >=29 and [[doom-module::tools tree-sitter]].
- +snail :: - +snail ::
Use Snail, a development environment and REPL interaction package for Julia in Use Snail, a development environment and REPL interaction package for Julia in
the spirit of Common Lisps SLIME and Clojures CIDER. It enables convenient the spirit of Common Lisps SLIME and Clojures CIDER. It enables convenient

View File

@ -4,14 +4,11 @@
:interpreter "julia" :interpreter "julia"
:config :config
(unless (modulep! +snail) (unless (modulep! +snail)
(set-repl-handler! 'julia-mode #'+julia/open-repl)) (set-repl-handler! '(julia-mode julia-ts-mode) #'+julia/open-repl))
(when (modulep! +lsp) (when (modulep! +lsp)
(add-hook 'julia-mode-local-vars-hook #'lsp! 'append)) (add-hook 'julia-mode-local-vars-hook #'lsp! 'append))
(when (modulep! +tree-sitter)
(add-hook 'julia-mode-local-vars-hook #'tree-sitter! 'append))
;; Borrow matlab.el's fontification of math operators. From ;; Borrow matlab.el's fontification of math operators. From
;; <https://web.archive.org/web/20170326183805/https://ogbe.net/emacsconfig.html> ;; <https://web.archive.org/web/20170326183805/https://ogbe.net/emacsconfig.html>
(dolist (mode '(julia-mode ess-julia-mode)) (dolist (mode '(julia-mode ess-julia-mode))
@ -47,9 +44,22 @@
1 font-lock-type-face))))) 1 font-lock-type-face)))))
(use-package! julia-ts-mode
:when (modulep! +tree-sitter)
:defer t
:init
(set-tree-sitter! 'julia-mode 'julia-ts-mode
'((julia :url "https://github.com/tree-sitter/tree-sitter-julia"
:rev "v0.23.1")))
:config
(when (modulep! +lsp)
(add-hook 'julia-ts-mode-local-vars-hook #'lsp! 'append)))
(use-package! julia-repl (use-package! julia-repl
:preface (defvar +julia-repl-start-hook nil) :preface (defvar +julia-repl-start-hook nil)
:hook (julia-mode . julia-repl-mode) :hook (julia-mode . julia-repl-mode)
:hook (julia-ts-mode . julia-repl-mode)
:hook (+julia-repl-start . +julia-override-repl-escape-char-h) :hook (+julia-repl-start . +julia-override-repl-escape-char-h)
:hook (+julia-repl-start . julia-repl-use-emacsclient) :hook (+julia-repl-start . julia-repl-use-emacsclient)
:config :config
@ -95,7 +105,8 @@
:after eglot :after eglot
:init :init
;; Prevent timeout while installing LanguageServer.jl ;; Prevent timeout while installing LanguageServer.jl
(setq-hook! 'julia-mode-hook eglot-connect-timeout (max eglot-connect-timeout 60)) (setq-hook! '(julia-mode-hook julia-ts-mode-hook)
eglot-connect-timeout (max eglot-connect-timeout 60))
:config (eglot-jl-init)) :config (eglot-jl-init))
@ -103,6 +114,7 @@
:when (modulep! +snail) :when (modulep! +snail)
:when (modulep! :term vterm) :when (modulep! :term vterm)
:hook (julia-mode . julia-snail-mode) :hook (julia-mode . julia-snail-mode)
:hook (julia-ts-mode . julia-snail-mode)
:config :config
(set-popup-rule! "^\\*julia.*\\*$" :ttl nil :select nil :quit nil) (set-popup-rule! "^\\*julia.*\\*$" :ttl nil :select nil :quit nil)

View File

@ -4,6 +4,9 @@
(package! julia-mode :pin "5c940c4ba357d8361534f11169f3d40b2d7833fc") (package! julia-mode :pin "5c940c4ba357d8361534f11169f3d40b2d7833fc")
(package! julia-repl :pin "317d56021889a336b4be241604ba71e46dc80581") (package! julia-repl :pin "317d56021889a336b4be241604ba71e46dc80581")
(when (modulep! +tree-sitter)
(package! julia-ts-mode :pin "d693c6b35d3aed986b2700a3b5f910de12d6c53c"))
(when (modulep! +lsp) (when (modulep! +lsp)
(if (modulep! :tools lsp +eglot) (if (modulep! :tools lsp +eglot)
(package! eglot-jl :pin "7c968cc61fb64016ebe6dc8ff83fd05923db4374") (package! eglot-jl :pin "7c968cc61fb64016ebe6dc8ff83fd05923db4374")

View File

@ -38,7 +38,6 @@
(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)
(json "https://github.com/tree-sitter/tree-sitter-json" nil nil nil nil) (json "https://github.com/tree-sitter/tree-sitter-json" nil nil nil nil)
(julia "https://github.com/tree-sitter/tree-sitter-julia" nil nil nil nil)
(kotlin "https://github.com/fwcd/tree-sitter-kotlin" nil nil nil nil) (kotlin "https://github.com/fwcd/tree-sitter-kotlin" nil nil nil nil)
(latex "https://github.com/latex-lsp/tree-sitter-latex" nil nil nil nil) (latex "https://github.com/latex-lsp/tree-sitter-latex" nil nil nil nil)
(make "https://github.com/tree-sitter-grammars/tree-sitter-make" nil nil nil nil) (make "https://github.com/tree-sitter-grammars/tree-sitter-make" nil nil nil nil)