mirror of
https://github.com/chenasraf/nvim-treesitter.git
synced 2026-05-18 01:39:00 +00:00
- 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
29 lines
977 B
Lua
29 lines
977 B
Lua
local api = vim.api
|
|
local parsers = require'nvim-treesitter.parsers'
|
|
local install = require'nvim-treesitter.install'
|
|
local locals = require'nvim-treesitter.locals'
|
|
local utils = require'nvim-treesitter.utils'
|
|
local info = require'nvim-treesitter.info'
|
|
local configs = require'nvim-treesitter.configs'
|
|
|
|
local M = {}
|
|
|
|
-- This function sets up everythin needed for a given language
|
|
-- this is the main interface through the plugin
|
|
function M.setup(lang)
|
|
utils.setup_commands('install', install.commands)
|
|
utils.setup_commands('info', info.commands)
|
|
utils.setup_commands('configs', configs.commands)
|
|
|
|
for _, ft in pairs(configs.available_parsers()) do
|
|
for _, mod in pairs(configs.available_modules()) do
|
|
if parsers.has_parser(ft) and configs.is_enabled(mod, ft) then
|
|
local cmd = string.format("lua require'nvim-treesitter.%s'.attach()", mod)
|
|
api.nvim_command(string.format("autocmd FileType %s %s", ft, cmd))
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
return M
|