mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
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:
parent
46cace42fa
commit
27d8fdc6a6
1 changed files with 1 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue