From 07eb437bb1c4c0a0298553dd509294f82362d6bc Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 16 Apr 2022 17:49:17 +0200 Subject: refactor!: update to Neovim 0.7 APIs * set highlight groups via nvim_set_hl * define autocommands via nvim_create_autocmd * port plugin/nvim-treesitter.vim to Lua * port healthcheck to Lua --- lua/nvim-treesitter/configs.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lua/nvim-treesitter/configs.lua') diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua index cc741356..2d64098a 100644 --- a/lua/nvim-treesitter/configs.lua +++ b/lua/nvim-treesitter/configs.lua @@ -100,8 +100,13 @@ local function enable_mod_conf_autocmd(mod) return end - local cmd = string.format("lua require'nvim-treesitter.configs'.reattach_module('%s')", mod) - api.nvim_command(string.format("autocmd NvimTreesitter FileType * %s", cmd)) + api.nvim_create_autocmd("FileType", { + group = "NvimTreesitter", + callback = function() + require("nvim-treesitter.configs").reattach_module(mod) + end, + desc = "Reattach module", + }) config_mod.loaded = true end @@ -150,7 +155,7 @@ local function disable_mod_conf_autocmd(mod) end -- TODO(kyazdani): detach the correct autocmd... doesn't work when using %s, cmd. -- This will remove all autocomands! - api.nvim_command "autocmd! NvimTreesitter FileType *" + api.nvim_clear_autocmds { event = "FileType", group = "NvimTreesitter" } config_mod.loaded = false end -- cgit v1.2.3