Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Error: attempt to call method 'range' (a nil value)" #41

Open
mawkler opened this issue Oct 3, 2024 · 0 comments · May be fixed by #42
Open

"Error: attempt to call method 'range' (a nil value)" #41

mawkler opened this issue Oct 3, 2024 · 0 comments · May be fixed by #42

Comments

@mawkler
Copy link

mawkler commented Oct 3, 2024

I started getting this error recently:

Error executing vim.schedule lua callback: .../nvim-treesitter-endwise/lua/nvim-treesitter/endwise.lua:148: attempt to call method 'range' (a nil value)
stack traceback:
	.../nvim-treesitter-endwise/lua/nvim-treesitter/endwise.lua:148: in function 'endwise'
	.../nvim-treesitter-endwise/lua/nvim-treesitter/endwise.lua:199: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>

Looking at the code it makes sense because indent_node is only set in some cases, and nil in other cases:

local indent_node, cursor_node, endable_node
for id, node in pairs(match) do
    if query.captures[id] == 'indent' then
        indent_node = node -- `indent_node` is only set if we get here
    elseif query.captures[id] == 'cursor' then
        cursor_node = node
    elseif query.captures[id] == 'endable' then
        endable_node = node
    end
end

local indent_node_range = { indent_node:range() } -- This is the error throwing line

I'm not sure why this bug hasn't shown up until now though.

metiulekm added a commit to metiulekm/nvim-treesitter-endwise that referenced this issue Oct 3, 2024
@metiulekm metiulekm linked a pull request Oct 3, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant