I am afraid I’ve gotten very rusty on Emacs.
Could you clarify where you’re getting stuck? To me, the julia-ts-mode README is fairly clear. I can’t test this because I don’t have an emacs installation with internet access at the moment, but it should be as simple as:
- Install MELPA by adding this snippet to your config file:
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Comment/uncomment this line to enable MELPA Stable if desired. See `package-archive-priorities`
;; and `package-pinned-packages`. Most users will not need or want to do this.
;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)
- Install julia-ts-mode by adding the snippet from the README (I believe this should just work in emacs 29 since
use-package
is now included in emacs):
(use-package julia-ts-mode
:ensure t
:mode "\\.jl$")
- Install and configure
treesit-auto
package using the example configuration from its README by adding:
(use-package treesit-auto
:custom
(treesit-auto-install 'prompt)
:config
(treesit-auto-add-to-auto-mode-alist 'all)
(global-treesit-auto-mode))
- Navigate to a julia file with extension
.jl
usingC-x C-f
. Respond “yes” to the prompt about installing treesitter grammar, and you should be editing usingjulia-ts-mode
.
Thank you, that is helpful. I’m still getting an error though:
It would be helpful to see a complete init.el file that has the moving parts in the right order.
I think you were probably just missing a :ensure t
for treesit-auto
. Sorry about that. I don’t personally use use-package
, so I missed that detail. I just tested the following in init.el with a fresh --init-directory
, and it worked as expected:
;;; init.el --- My emacs config -*- lexical-bindings:t -*-
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(use-package julia-ts-mode
:ensure t
:mode "\\.jl$")
(use-package treesit-auto
:ensure t
:custom
(treesit-auto-install 'prompt)
:config
(treesit-auto-add-to-auto-mode-alist 'all)
(global-treesit-auto-mode))
I should note that if you had followed the directions in the treesit-auto
README instead of my bastardization of them above, everything should have worked properly. All issues are with my reading comprehension rather than with upstream documentation.
Looks like treesit-auto
tries to build the tree-sitter grammar from source which doesn’t work on Windows without quite a bit of effort to setup a proper build toolchain. The path forward is probably to manually install the already-built grammar dll. I’d need to lookup how to do so, but you can probably use the binary from the jll:
Okay, you have two options:
- Install a C/C++ compiler and a linker such as mingw-w64. Then make sure that it’s on emacs variable
exec-path
(either inspectexec-path
before installing, and install somewhere already on the path or add the location the compiler is installed toexec-path
). After this,treesit-auto
should automatically install the julia grammar when opening a julia file. - Download an already-compiled grammar from a trusted source and manually install it. For example:
- Grab the appropriate asset for the most recent release of the tree_sitter_julia jll (probably
x86_64-w64-mingw32
). - Extract the gzipped asset (may need to install something on windows to do this).
- Move
libtreesitter_julia.dll
from thebin
directory of the extracted asset to.emac.d/tree-sitter
- Rename
libtreesitter_julia.dll
tolibtree-sitter-julia.dll
. - Remove the
treesit-auto
use-package
form from yourinit.el
.
- Grab the appropriate asset for the most recent release of the tree_sitter_julia jll (probably
Thank you so much. I don’t know how I would have figured this out without losing patience with the whole process.
P