diff --git a/lua/nvim-ts-autotag/config/plugin.lua b/lua/nvim-ts-autotag/config/plugin.lua index 2cb3690..09d2226 100644 --- a/lua/nvim-ts-autotag/config/plugin.lua +++ b/lua/nvim-ts-autotag/config/plugin.lua @@ -187,6 +187,13 @@ function Setup.setup(opts) TagConfigs:add_alias(new_ft, existing_ft) end local augroup = vim.api.nvim_create_augroup("nvim_ts_xmltag", { clear = true }) + vim.api.nvim_create_autocmd("InsertEnter", { + group = augroup, + once = true, + callback = function(args) + require("nvim-ts-autotag.internal").attach(args.buf) + end, + }) vim.api.nvim_create_autocmd("Filetype", { group = augroup, callback = function(args) diff --git a/lua/nvim-ts-autotag/internal.lua b/lua/nvim-ts-autotag/internal.lua index 98ce103..b816b93 100644 --- a/lua/nvim-ts-autotag/internal.lua +++ b/lua/nvim-ts-autotag/internal.lua @@ -445,6 +445,9 @@ end M.attach = function(bufnr) bufnr = bufnr or vim.api.nvim_get_current_buf() + if buffer_tag[bufnr] then + return + end ---@diagnostic disable-next-line: invisible if not Setup.did_setup() then local _, ts_configs = pcall(require, "nvim-treesitter.configs")