mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-02 19:46:58 -04:00
feat/refacto: improve configurations
- You should now get the configs through functions - Configs for languages are now inside a local object called parsers - You can get the parser installation configurations with `get_parser_configs` - A new object has been initialized inside configs to specify module config (called config). - Provide functions to enable/disable a module on one buffer - Provide functions to enable/disable a module on all buffers, and if filetype is specified, for specific filetype - Provide function to determine if module is activated for a specified filetype
This commit is contained in:
parent
b7fdd6ae38
commit
62786ec7c6
8 changed files with 453 additions and 112 deletions
|
|
@ -1,12 +1,12 @@
|
|||
local api = vim.api
|
||||
local queries = require'nvim-treesitter.query'
|
||||
local ts = vim.treesitter
|
||||
local queries = require'nvim-treesitter.query'
|
||||
|
||||
local M = {
|
||||
highlighters={}
|
||||
highlighters = {}
|
||||
}
|
||||
|
||||
function M.setup(bufnr, ft)
|
||||
function M.attach(bufnr, ft)
|
||||
local buf = bufnr or api.nvim_get_current_buf()
|
||||
local ft = ft or api.nvim_buf_get_option(buf, 'ft')
|
||||
|
||||
|
|
@ -16,4 +16,13 @@ function M.setup(bufnr, ft)
|
|||
M.highlighters[buf] = ts.TSHighlighter.new(query, buf, ft)
|
||||
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
|
||||
end
|
||||
api.nvim_buf_set_option(buf, 'syntax', 'on')
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue