Compare commits

...

2 Commits

Author SHA1 Message Date
fdgdgerg
fb183bf479
Merge c54176b532 into 1cca23c9da 2024-12-18 01:18:29 +00:00
JoeDaBu
c54176b532 fixed a bug where changing to a new buffer enabled autotag 2024-12-17 17:18:24 -08:00
2 changed files with 15 additions and 9 deletions

View File

@ -172,13 +172,8 @@ end
--- Do general plugin setup
---@param opts nvim-ts-autotag.PluginSetup?
function Setup.setup(config)
if config then
Setup.opts = config.opts
opts = Setup.opts
else
opts = {}
end
function Setup.setup(opts)
opts = opts or {}
if Setup.did_setup() then
return
end
@ -243,4 +238,8 @@ function Setup.get_opts(filetype)
return Setup.opts
end
function Setup.toggle()
Setup.get_opts().enable = not Setup.get_opts().enable
end
return Setup

View File

@ -470,6 +470,11 @@ M.attach = function(bufnr)
if TagConfigs:get(vim.bo.filetype) ~= nil then
setup_ts_tag()
-- this uses a new instance of opts from a new call to Setup
-- vim.notify('function#if#if Setup.opts.enable: ' .. vim.inspect(Setup.opts)) -- __AUTO_GENERATED_PRINT_VAR_END__
if not Setup.get_opts().enable then
return
end
local group = vim.api.nvim_create_augroup("nvim-ts-autotag-" .. bufnr, { clear = true })
if Setup.get_opts(vim.bo.filetype).enable_close then
vim.keymap.set("i", ">", function()
@ -576,11 +581,13 @@ function M.buffers()
end
M.toggle = function()
Setup.opts.enable = not Setup.opts.enable
if Setup.opts.enable then
Setup.toggle()
if Setup.get_opts().enable then
M.enable()
vim.notify('autotag toggled on')
else
M.disable()
vim.notify('autotag toggled off')
end
end