diff options
| author | Brian Shu <littlebubu.shu@gmail.com> | 2021-01-05 11:26:03 -0500 |
|---|---|---|
| committer | Thomas Vigouroux <tomvig38@gmail.com> | 2021-01-07 11:16:16 +0100 |
| commit | e0b49a9a1885708d3565e9a59847b14a42faef2c (patch) | |
| tree | 949c280d7de6cad86a44ffdebca698d57ff9d169 /lua | |
| parent | Python highlights: update definition of decorator (diff) | |
| download | nvim-treesitter-e0b49a9a1885708d3565e9a59847b14a42faef2c.tar nvim-treesitter-e0b49a9a1885708d3565e9a59847b14a42faef2c.tar.gz nvim-treesitter-e0b49a9a1885708d3565e9a59847b14a42faef2c.tar.bz2 nvim-treesitter-e0b49a9a1885708d3565e9a59847b14a42faef2c.tar.lz nvim-treesitter-e0b49a9a1885708d3565e9a59847b14a42faef2c.tar.xz nvim-treesitter-e0b49a9a1885708d3565e9a59847b14a42faef2c.tar.zst nvim-treesitter-e0b49a9a1885708d3565e9a59847b14a42faef2c.zip | |
added attach async
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-treesitter/configs.lua | 4 | ||||
| -rw-r--r-- | lua/nvim-treesitter/utils.lua | 11 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua index b0d38244e..a7bbcb97d 100644 --- a/lua/nvim-treesitter/configs.lua +++ b/lua/nvim-treesitter/configs.lua @@ -78,7 +78,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'.attach_module_async('%s')", mod) api.nvim_command(string.format("autocmd NvimTreesitter FileType * %s", cmd)) config_mod.loaded = true @@ -311,6 +311,8 @@ function M.attach_module(mod_name, bufnr, lang) end end +M.attach_module_async = utils.async(M.attach_module) + -- Detaches a module to a buffer -- @param mod_name the module name -- @param bufnr the bufnr diff --git a/lua/nvim-treesitter/utils.lua b/lua/nvim-treesitter/utils.lua index de579bd6d..00ba4b943 100644 --- a/lua/nvim-treesitter/utils.lua +++ b/lua/nvim-treesitter/utils.lua @@ -141,4 +141,15 @@ function M.index_of(tbl, obj) 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 |
