nvim-treesitter / nvim-treesitter-context

Show code context
MIT License
2.5k stars 201 forks source link

Error message when opening the command line window with q: #437

Closed tyrdal closed 4 months ago

tyrdal commented 6 months ago

Description

When I open the command line window with q: I get the following error message:

Error executing vim.schedule lua callback: ...vim-treesitter-context/lua/treesitter-context/render.lua:310: E11: Invalid in command-line window; <CR> executes, CTRL-C quits
stack traceback:
    [C]: in function 'nvim_win_close'
    ...vim-treesitter-context/lua/treesitter-context/render.lua:310: in function <...vim-treesitter-context/lua/treesitter-context/render.lua:308>
Error executing vim.schedule lua callback: ...vim-treesitter-context/lua/treesitter-context/render.lua:310: E11: Invalid in command-line window; <CR> executes, CTRL-C quits

Neovim version

0.9.5

Expected behavior

If the context is not applicable then just don't run it there and avoid the error.

Actual behavior

See description.

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

Steps to reproduce

  1. nvim --clean -u minimal.lua
  2. TSInstall
  3. Make sure the setup functions have run for for treesitter and your plugin
  4. Open a file that you installed a parser for in step 2
  5. run q: in normal mode or hit : and follow it with crl+f
lewis6991 commented 5 months ago

Unable to reproduce in nvim 0.10.0. Please check.

rafamadriz commented 5 months ago

Unable to reproduce in nvim 0.10.0. Please check.

Having the same issue, I was able to reproduce with the minimal config provided on 0.9.5. You just have to make sure to enable treesitter-context. Here's an example:

https://asciinema.org/a/spFeVFBKRarvuKgyG5HtTIIxq

I also tried on 0.10 and there's no error, so it seems to be a 0.9.5 thing.

lewis6991 commented 4 months ago

0.10 is release now, so don't need to fix this.