# Help testing Julia tree-sitter mode in Emacs

**URL:** https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819
**Category:** Tooling
**Created:** [January 11, 2023, 7:06pm UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819 "2023-01-11T19:06:15Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)
#### Post date: [February 4, 2023, 5:11pm UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/21 "2023-02-04T17:11:25Z")

</div>

Anyone working on adding Julia support to combobulate?

---

<div class="post-metadata">

### Author: ![linwaytin](https://avatars.discourse-cdn.com/v4/letter/l/898d66/32.png) [@linwaytin](https://discourse.julialang.org/u/linwaytin)
#### Post date: [February 26, 2023, 5:16am UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/22 "2023-02-26T05:16:31Z")

</div>

This screenshot looks amazing. Is the completion from LSP or from this tree-sitter package?

---

<div class="post-metadata">

### Author: ![jcmkk3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jcmkk3/32/45280_2.png) [@jcmkk3](https://discourse.julialang.org/u/jcmkk3)
#### Post date: [February 26, 2023, 6:49pm UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/23 "2023-02-26T18:49:48Z")

</div>

The completion candidates are likely being powered by eglot, which is the LSP client that is now built into the 29 release of emacs. The pop up ui itself will be either company or corfu.

---

<div class="post-metadata">

### Author: ![linwaytin](https://avatars.discourse-cdn.com/v4/letter/l/898d66/32.png) [@linwaytin](https://discourse.julialang.org/u/linwaytin)
#### Post date: [February 27, 2023, 12:24am UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/24 "2023-02-27T00:24:02Z")

</div>

Got you. Thanks.

---

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [February 27, 2023, 12:45pm UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/25 "2023-02-27T12:45:41Z")

</div>

Hi @linwaytin !

The popup is company, which receives information from the LSP as @jcmkk3 said. However, I am using lsp-mode instead of eglot. I have never been able to make eglot works with Julia for some strange reason.

---

<div class="post-metadata">

### Author: ![linwaytin](https://avatars.discourse-cdn.com/v4/letter/l/898d66/32.png) [@linwaytin](https://discourse.julialang.org/u/linwaytin)
#### Post date: [February 27, 2023, 3:11pm UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/26 "2023-02-27T15:11:52Z")

</div>

Thank you!

I asked because I remember the LSP server for julia is very slow. I tried it some years ago and the experience is not good. Do you think it’s usable now?

---

<div class="post-metadata">

### Author: ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)
#### Post date: [February 27, 2023, 3:13pm UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/27 "2023-02-27T15:13:04Z")

</div>

I use eglot + corfu, and find the experience good.

---

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [February 27, 2023, 5:56pm UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/28 "2023-02-27T17:56:12Z")

</div>

> [@linwaytin](#):
>
> I asked because I remember the LSP server for julia is very slow. I tried it some years ago and the experience is not good. Do you think it’s usable now?

Yes, the experience was very slow but it got much better now. It is not perfect yet, but I use it daily without problems.

---

<div class="post-metadata">

### Author: ![linwaytin](https://avatars.discourse-cdn.com/v4/letter/l/898d66/32.png) [@linwaytin](https://discourse.julialang.org/u/linwaytin)
#### Post date: [February 28, 2023, 1:41am UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/29 "2023-02-28T01:41:37Z")

</div>

Awesome! It’s the time to try it again.

---

<div class="post-metadata">

### Author: ![ehsani63](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ehsani63/32/38199_2.png) [@ehsani63](https://discourse.julialang.org/u/ehsani63)
#### Post date: [May 3, 2023, 9:51am UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/30 "2023-05-03T09:51:07Z")

</div>

Hi, I am trying/enjoying the Julia tree-sitter on Emacs. Nice work. However, is there a specific config to get the indentation works properly? Right now, auto-indent works only if I write the begin and end of a block and then go and press enter at the end of the lines inside the block.

---

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [May 3, 2023, 3:21pm UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/31 "2023-05-03T15:21:48Z")

</div>

Hi!

I am not sure if this can be “fixed”. The tree sitter grammar does not identify the blocks until you add “begin” (or if, else, while, etc) and end. Hence, emacs does not know that it must apply an indentation to that code. I have no ideia how can we workaround.

---

<div class="post-metadata">

### Author: ![ehsani63](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ehsani63/32/38199_2.png) [@ehsani63](https://discourse.julialang.org/u/ehsani63)
#### Post date: [May 4, 2023, 9:28am UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/32 "2023-05-04T09:28:32Z")

</div>

I see. Maybe one can use snippets to add the “end” keyword automatically. Then tree-sitter should be able to take care of the indentation inside the block.

---

<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 20, 2024, 1:22am UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/33 "2024-01-20T01:22:46Z")

</div>

Could someone post a workable .emacs? I cannot get going… Thanks!

---

<div class="post-metadata">

### Author: ![ehsani63](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ehsani63/32/38199_2.png) [@ehsani63](https://discourse.julialang.org/u/ehsani63)
#### Post date: [April 30, 2024, 10:37am UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/34 "2024-04-30T10:37:33Z")

</div>

Recently, I built Emacs on a new system, and since then, `julia-ts-mode` does not show different colors for the source code. Upon checking the messages, I see the following errors. Does anyone have an idea what is missing?

> Treesitter context fold mode cannot be enabled.  
> [eglot] Waiting in the background for server `EGLOT (esi/(julia-mode ess-julia-mode julia-ts-mode))' Error during redisplay: (jit-lock-function 1) signaled (treesit-query-error "Node type error at" 177 "(assignment (identifier) @font-lock-variable-name-face (_)) (assignment (field_expression (identifier) \".\" (identifier) @font-lock-variable-name-face) (operator)) (assignment (bare_tuple (identifier) @font-lock-variable-name-face)) (assignment (bare_tuple (field_expression (identifier) \".\" (identifier) @font-lock-variable-name-face)) (operator)) (local_statement (identifier) @font-lock-variable-name-face) (let_binding (identifier) @font-lock-variable-name-face) (global_statement (identifier) @font-lock-variable-name-face)" "Debug the query with `treesit-query-validate’")

---

<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: [April 30, 2024, 11:41am UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/35 "2024-04-30T11:41:57Z")

</div>

Sounds like you’re running into [Displaying Julia files using julia-ts-mode fails on Emacs 30.0.5 · Issue #21 · JuliaEditorSupport/julia-ts-mode · GitHub](https://github.com/JuliaEditorSupport/julia-ts-mode/issues/21). Help fixing it would of course be appreciated.

---

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [April 30, 2024, 1:13pm UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/36 "2024-04-30T13:13:50Z")

</div>

Hi @ehsani63 !

Are you using Emacs 29 or 30?

It seems that the grammar has changed, leading to some errors (this kind of problem is particularly difficult to debug in Emacs only by those debugging messages…). Unfortunately, I do not use Emacs anymore and it will take sometime until I can setup the environment to debug it myself.

I have already transferred the `julia-ts-mode` repository to the org JuliaEditorSupport and hopefully someone will be able to help us here 🙂

---

<div class="post-metadata">

### Author: ![savq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/savq/32/22063_2.png) [@savq](https://discourse.julialang.org/u/savq)
#### Post date: [May 1, 2024, 7:26pm UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/37 "2024-05-01T19:26:00Z")

</div>

In Neovim, the tree-sitter plugin decides what version of the grammar to use. Does it work the same way in Emacs?

EDIT: I see that [GitHub - renzmann/treesit-auto: Automatic installation, usage, and fallback for tree-sitter major modes in Emacs 29](https://github.com/renzmann/treesit-auto) is used to install the grammar. This isn’t ideal because it’s very easy to have version mismatches. Ideally the mode should list the last tag that works correctly, so the installer knows the correct version to install (nvim-treesitter tracks the latest commit).

---

<div class="post-metadata">

### Author: ![neophytedave](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/neophytedave/32/202273_2.png) [@neophytedave](https://discourse.julialang.org/u/neophytedave)
#### Post date: [May 1, 2024, 8:38pm UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/38 "2024-05-01T20:38:10Z")

</div>

Do not know if it would help at all, but see Helix’s ([www.helix-editor.com](http://www.helix-editor.com)) implementation of tree-sitter.

---

<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: [May 1, 2024, 9:27pm UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/39 "2024-05-01T21:27:41Z")

</div>

To be clear, `julia-ts-mode` merely assumes that a compatible grammar is installed but doesn’t itself install any grammar. Installing the grammar is the user’s responsibility, but `treesit-auto` is suggested as an option.

Obviously something needs to change if the recommended way of installing the grammar installs an incompatible version, but it’s not `julia-ts-mode` itself misbehaving. Maybe the correct change is to have `julia-ts-mode` manage the grammar installation itself, but that sounds like a massive pain to do correctly in a cross-platform way.

TLDR: .dll hell

---

<div class="post-metadata">

### Author: ![savq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/savq/32/22063_2.png) [@savq](https://discourse.julialang.org/u/savq)
#### Post date: [May 1, 2024, 10:53pm UTC](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819/40 "2024-05-01T22:53:32Z")

</div>

Yeah, I didn’t mean to imply `julia-ts-mode` should install the grammar, but rather that it should store metadata so the installer knows the version it needs to install. It’s a very bad idea to install `HEAD` unconditionally.

In nvim-treesitter, there’s a [json file](https://github.com/nvim-treesitter/nvim-treesitter/blob/master/lockfile.json) with the latest commit of each parser that is known to work with the queries in the repo. Since there’s no emacs tree-sitter mono-repo, you’d need a different approach. But the principle is the same.

[Previous page](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819.md?page=1)

[Next page](https://discourse.julialang.org/t/help-testing-julia-tree-sitter-mode-in-emacs/92819.md?page=3)
