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

**URL:** <https://discourse.julialang.org/t/is-there-a-from-zero-set-of-instructions-to-get-emacs-going-with-julia-ts-mode/109031>\
**Category:** Tooling\
**Created:** [January 19, 2024, 11:40pm UTC](https://discourse.julialang.org/t/is-there-a-from-zero-set-of-instructions-to-get-emacs-going-with-julia-ts-mode/109031 "2024-01-19T23:40:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [January 19, 2024, 11:40pm UTC](https://discourse.julialang.org/t/is-there-a-from-zero-set-of-instructions-to-get-emacs-going-with-julia-ts-mode/109031/1 "2024-01-19T23:40:57Z")

</div>

I am afraid I’ve gotten very rusty on Emacs. ☹

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [January 22, 2024, 8:12pm UTC](https://discourse.julialang.org/t/is-there-a-from-zero-set-of-instructions-to-get-emacs-going-with-julia-ts-mode/109031/2 "2024-01-22T20:12:30Z")

</div>

Could you clarify where you’re getting stuck? To me, [the julia-ts-mode README](https://github.com/ronisbr/julia-ts-mode#installation) 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](https://melpa.org/#/getting-started) by adding this snippet to your config file:

```elisp
(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):

```elisp
(use-package julia-ts-mode
  :ensure t
  :mode "\\.jl$")

```

1. Install and configure `treesit-auto` package using [the example configuration from its README](https://github.com/renzmann/treesit-auto#configuration-example) by adding:

```elisp
(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`.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [January 22, 2024, 8:23pm UTC](https://discourse.julialang.org/t/is-there-a-from-zero-set-of-instructions-to-get-emacs-going-with-julia-ts-mode/109031/3 "2024-01-22T20:23:04Z")

</div>

Thank you, that is helpful. I’m still getting an error though:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/4/94c33621656c87985e28536f38253b3e27d4e596.png)

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/2/b2c6df89f298a76060c54a7d981db2f26fe4e28d.png)

It would be helpful to see a complete init.el file that has the moving parts in the right order.

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [January 22, 2024, 9:24pm UTC](https://discourse.julialang.org/t/is-there-a-from-zero-set-of-instructions-to-get-emacs-going-with-julia-ts-mode/109031/4 "2024-01-22T21:24:01Z")

</div>

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:

```elisp
;;; 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.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [January 22, 2024, 10:11pm UTC](https://discourse.julialang.org/t/is-there-a-from-zero-set-of-instructions-to-get-emacs-going-with-julia-ts-mode/109031/5 "2024-01-22T22:11:45Z")

</div>

> [@non-Jedi](#):
>
> ```julia
> ;;; 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))
> 
> ```

Thanks! Still errors:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/f/5f6fe3fc16eb4b3a3ed58ddb826500cd3c98e28e.png)

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [January 23, 2024, 3:19am UTC](https://discourse.julialang.org/t/is-there-a-from-zero-set-of-instructions-to-get-emacs-going-with-julia-ts-mode/109031/6 "2024-01-23T03:19:03Z")

</div>

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](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)

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [January 23, 2024, 1:47pm UTC](https://discourse.julialang.org/t/is-there-a-from-zero-set-of-instructions-to-get-emacs-going-with-julia-ts-mode/109031/7 "2024-01-23T13:47:19Z")

</div>

Okay, you have two options:

1. Install a C/C++ compiler and a linker such as [mingw-w64](https://www.mingw-w64.org/). 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](https://github.com/JuliaBinaryWrappers/tree_sitter_julia_jll.jl/releases) (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`.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [January 23, 2024, 4:56pm UTC](https://discourse.julialang.org/t/is-there-a-from-zero-set-of-instructions-to-get-emacs-going-with-julia-ts-mode/109031/8 "2024-01-23T16:56:40Z")

</div>

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

P
