# Neovim tree-sitter error when loading julia file: invalid node type "function\_expression"

**URL:** <https://discourse.julialang.org/t/neovim-tree-sitter-error-when-loading-julia-file-invalid-node-type-function-expression/122864>\
**Category:** General Usage\
**Tags:** languageserver, neovim\
**Created:** [November 20, 2024, 5:14pm UTC](https://discourse.julialang.org/t/neovim-tree-sitter-error-when-loading-julia-file-invalid-node-type-function-expression/122864 "2024-11-20T17:14:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![filchristou](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/filchristou/32/26760_2.png) [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Post date:** [November 20, 2024, 5:14pm UTC](https://discourse.julialang.org/t/neovim-tree-sitter-error-when-loading-julia-file-invalid-node-type-function-expression/122864/1 "2024-11-20T17:14:24Z")

</div>

After updating my neovim setup I get the following error

 ![image](https://global.discourse-cdn.com/julialang/original/3X/7/4/749eda7837de489c78565b2d43597c7b1ce88c21.png)

My guess is I am not alone here (?)

Searching a bit around I think a fix is already available from this commit

> <https://github.com/tree-sitter/tree-sitter-julia/commit/029db9527121da6947101195539a1da2dacd8cd0>
>
> \- Arrow functions cannot contain open tuples, so they should only allow
> closed… assignments (like \`let\_statement\`).
> \- Rename \`function\_expression\` to \`arrow\_function\_expression\`.

But I don’t know when this will land to the latest tree-sitter release.

[It looks like](https://github.com/tree-sitter/tree-sitter/discussions/1768) tree-sitter doesn’t gracefully handle versioning of 3rd party modules like `julia`.  
I don’t even know how to poll which `tree-sitter-julia` version is installed, let alone how to instruct tree-sitter to use the newest version.

Any help ?

---

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [November 20, 2024, 6:43pm UTC](https://discourse.julialang.org/t/neovim-tree-sitter-error-when-loading-julia-file-invalid-node-type-function-expression/122864/2 "2024-11-20T18:43:17Z")

</div>

> [@filchristou](#):
>
> I don’t even know how to poll which `tree-sitter-julia` version is installed, let alone how to instruct tree-sitter to use the newest version.

My understanding is that the parsers are locked in the [`nvim-treesitter` plugin](https://github.com/nvim-treesitter/nvim-treesitter) (in their [`lockfile.json`](https://github.com/nvim-treesitter/nvim-treesitter/blob/master/lockfile.json)). So you’d have to pin a version of `nvim-treesitter` that has the julia parser you want, or potentially look into an [advanced setup](https://github.com/nvim-treesitter/nvim-treesitter?tab=readme-ov-file#advanced-setup).

What syntax do you have in your `.jl` file that triggers this error? I’m on `nvim-treesitter v0.9.3`, and I’m haven’t seen any issues.

---

<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:** [November 20, 2024, 8:39pm UTC](https://discourse.julialang.org/t/neovim-tree-sitter-error-when-loading-julia-file-invalid-node-type-function-expression/122864/3 "2024-11-20T20:39:15Z")

</div>

Did you run `:TSUpdate` ?

---

<div class="post-metadata">

**Author:** ![aris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@aris](https://discourse.julialang.org/u/aris)\
**Post date:** [November 21, 2024, 9:25am UTC](https://discourse.julialang.org/t/neovim-tree-sitter-error-when-loading-julia-file-invalid-node-type-function-expression/122864/4 "2024-11-21T09:25:43Z")

</div>

> [@filchristou](#):
>
> My guess is I am not alone here (?)

Same issue for me ☹  
It seems julia is no longer ticked on the [list of supported languages](https://github.com/nvim-treesitter/nvim-treesitter?tab=readme-ov-file#supported-languages).

---

<div class="post-metadata">

**Author:** ![filchristou](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/filchristou/32/26760_2.png) [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Post date:** [November 21, 2024, 10:44am UTC](https://discourse.julialang.org/t/neovim-tree-sitter-error-when-loading-julia-file-invalid-node-type-function-expression/122864/5 "2024-11-21T10:44:51Z")

</div>

Yes.

---

<div class="post-metadata">

**Author:** ![filchristou](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/filchristou/32/26760_2.png) [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Post date:** [November 21, 2024, 6:13pm UTC](https://discourse.julialang.org/t/neovim-tree-sitter-error-when-loading-julia-file-invalid-node-type-function-expression/122864/6 "2024-11-21T18:13:55Z")

</div>

I am running on neovim `v0.10.2` and the latest nvim-treesitter commit `8a74ac9a` with the `lockfile.jl` showing the latest `tree-sitter-julia` commit `e01c928d11375513138a175a68485c4d53e55ea9`.  
I have uninstalled/installed tree-sitter plugin several times.

> [@goerz](#):
>
> What syntax do you have in your `.jl` file that triggers this error? I

Just starting an empty `.jl` file is enough

> > I’m on `nvim-treesitter v0.9.3`, and I’m haven’t seen any issues.

@goerz just curious… what plugin manager are you using and how did you identify the version?

---

<div class="post-metadata">

**Author:** ![filchristou](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/filchristou/32/26760_2.png) [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Post date:** [November 21, 2024, 6:43pm UTC](https://discourse.julialang.org/t/neovim-tree-sitter-error-when-loading-julia-file-invalid-node-type-function-expression/122864/7 "2024-11-21T18:43:27Z")

</div>

I don’t know why, but I had the following Lazy configuration for nvim-treesitter

```lua
  {
    -- Highlight, edit, and navigate code
    'nvim-treesitter/nvim-treesitter',
    dependencies = {
      'nvim-treesitter/nvim-treesitter-textobjects',
    },
    build = ':TSUpdate',
  },

```

The current version of `nvim-treesitter/nvim-treesitter-textobjects` has the following line

> <https://github.com/nvim-treesitter/nvim-treesitter-textobjects/blob/3e450cd85243da99dc23ebbf14f9c70e9a0c26a4/queries/julia/textobjects.scm#L104>

which provokes the error.

I just deleted `nvim-treesitter/nvim-treesitter-textobjects` from the dependency and uninstalled and now I don’t get the error.

There is also an issue open

> <https://github.com/nvim-treesitter/nvim-treesitter-textobjects/issues/716>
>
> \*\*Describe the bug\*\*
> Whenever opening a julia file, I get the error \`Invalid nod…e type "function\_expression"\`. This error does not occur when only nvim-treesitter is active.  
> 
> Explicitly, I get the following trace whenever I open a Julia file.
> 
> \<details\>
> 
> \`\`\`
> 
> Error detected while processing BufReadPost Autocommands for "\*":
> Error executing lua callback: /opt/local/share/nvim/runtime/filetype.lua:35: Error executing lua: /opt/local/share/nvim/runtime/fi
> letype.lua:36: BufReadPost Autocommands for "\*"..FileType Autocommands for "\*": Vim(append):Error executing lua callback: /opt/loc
> al/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 104:2. Invalid node type "function\_expression":
> (function\_expression
> ^
> 
> stack traceback:
> \[C\]: in function '\_ts\_parse\_query'
> /opt/local/share/nvim/runtime/lua/vim/treesitter/query.lua:252: in function 'fn'
> /opt/local/share/nvim/runtime/lua/vim/func/\_memoize.lua:58: in function 'fn'
> /opt/local/share/nvim/runtime/lua/vim/func/\_memoize.lua:58: in function 'get\_query'
> ...r-textobjects/lua/nvim-treesitter/textobjects/shared.lua:99: in function 'available\_textobjects'
> ...r-textobjects/lua/nvim-treesitter/textobjects/select.lua:173: in function 'attach'
> ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:509: in function 'attach\_module'
> ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:532: in function 'reattach\_module'
> ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:133: in function \<...vim/lazy/nvim-treesitter/lua/nvim-treesit
> ter/configs.lua:132\>
> \[C\]: in function 'nvim\_cmd'
> /opt/local/share/nvim/runtime/filetype.lua:36: in function \</opt/local/share/nvim/runtime/filetype.lua:35\>
> \[C\]: in function 'nvim\_buf\_call'
> /opt/local/share/nvim/runtime/filetype.lua:35: in function \</opt/local/share/nvim/runtime/filetype.lua:10\>
> stack traceback:
> \[C\]: in function 'nvim\_cmd'
> /opt/local/share/nvim/runtime/filetype.lua:36: in function \</opt/local/share/nvim/runtime/filetype.lua:35\>
> \[C\]: in function 'nvim\_buf\_call'
> /opt/local/share/nvim/runtime/filetype.lua:35: in function \</opt/local/share/nvim/runtime/filetype.lua:10\>
> stack traceback:
> \[C\]: in function 'nvim\_buf\_call'
> /opt/local/share/nvim/runtime/filetype.lua:35: in function \</opt/local/share/nvim/runtime/filetype.lua:10\>
> 
> \`\`\`
> 
> \</details\>
> 
> \*\*Minimal-config\*\*
> 
> \<details\>
> 
> \`\`\`
> 
> \---Install Lazy package manager.
> local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
> if not vim.loop.fs\_stat(lazypath) then
> vim.fn.system {
> 'git',
> 'clone',
> '--filter=blob:none',
> 'https://github.com/folke/lazy.nvim.git',
> '--branch=stable', -- latest stable release
> lazypath,
> }
> end
> vim.opt.rtp:prepend(lazypath)
> 
> 
> require('lazy').setup({
> {
> 'nvim-treesitter/nvim-treesitter',
> dependencies = {
> 'nvim-treesitter/nvim-treesitter-textobjects',
> },
> build = ':TSUpdate',
> main = 'nvim-treesitter.configs',
> opts = {
> ensure\_installed = { 'julia' },
> textobjects = {
> select = {
> enable = true,
> keymaps = {
> \['af'\] = '@function.outer',
> \['if'\] = '@function.inner',
> },
> },
> }
> },
> },
> })
> 
> \`\`\`
> 
> \</details\>
> 
> \*\*To Reproduce\*\*
> Steps to reproduce the behavior:
> 1. In terminal, \`touch test.jl\`
> 2. With the minimal config above, \`nvim test.jl\`
> 3. See error
> 
> \*\*Expected behavior\*\*
> No error should occur, and the plugin should work.
> 
> \*\*Output of \`:checkhealth nvim-treesitter\`\*\*
> 
> \<details\>
> \<code\>
> 
> ==============================================================================
> nvim-treesitter: require("nvim-treesitter.health").check()
> 
> Installation ~
> \- WARNING \`tree-sitter\` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
> \- WARNING \`node\` executable not found (only needed for :TSInstallFromGrammar, not required for :TSInstall)
> \- OK \`git\` executable found.
> \- OK \`cc\` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
> Version: Apple clang version 14.0.0 (clang-1400.0.29.202)
> \- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required \>=13). Parsers must be compatible with runtime ABI.
> 
> OS Info:
> {
> machine = "x86\_64",
> release = "21.6.0",
> sysname = "Darwin",
> version = "Darwin Kernel Version 21.6.0: Mon Jun 24 00:56:10 PDT 2024; root:xnu-8020.240.18.709.2~1/RELEASE\_X86\_64"
> } ~
> 
> Parser/Features H L F I J
> - c ✓ ✓ ✓ ✓ ✓
> - javascript ✓ ✓ ✓ ✓ ✓
> - julia ✓ ✓ ✓ ✓ ✓
> - lua ✓ ✓ ✓ ✓ ✓
> - luadoc ✓ . . . .
> - luap ✓ . . . .
> - markdown ✓ . ✓ ✓ ✓
> - markdown\_inline ✓ . . . ✓
> - python ✓ ✓ ✓ ✓ ✓
> - query ✓ ✓ ✓ ✓ ✓
> - rust ✓ ✓ ✓ ✓ ✓
> - vim ✓ ✓ ✓ . ✓
> - vimdoc ✓ . . . ✓
> 
> Legend: H\[ighlight\], L\[ocals\], F\[olds\], I\[ndents\], In\[j\]ections
> +) multiple parsers found, only one will be used
> x) errors found in the query, try to run :TSUpdate {lang} ~
> 
> \</code\>
> \</details\>
> 
> \*\*Output of \`nvim --version\`\*\*
> \`\`\`
> NVIM v0.10.2
> Build type: Release
> LuaJIT 2.1.1720049189
> Run "nvim -V1 -v" for more info
> \`\`\`
> 
> \*\*Additional context\*\*
> \- I tried the troubleshooting steps \[here\](https://github.com/nvim-treesitter/nvim-treesitter?tab=readme-ov-file#i-get-query-error-invalid-node-type-at-position)
> \- I'm just taking a wild guess, since I don't know this package's code at all, but is it due to \[this\](https://github.com/nvim-treesitter/nvim-treesitter-textobjects/blob/3e450cd85243da99dc23ebbf14f9c70e9a0c26a4/queries/julia/textobjects.scm#L104)?

---

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [November 21, 2024, 7:22pm UTC](https://discourse.julialang.org/t/neovim-tree-sitter-error-when-loading-julia-file-invalid-node-type-function-expression/122864/8 "2024-11-21T19:22:31Z")

</div>

I’m using `Lazy` as well. My configuration is at [GitHub - goerz/neovimrc: My Neovim Configuration](https://github.com/goerz/neovimrc)

If you ever have a problem with treesitter queries that ship with `nvim-treesitter`, you can always use your own by putting them in `~/.config/nvim/queries/julia`

---

<div class="post-metadata">

**Author:** ![gottacatchenall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gottacatchenall/32/18265_2.png) [@gottacatchenall](https://discourse.julialang.org/u/gottacatchenall)\
**Post date:** [January 4, 2025, 6:58pm UTC](https://discourse.julialang.org/t/neovim-tree-sitter-error-when-loading-julia-file-invalid-node-type-function-expression/122864/9 "2025-01-04T18:58:21Z")

</div>

I had this issue, but it seems it was fixed in [this PR](https://github.com/nvim-treesitter/nvim-treesitter-textobjects/pull/719). I had to run `:TSUninstall julia` and reinstall it to get it to work (updating nvim-treesitter itself did not work)
