Skip to content

treesitter: attempt to call method 'range' (a nil value) on Neovim 0.12 #432

Description

@Liegia

Environment

  • Neovim: 0.12.0
  • nvim-treesitter: cf12346 (master)

Error

Triggers on CursorMoved, WinEnter, and any window-opening action.

E5108: Lua: .../vim/treesitter.lua:196: attempt to call method 'range' (a nil value)
stack traceback:
vim/treesitter.lua:196: in function 'get_range'
vim/treesitter.lua:231: in function 'get_node_text'
nvim-treesitter/query_predicates.lua:120: in function 'handler'
...
vim-matchup/lua/treesitter-matchup/internal.lua:150: in function 'get_matches'
vim-matchup/lua/treesitter-matchup/internal.lua:378: in function 'get_delim'

Root cause

Neovim 0.12 changed vim.treesitter.get_parser() to return nil instead of
throwing an error when no parser is found. vim-matchup's treesitter engine
does not handle the nil return, crashing at internal.lua:150.

Workaround

Remove vim-matchup as dependency entirely. No workaround via config flags
(vim.g.matchup_treesitter_enabled = 0 and enable = false in nvim-treesitter
configs block both have no effect).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions