Skip to content

Commit

Permalink
feat: allow to be lazy loaded on InsertEnter (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
lopi-py authored Aug 27, 2024
1 parent 0cb76ee commit e239a56
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lua/nvim-ts-autotag/config/plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions lua/nvim-ts-autotag/internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit e239a56

Please sign in to comment.