From 8c6ef83d5ba059725265825f72a329757216991c Mon Sep 17 00:00:00 2001 From: jhofscheier Date: Sat, 12 Aug 2023 23:50:17 +0200 Subject: [PATCH] refactor(init): use argument for `BufUnload` callback to get bufnr --- lua/ltex-utils/init.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/ltex-utils/init.lua b/lua/ltex-utils/init.lua index 8f05190..fdf0381 100644 --- a/lua/ltex-utils/init.lua +++ b/lua/ltex-utils/init.lua @@ -7,15 +7,15 @@ local rule_ui = require("ltex-utils.rule_ui") -- Writes current LTeX LSP server settings to file ---@return string|nil # error message if writing to file fails -local function on_exit() +local function on_exit(bufmeta) ---@type integer - local bufnr = vim.api.nvim_get_current_buf() + local bufnr = bufmeta.buf -- delete current buffer from windows list builtin.wins[bufnr] = nil ---@type boolean, string|nil - local ok, err = pcall(ltex.write_ltex_to_file) + local ok, err = pcall(ltex.write_ltex_to_file, bufnr) if not ok then vim.notify("Error on exit: " .. vim.inspect(err), vim.log.levels.ERROR)