mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-17 02:40:09 -04:00
added attach async
This commit is contained in:
parent
b441f257a4
commit
e0b49a9a18
2 changed files with 14 additions and 1 deletions
|
|
@ -78,7 +78,7 @@ local function enable_mod_conf_autocmd(mod)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local cmd = string.format("lua require'nvim-treesitter.configs'.attach_module('%s')", mod)
|
local cmd = string.format("lua require'nvim-treesitter.configs'.attach_module_async('%s')", mod)
|
||||||
api.nvim_command(string.format("autocmd NvimTreesitter FileType * %s", cmd))
|
api.nvim_command(string.format("autocmd NvimTreesitter FileType * %s", cmd))
|
||||||
|
|
||||||
config_mod.loaded = true
|
config_mod.loaded = true
|
||||||
|
|
@ -311,6 +311,8 @@ function M.attach_module(mod_name, bufnr, lang)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
M.attach_module_async = utils.async(M.attach_module)
|
||||||
|
|
||||||
-- Detaches a module to a buffer
|
-- Detaches a module to a buffer
|
||||||
-- @param mod_name the module name
|
-- @param mod_name the module name
|
||||||
-- @param bufnr the bufnr
|
-- @param bufnr the bufnr
|
||||||
|
|
|
||||||
|
|
@ -141,4 +141,15 @@ function M.index_of(tbl, obj)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.async(f)
|
||||||
|
return function(...)
|
||||||
|
local handle
|
||||||
|
handle = vim.loop.new_async(vim.schedule_wrap(function(...)
|
||||||
|
f(...)
|
||||||
|
handle:close()
|
||||||
|
end))
|
||||||
|
handle:send(...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue