From 5bbdfdaa303c698f060035f37a91eaad8d2f8e27 Mon Sep 17 00:00:00 2001 From: Karl Wang Date: Thu, 3 Feb 2022 20:24:23 -0800 Subject: [PATCH] Detach the currently effective buffer number --- lua/nvim-ts-autotag.lua | 5 ++--- lua/nvim-ts-autotag/internal.lua | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lua/nvim-ts-autotag.lua b/lua/nvim-ts-autotag.lua index c1c3a2b..572fff6 100644 --- a/lua/nvim-ts-autotag.lua +++ b/lua/nvim-ts-autotag.lua @@ -1,5 +1,4 @@ - -local internal= require('nvim-ts-autotag.internal') +local internal = require("nvim-ts-autotag.internal") local M = {} @@ -19,7 +18,7 @@ function M.setup(opts) vim.cmd[[augroup nvim_ts_xmltag]] vim.cmd[[autocmd!]] vim.cmd[[autocmd FileType * call v:lua.require('nvim-ts-autotag.internal').attach()]] - vim.cmd[[autocmd BufDelete * call v:lua.require('nvim-ts-autotag.internal').detach()]] + vim.cmd[[autocmd BufDelete * lua require('nvim-ts-autotag.internal').detach(vim.fn.expand(''))]] vim.cmd[[augroup end]] end diff --git a/lua/nvim-ts-autotag/internal.lua b/lua/nvim-ts-autotag/internal.lua index c9dae9e..75db513 100644 --- a/lua/nvim-ts-autotag/internal.lua +++ b/lua/nvim-ts-autotag/internal.lua @@ -426,8 +426,8 @@ M.attach = function (bufnr,lang) end end -M.detach = function ( ) - local bufnr = vim.api.nvim_get_current_buf() +M.detach = function (bufnr) + bufnr = tonumber(bufnr) or vim.api.nvim_get_current_buf() buffer_tag[bufnr] = nil end