fix: do not force syntax=ON on detach

syntax is now restored in vim.treesitter.stop() so we don't need to
force it on here.
This commit is contained in:
Lewis Russell 2023-01-04 13:57:38 +00:00 committed by Lewis Russell
parent 46cace42fa
commit 27d8fdc6a6

View file

@ -1,5 +1,3 @@
local api = vim.api
local configs = require "nvim-treesitter.configs"
local M = {}
@ -14,25 +12,19 @@ local function should_enable_vim_regex(config, lang)
return additional_hl and (not is_table or vim.tbl_contains(additional_hl, lang))
end
---@param bufnr integer
local function enable_syntax(bufnr)
api.nvim_buf_set_option(bufnr, "syntax", "ON")
end
---@param bufnr integer
---@param lang string
function M.attach(bufnr, lang)
local config = configs.get_module "highlight"
vim.treesitter.start(bufnr, lang)
if config and should_enable_vim_regex(config, lang) then
enable_syntax(bufnr)
vim.bo[bufnr].syntax = "ON"
end
end
---@param bufnr integer
function M.detach(bufnr)
vim.treesitter.stop(bufnr)
enable_syntax(bufnr)
end
---@deprecated