windwp / nvim-ts-autotag

Use treesitter to auto close and auto rename html tag
MIT License
1.65k stars 87 forks source link

bug: No parser for 'embedded_template' language #183

Closed cbochs closed 4 months ago

cbochs commented 4 months ago

I am running into this error while editing ruby .html.erb files:

   Error  16:30:44 msg_show.lua_error Error detected while processing InsertLeave Autocommands for "<buffer=3>":
16:30:44 msg_show Error executing lua callback: ...arm64/share/nvim/runtime/lua/vim/treesitter/language.lua:107: no parser for 'embedded_template' language, see :help treesitter-parsers
stack traceback:
    [C]: in function 'error'
    ...arm64/share/nvim/runtime/lua/vim/treesitter/language.lua:107: in function 'add'
    ...4/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:111: in function 'new'
    ...im-macos-arm64/share/nvim/runtime/lua/vim/treesitter.lua:41: in function '_create_parser'
    ...im-macos-arm64/share/nvim/runtime/lua/vim/treesitter.lua:108: in function 'get_parser'
    ...im/lazy/nvim-ts-autotag/lua/nvim-ts-autotag/internal.lua:433: in function <...im/lazy/nvim-ts-autotag/lua/nvim-ts-autotag/internal.lua:431>

The problem appears to stem from this line: nvim-ts-autotag/internal.lua#L433.

I think it could be solved by just wrapping this in a pcall, like:

local ok, parser = pcall(vim.treesitter.get_parser)
if not ok then
    return
end