mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-16 02:10:15 -04:00
parent
a48c440f2b
commit
7edf1d1c2b
1 changed files with 4 additions and 6 deletions
|
|
@ -5,7 +5,6 @@ local parsers = require'nvim-treesitter.parsers'
|
||||||
local configs = require'nvim-treesitter.configs'
|
local configs = require'nvim-treesitter.configs'
|
||||||
|
|
||||||
local M = {
|
local M = {
|
||||||
highlighters = {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local hlmap = vim.treesitter.highlighter.hl_map
|
local hlmap = vim.treesitter.highlighter.hl_map
|
||||||
|
|
@ -97,15 +96,14 @@ function M.attach(bufnr, lang)
|
||||||
hlmap[k] = v
|
hlmap[k] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
M.highlighters[bufnr] = ts.highlighter.new(parser, {})
|
ts.highlighter.new(parser, {})
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.detach(bufnr)
|
function M.detach(bufnr)
|
||||||
if M.highlighters[bufnr] then
|
if ts.highlighter.active[bufnr] then
|
||||||
M.highlighters[bufnr]:set_query("")
|
ts.highlighter.active[bufnr]:destroy()
|
||||||
M.highlighters[bufnr] = nil
|
|
||||||
end
|
end
|
||||||
api.nvim_buf_set_option(bufnr, 'syntax', 'on')
|
api.nvim_buf_set_option(bufnr, 'syntax', 'ON')
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue