mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-06 21:40:03 -04:00
configs: attach on unknown parsers too
This commit is contained in:
parent
1d178d75ea
commit
572a4a964b
3 changed files with 3 additions and 6 deletions
|
|
@ -106,10 +106,6 @@ local function enable_module(mod, bufnr, lang)
|
|||
local bufnr = bufnr or api.nvim_get_current_buf()
|
||||
local lang = lang or parsers.get_buf_lang(bufnr)
|
||||
|
||||
if not parsers.list[lang] then
|
||||
return
|
||||
end
|
||||
|
||||
M.attach_module(mod, bufnr, lang)
|
||||
end
|
||||
|
||||
|
|
@ -342,7 +338,7 @@ end
|
|||
function M.attach_module(mod_name, bufnr, lang)
|
||||
local resolved_mod = resolve_module(mod_name)
|
||||
|
||||
if resolved_mod then
|
||||
if resolved_mod and parsers.has_parser(lang) then
|
||||
resolved_mod.attach(bufnr, lang)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ for name, obj in pairs(M.list) do
|
|||
end
|
||||
|
||||
function M.ft_to_lang(ft)
|
||||
return ft_to_parsername[ft]
|
||||
return ft_to_parsername[ft] or ft
|
||||
end
|
||||
|
||||
function M.lang_to_ft(lang)
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ function M.get_named_children(node)
|
|||
end
|
||||
|
||||
function M.get_node_at_cursor(winnr)
|
||||
if not parsers.has_parser() then return end
|
||||
local cursor = api.nvim_win_get_cursor(winnr or 0)
|
||||
local root = parsers.get_parser():parse():root()
|
||||
return root:named_descendant_for_range(cursor[1]-1,cursor[2],cursor[1]-1,cursor[2])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue