fix(modules): do not reattach if already attached

This commit is contained in:
Steven Sojka 2020-08-21 07:49:06 -05:00 committed by Steven Sojka
parent f3a515b350
commit 3fe8bbcf9c
10 changed files with 76 additions and 42 deletions

View file

@ -69,7 +69,6 @@ hlmap["text.literal"] = "TSLiteral"
hlmap["text.uri"] = "TSURI"
function M.attach(bufnr, lang)
local bufnr = bufnr or api.nvim_get_current_buf()
local lang = lang or parsers.get_buf_lang(bufnr)
local config = configs.get_module('highlight')
@ -84,12 +83,11 @@ function M.attach(bufnr, lang)
end
function M.detach(bufnr)
local buf = bufnr or api.nvim_get_current_buf()
if M.highlighters[buf] then
M.highlighters[buf]:set_query("")
M.highlighters[buf] = nil
if M.highlighters[bufnr] then
M.highlighters[bufnr]:set_query("")
M.highlighters[bufnr] = nil
end
api.nvim_buf_set_option(buf, 'syntax', 'on')
api.nvim_buf_set_option(bufnr, 'syntax', 'on')
end
return M