Is there a from-zero set of instructions to get Emacs going with julia-ts-mode?

I am afraid I’ve gotten very rusty on Emacs. :frowning:

1 Like

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:

  1. 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)
  1. 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$")
  1. 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))
  1. Navigate to a julia file with extension .jl using C-x C-f. Respond “yes” to the prompt about installing treesitter grammar, and you should be editing using julia-ts-mode.
1 Like

Thank you, that is helpful. I’m still getting an error though:
image

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.

Thanks! Still errors:

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:

https://github.com/JuliaBinaryWrappers/tree_sitter_julia_jll.jl/releases/download/tree_sitter_julia-v0.19.0%2B0/tree_sitter_julia.v0.19.0.x86_64-w64-mingw32.tar.gz

Okay, you have two options:

  1. Install a C/C++ compiler and a linker such as mingw-w64. Then make sure that it’s on emacs variable exec-path (either inspect exec-path before installing, and install somewhere already on the path or add the location the compiler is installed to exec-path). After this, treesit-auto should automatically install the julia grammar when opening a julia file.
  2. Download an already-compiled grammar from a trusted source and manually install it. For example:
    1. Grab the appropriate asset for the most recent release of the tree_sitter_julia jll (probably x86_64-w64-mingw32).
    2. Extract the gzipped asset (may need to install something on windows to do this).
    3. Move libtreesitter_julia.dll from the bin directory of the extracted asset to .emac.d/tree-sitter
    4. Rename libtreesitter_julia.dll to libtree-sitter-julia.dll.
    5. Remove the treesit-auto use-package form from your init.el.
1 Like

Thank you so much. I don’t know how I would have figured this out without losing patience with the whole process.

P