nvim-treehopper icon indicating copy to clipboard operation
nvim-treehopper copied to clipboard

No parser for `typescriptreact` language (when treesitter parser name is different from filetype)

Open Gelio opened this issue 3 years ago • 0 comments

When trying to use nvim-treehopper in a tsx file, I get the following error:

E5108: Error executing lua ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:25: no parser for
 'typescriptreact' language, see :help treesitter-parsers
stack traceback:
        [C]: in function 'error'
        ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:25: in function 'require_language'
        /usr/local/share/nvim/runtime/lua/vim/treesitter.lua:39: in function '_create_parser'
        /usr/local/share/nvim/runtime/lua/vim/treesitter.lua:98: in function 'get_parser'
        ...nvim/site/pack/packer/start/nvim-treehopper/lua/tsht.lua:53: in function 'nodes'
        [string ":lua"]:1: in main chunk
Press ENTER or type command to continue

https://user-images.githubusercontent.com/889383/173181320-7471c0ca-3580-4f3c-9794-6a09d90acb45.mp4

This seems to be caused by the treesitter parser for the typescriptreact filetype being named tsx. nvim-treehopper tries to use the parser with the same name as the filetype, which is not the case for quite a few filetypes, as shown in nvim-treesitter.

I have decided to report this issue separately from my attempt at solving it (#14), since the progress on that PR has stifled while the issue remains.

Gelio avatar Jun 14 '22 06:06 Gelio