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

context.lua:17: attempt to index local 'tree' (a nil value) #397

Closed
benjyiw opened this issue Feb 16, 2024 · 3 comments · Fixed by #399
Closed

context.lua:17: attempt to index local 'tree' (a nil value) #397

benjyiw opened this issue Feb 16, 2024 · 3 comments · Fixed by #399
Labels
bug Something isn't working

Comments

@benjyiw
Copy link

benjyiw commented Feb 16, 2024

Description

I ran an upgrade of all my plugins earlier today. Now I'm having trouble working with some files that are incorrectly formatted. I'm getting constant errors when attempting navigation. Copied the trace into the "actual behavior" section.

My solution for now was to go back to the commit prior to recent changes to context.lua around like 17, where the stack trace starts, and all is well. Figured I would open an issue since others may also be experiencing the same

Neovim version

NVIM v0.9.5

Expected behavior

No response

Actual behavior

Error detected while processing CursorMoved Autocommands for "*":                                                                                                                                                                                              
Error executing lua callback: ...im-treesitter-context/lua/treesitter-context/context.lua:17: attempt to index local 'tree' (a nil value)                                                                                                                      
stack traceback:                                                                                                                                                                                                                                               
        ...im-treesitter-context/lua/treesitter-context/context.lua:17: in function 'get_parent_nodes'                                                                                                                                                         
        ...im-treesitter-context/lua/treesitter-context/context.lua:250: in function 'get_context'                                                                                                                                                             
        ...start/nvim-treesitter-context/lua/treesitter-context.lua:101: in function 'f'                                                                                                                                                                       
        ...start/nvim-treesitter-context/lua/treesitter-context.lua:27: in function <...start/nvim-treesitter-context/lua/treesitter-context.lua:21>                                                                                                           

Minimal config

local plugins = {
  ts         = 'https://github.com/nvim-treesitter/nvim-treesitter',
  ts_context = 'https://github.com/nvim-treesitter/nvim-treesitter-context',
  -- ADD ADDITIONAL PLUGINS THAT ARE _NECESSARY_ TO REPRODUCE THE ISSUE
}

for name, url in pairs(plugins) do
  local install_path = '/tmp/nvim/site/'..name
  if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system { 'git', 'clone', '--depth=1', url, install_path }
  end
  vim.o.runtimepath = install_path..','..vim.o.runtimepath
end

-- ADD INIT.LUA SETTINGS THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE
require'nvim-treesitter.configs'.setup {
  ensure_installed = { "yaml" },
}

Steps to reproduce

  1. Open some file with bad formatting with neovim nvim --clean -u minimal.lua bad.yaml

here's a bad yaml example:

key1:
    key2: value
  badkey: value
  1. Attempt navigation around "badkey" and stack traces should go crazy.
@benjyiw benjyiw added the bug Something isn't working label Feb 16, 2024
@lewis6991
Copy link
Member

@kwaszczuk

@ShellCode33
Copy link

I'm facing the same issue. Which commit did you go back to @benjyiw ?

@kwaszczuk
Copy link
Contributor

I am looking into the issue.

@ShellCode33 It was most likely caused by 0a95d47 so going back to 32bbb21 should help.

kwaszczuk added a commit to kwaszczuk/nvim-treesitter-context that referenced this issue Feb 17, 2024
lewis6991 pushed a commit that referenced this issue Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants