alfaix / neotest-gtest

Google Test adapter for nvim-neotest
MIT License
45 stars 14 forks source link

Problems setting it up: no parser for 'cpp' language #23

Closed TilGP closed 4 months ago

TilGP commented 4 months ago

I get the following error:

Failed to load `plugins.neotest`

....10.0/share/nvim/runtime/lua/vim/treesitter/language.lua:107: no parser for 'cpp' language, see :help treesitter-parsers

# stacktrace:
  - /home/linuxbrew/.linuxbrew/Cellar/neovim/0.10.0/share/nvim/runtime/lua/vim/treesitter/language.lua:107 _in_ **add**
  - /home/linuxbrew/.linuxbrew/Cellar/neovim/0.10.0/share/nvim/runtime/lua/vim/treesitter/query.lua:250 _in_ **fn**
  - /home/linuxbrew/.linuxbrew/Cellar/neovim/0.10.0/share/nvim/runtime/lua/vim/func/_memoize.lua:58 _in_ **parse**
  - /neotest-gtest/lua/neotest-gtest/parse.lua:28
  - /neotest-gtest/lua/neotest-gtest/init.lua:2
  - lua/plugins/neotest.lua:10
  - lua/config/lazy.lua:9
  - init.lua:2

Although I have done :TSInstall cpp and :TSInstallInfo shows cpp as installed. What did I do wrong?

alfaix commented 4 months ago

Hey @TilGP, thanks for giving the plugin a try :)

It looks like the line that fails is the treesitter parse call. Could you please try running: :lua vim.treesitter.query.parse("cpp", "((function_definition) @f)")

If this doesn't work then something is wrong with the treesitter installation - if you're using a custom cpp parser (e.g., from a branch) - then try the regular one. If you're using the regular one, I'm afraid I can't suggest much - perhaps reinstalling nvim-treesitter through your plugin manager. If nothing helps, I suggest to open an issue with the nvim-treesitter folks.

TilGP commented 4 months ago

thanks for the response. I have reinstalled treesitter and the cpp parser. All should be up-to-date with the master branch. could you tell me, what the command should return. Because the response is empty for me (executing during with a cpp file open). I will try to find a solution and/or open a issue in the treesitter repo

alfaix commented 4 months ago

Hey @TilGP, empty output is normal, if it doesn't print an error. You can do :lua =vim.treesitter.query.parse("cpp", "((function_definition) @f)") (with = after lua) which should return a table.

If that still works, but the plugin doesn't, something strange is happening. One guess is that perhaps nvim-treesitter is not loaded at the moment that neotest-gtest is called? If you're using lazy.nvim (or something similar with lazy loading), try adding nvim-treesitter to dependencies of neotest.