fixed not highlighting bug

This commit is contained in:
Brian Shu 2021-01-08 08:15:07 -05:00 committed by Thomas Vigouroux
parent 6856e23171
commit 28f2ba475f
2 changed files with 12 additions and 14 deletions

View file

@ -299,8 +299,8 @@ end
-- @param bufnr the bufnr
-- @param lang the language of the buffer
function M.attach_module(mod_name, bufnr, lang)
local bufnr = bufnr or api.nvim_get_current_buf()
local lang = lang or parsers.get_buf_lang(bufnr)
bufnr = bufnr or api.nvim_get_current_buf()
lang = lang or parsers.get_buf_lang(bufnr)
local resolved_mod = resolve_module(mod_name)
if resolved_mod
@ -311,7 +311,16 @@ function M.attach_module(mod_name, bufnr, lang)
end
end
M.attach_module_async = utils.async(M.attach_module)
-- must have custom async function or bufnr will be wrong
function M.attach_module_async(mod_name, bufnr)
bufnr = bufnr or api.nvim_get_current_buf() -- get bufnr before doing async, or bufnr will be wrong
local handle
handle = vim.loop.new_async(vim.schedule_wrap(function(...)
M.attach_module(...)
end))
handle:send(mod_name, bufnr, nil)
end
-- Detaches a module to a buffer
-- @param mod_name the module name

View file

@ -141,15 +141,4 @@ 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