mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-03 03:56:52 -04:00
Re-attach module when the file type is changed
Requires https://github.com/neovim/neovim/pull/14995 Closes https://github.com/nvim-treesitter/nvim-treesitter/issues/1249
This commit is contained in:
parent
74d1d58572
commit
9be9ebda0a
1 changed files with 10 additions and 1 deletions
|
|
@ -85,7 +85,7 @@ local function enable_mod_conf_autocmd(mod)
|
|||
return
|
||||
end
|
||||
|
||||
local cmd = string.format("lua require'nvim-treesitter.configs'.attach_module('%s')", mod)
|
||||
local cmd = string.format("lua require'nvim-treesitter.configs'.reattach_module('%s')", mod)
|
||||
api.nvim_command(string.format("autocmd NvimTreesitter FileType * %s", cmd))
|
||||
|
||||
config_mod.loaded = true
|
||||
|
|
@ -442,6 +442,15 @@ function M.detach_module(mod_name, bufnr)
|
|||
end
|
||||
end
|
||||
|
||||
-- Same as attach_module, but if the module is already attached, detach it first.
|
||||
-- @param mod_name the module name
|
||||
-- @param bufnr the bufnr
|
||||
-- @param lang the language of the buffer
|
||||
function M.reattach_module(mod_name, bufnr, lang)
|
||||
M.detach_module(mod_name, bufnr)
|
||||
M.attach_module(mod_name, bufnr, lang)
|
||||
end
|
||||
|
||||
-- Gets available modules
|
||||
-- @param root root table to find modules
|
||||
function M.available_modules(root)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue