jmbuhr / otter.nvim

Just ask an otter! 🦦
MIT License
441 stars 11 forks source link

attempt to call method '_rawquery' (a nil value) #134

Closed llimllib closed 2 months ago

llimllib commented 2 months ago

When I open a markdown file, whether or not it has fenced blocks, I'm getting an exception:

Error detected while processing BufEnter Autocommands for "*.md":                                                                                                                                                           
Error executing lua callback: .../lazy/otter.nvim/lua/otter/tools/treesitter_iterator.lua:8: attempt to call method '_rawquery' (a nil value)                                                                               
stack traceback:                                                                                                                                                                                                            
        .../lazy/otter.nvim/lua/otter/tools/treesitter_iterator.lua:8: in function 'iter_captures'                                                                                                                          
        ...b/.local/share/nvim/lazy/otter.nvim/lua/otter/keeper.lua:54: in function 'extract_code_chunks'                                                                                                                   
        ...lib/.local/share/nvim/lazy/otter.nvim/lua/otter/init.lua:69: in function 'activate'                                                                                                                              
        /Users/llimllib/.config/nvim/lua/config_otter.lua:19: in function </Users/llimllib/.config/nvim/lua/config_otter.lua:18> 

I recently updated to neovim 0.10.0, which I'm not sure is relevant or not. I ran :TSUpdate to update all my treesitter grammars when I did.

line 19 of my config is otter.activate in this block:

vim.api.nvim_create_autocmd({ "BufEnter" }, {
    pattern = { "*.md" },
    callback = function()
        otter.activate({ "javascript", "typescript", "js", "ts" }, true, true)
        vim.api.nvim_buf_set_keymap(0, "n", "gd", ":lua require'otter'.ask_definition()<cr>", { silent = true })
        vim.api.nvim_buf_set_keymap(0, "n", "K", ":lua require'otter'.ask_hover()<cr>", { silent = true })
    end,
})

line 54 of keeper.lua is the last line of this block:

M.extract_code_chunks = function(main_nr, lang, exclude_eval_false, row_from, row_to)
  local query = M._otters_attached[main_nr].query
  local parser = M._otters_attached[main_nr].parser
  local tree = parser:parse()
  local root = tree[1]:root()

  local code_chunks = {}
  local lang_capture = nil
  for id, node, metadata in treesitter_iterator.iter_captures(root, main_nr, query) do

the first 8 lines of treesitter_iterator.lua are:

M = {}

M.iter_captures = function (node, source, query)
  if type(source) == "number" and source == 0 then
    source = vim.api.nvim_get_current_buf()
  end

  local raw_iter = node:_rawquery(query.query, true, 0, -1)

Here's my full :healthcheck output:

:healthcheck ``` ============================================================================== lazy: require("lazy.health").check() lazy.nvim ~ - OK Git installed - OK no existing packages found by other package managers - OK packer_compiled.lua not found ============================================================================== null-ls: require("null-ls.health").check() - ERROR black: the command "black" is not executable. - OK clang_format: the command "clang-format" is executable. - OK goimports: the command "goimports" is executable. - OK gofumpt: the command "gofumpt" is executable. - OK prettier: the command "prettier" is executable. - OK stylua: the command "stylua" is executable. - ERROR terraform_fmt: the command "terraform" is not executable. ============================================================================== nvim: require("nvim.health").check() Configuration ~ - OK no issues found Runtime ~ - OK $VIMRUNTIME: /opt/homebrew/Cellar/neovim/0.10.0/share/nvim/runtime Performance ~ - OK Build type: Release Remote Plugins ~ - OK Up to date terminal ~ - key_backspace (kbs) terminfo entry: `key_backspace=\177` - key_dc (kdch1) terminfo entry: `key_dc=\E[3~` - $COLORTERM="truecolor" External Tools ~ - OK ripgrep 14.1.0 (/opt/homebrew/bin/rg) ============================================================================== nvim-treesitter: require("nvim-treesitter.health").check() Installation ~ - OK `tree-sitter` found 0.22.6 (parser generator, only needed for :TSInstallFromGrammar) - OK `node` found v20.11.1 (only needed for :TSInstallFromGrammar) - OK `git` executable found. - OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" } Version: Apple clang version 15.0.0 (clang-1500.3.9.4) - OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI. OS Info: { machine = "arm64", release = "23.4.0", sysname = "Darwin", version = "Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:49 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6020" } ~ Parser/Features H L F I J - bash βœ“ βœ“ βœ“ . βœ“ - c βœ“ βœ“ βœ“ βœ“ βœ“ - c_sharp βœ“ βœ“ βœ“ . βœ“ - comment βœ“ . . . . - cpp βœ“ βœ“ βœ“ βœ“ βœ“ - css βœ“ . βœ“ βœ“ βœ“ - csv βœ“ . . . . - diff βœ“ . . . . - dockerfile βœ“ . . . βœ“ - elixir βœ“ βœ“ βœ“ βœ“ βœ“ - erlang βœ“ . βœ“ . . - git_config βœ“ . βœ“ . βœ“ - git_rebase βœ“ . . . βœ“ - gitcommit βœ“ . . . βœ“ - gitignore βœ“ . . . . - glsl βœ“ βœ“ βœ“ βœ“ βœ“ - go βœ“ βœ“ βœ“ βœ“ βœ“ - gomod βœ“ . . . βœ“ - gosum βœ“ . . . . - gowork βœ“ . . . βœ“ - html βœ“ βœ“ βœ“ βœ“ βœ“ - htmldjango βœ“ . βœ“ βœ“ βœ“ - ini βœ“ . βœ“ . . - java βœ“ βœ“ βœ“ βœ“ βœ“ - javascript βœ“ βœ“ βœ“ βœ“ βœ“ - json βœ“ βœ“ βœ“ βœ“ . - json5 βœ“ . . . βœ“ - jsonc βœ“ βœ“ βœ“ βœ“ βœ“ - julia βœ“ βœ“ βœ“ βœ“ βœ“ - latex βœ“ . βœ“ . βœ“ - lua βœ“ βœ“ βœ“ βœ“ βœ“ - make βœ“ . βœ“ . βœ“ - markdown βœ“ . βœ“ βœ“ βœ“ - markdown_inline βœ“ . . . βœ“ - prisma βœ“ . βœ“ . . - python βœ“ βœ“ βœ“ βœ“ βœ“ - query βœ“ βœ“ βœ“ βœ“ βœ“ - ruby βœ“ βœ“ βœ“ βœ“ βœ“ - rust βœ“ βœ“ βœ“ βœ“ βœ“ - scss βœ“ . βœ“ βœ“ . - sql βœ“ . . βœ“ βœ“ - starlark βœ“ βœ“ βœ“ βœ“ βœ“ - swift βœ“ βœ“ . βœ“ . - terraform βœ“ . βœ“ βœ“ βœ“ - toml βœ“ βœ“ βœ“ βœ“ βœ“ - tsx βœ“ βœ“ βœ“ βœ“ βœ“ - typescript βœ“ βœ“ βœ“ βœ“ βœ“ - vim βœ“ βœ“ βœ“ . βœ“ - vimdoc βœ“ . . . βœ“ - xml βœ“ βœ“ βœ“ βœ“ βœ“ - yaml βœ“ βœ“ βœ“ βœ“ βœ“ - zig βœ“ βœ“ βœ“ βœ“ βœ“ 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} ~ ============================================================================== provider.clipboard: require("provider.clipboard.health").check() Clipboard (optional) ~ - OK Clipboard tool found: pbcopy ============================================================================== provider.node: require("provider.node.health").check() Node.js provider (optional) ~ - Node.js: v20.11.1 - WARNING Missing "neovim" npm (or yarn, pnpm) package. - ADVICE: - Run in shell: npm install -g neovim - Run in shell (if you use yarn): yarn global add neovim - Run in shell (if you use pnpm): pnpm install -g neovim - You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim ============================================================================== provider.perl: require("provider.perl.health").check() Perl provider (optional) ~ - WARNING "Neovim::Ext" cpan module is not installed - ADVICE: - See :help |provider-perl| for more information. - You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim - WARNING No usable perl executable found ============================================================================== provider.python: require("provider.python.health").check() Python 3 provider (optional) ~ - WARNING No Python executable found that can `import neovim`. Using the first available executable for diagnostics. - WARNING Could not load Python : /Users/llimllib/.local/share/mise/installs/python/3.12/bin/python3 does not have the "neovim" module. /Users/llimllib/.local/share/mise/installs/python/3.12/bin/python3.12 does not have the "neovim" module. /opt/homebrew/bin/python3.11 does not have the "neovim" module. python3.10 not found in search path or not executable. python3.9 not found in search path or not executable. python3.8 not found in search path or not executable. python3.7 not found in search path or not executable. /Users/llimllib/.local/share/mise/installs/python/3.12/bin/python does not have the "neovim" module. - ADVICE: - See :help |provider-python| for more information. - You may disable this provider (and warning) by adding `let g:loaded_python3_provider = 0` to your init.vim - Executable: Not found Python virtualenv ~ - OK no $VIRTUAL_ENV ============================================================================== provider.ruby: require("provider.ruby.health").check() Ruby provider (optional) ~ - Ruby: ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin23] - WARNING `neovim-ruby-host` not found. - ADVICE: - Run `gem install neovim` to ensure the neovim RubyGem is installed. - Run `gem environment` to ensure the gem bin directory is in $PATH. - If you are using rvm/rbenv/chruby, try "rehashing". - See :help |g:ruby_host_prog| for non-standard gem installations. - You may disable this provider (and warning) by adding `let g:loaded_ruby_provider = 0` to your init.vim ============================================================================== telescope: require("telescope.health").check() Checking for required plugins ~ - OK plenary installed. - OK nvim-treesitter installed. Checking external dependencies ~ - OK rg: found ripgrep 14.1.0 - OK fd: found fd 8.7.0 ===== Installed extensions ===== ~ Telescope Extension: `fzf` ~ - OK lib working as expected - OK file_sorter correctly configured - OK generic_sorter correctly configured ============================================================================== vim.lsp: require("vim.lsp.health").check() - LSP log level : WARN - Log path: /Users/llimllib/.local/state/nvim/lsp.log - Log size: 9823 KB vim.lsp: Active Clients ~ - null-ls (id=1, root_dir=~/readme/mdx-renderer, attached_to=[1,4]) vim.lsp: File watcher ~ - file watching "(workspace/didChangeWatchedFiles)" disabled on all clients ============================================================================== vim.treesitter: require("vim.treesitter.health").check() - Nvim runtime ABI version: 14 - OK Parser: bash ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/bash.so - OK Parser: c ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/c.so - OK Parser: comment ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/comment.so - OK Parser: cpp ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/cpp.so - OK Parser: css ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/css.so - OK Parser: csv ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/csv.so - OK Parser: c_sharp ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/c_sharp.so - OK Parser: diff ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/diff.so - OK Parser: dockerfile ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/dockerfile.so - OK Parser: elixir ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/elixir.so - OK Parser: erlang ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/erlang.so - OK Parser: gitcommit ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/gitcommit.so - OK Parser: gitignore ABI: 13, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/gitignore.so - OK Parser: git_config ABI: 13, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/git_config.so - OK Parser: git_rebase ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/git_rebase.so - OK Parser: glsl ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/glsl.so - OK Parser: go ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/go.so - OK Parser: gomod ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/gomod.so - OK Parser: gosum ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/gosum.so - OK Parser: gowork ABI: 13, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/gowork.so - OK Parser: html ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/html.so - OK Parser: htmldjango ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/htmldjango.so - OK Parser: ini ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/ini.so - OK Parser: java ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/java.so - OK Parser: javascript ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/javascript.so - OK Parser: json ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/json.so - OK Parser: json5 ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/json5.so - OK Parser: jsonc ABI: 13, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/jsonc.so - OK Parser: julia ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/julia.so - OK Parser: latex ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/latex.so - OK Parser: lua ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/lua.so - OK Parser: make ABI: 13, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/make.so - OK Parser: markdown ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/markdown.so - OK Parser: markdown_inline ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/markdown_inline.so - OK Parser: prisma ABI: 13, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/prisma.so - OK Parser: python ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/python.so - OK Parser: query ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/query.so - OK Parser: ruby ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/ruby.so - OK Parser: rust ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/rust.so - OK Parser: scss ABI: 13, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/scss.so - OK Parser: sql ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/sql.so - OK Parser: starlark ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/starlark.so - OK Parser: swift ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/swift.so - OK Parser: terraform ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/terraform.so - OK Parser: toml ABI: 13, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/toml.so - OK Parser: tsx ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/tsx.so - OK Parser: typescript ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/typescript.so - OK Parser: vim ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/vim.so - OK Parser: vimdoc ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/vimdoc.so - OK Parser: xml ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/xml.so - OK Parser: yaml ABI: 13, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/yaml.so - OK Parser: zig ABI: 14, path: /Users/llimllib/.local/share/nvim/lazy/nvim-treesitter/parser/zig.so - OK Parser: bash ABI: 14, path: /opt/homebrew/Cellar/neovim/0.10.0/lib/nvim/parser/bash.so - OK Parser: c ABI: 14, path: /opt/homebrew/Cellar/neovim/0.10.0/lib/nvim/parser/c.so - OK Parser: lua ABI: 14, path: /opt/homebrew/Cellar/neovim/0.10.0/lib/nvim/parser/lua.so - OK Parser: markdown ABI: 14, path: /opt/homebrew/Cellar/neovim/0.10.0/lib/nvim/parser/markdown.so - OK Parser: markdown_inline ABI: 14, path: /opt/homebrew/Cellar/neovim/0.10.0/lib/nvim/parser/markdown_inline.so - OK Parser: python ABI: 14, path: /opt/homebrew/Cellar/neovim/0.10.0/lib/nvim/parser/python.so - OK Parser: query ABI: 14, path: /opt/homebrew/Cellar/neovim/0.10.0/lib/nvim/parser/query.so - OK Parser: vim ABI: 14, path: /opt/homebrew/Cellar/neovim/0.10.0/lib/nvim/parser/vim.so - OK Parser: vimdoc ABI: 14, path: /opt/homebrew/Cellar/neovim/0.10.0/lib/nvim/parser/vimdoc.so ```
llimllib commented 2 months ago

Nevermind, running a lazy.vim update seems to have solved the issue