From 6522b48a4e58fe08e9ebe6b939b9cfc38420b695 Mon Sep 17 00:00:00 2001 From: mpaulson Date: Thu, 30 Nov 2023 16:06:15 -0700 Subject: [PATCH] fix: wq would cause the editor to exit --- lua/harpoon/buffer.lua | 18 +++++++++++------- lua/harpoon/config.lua | 1 + lua/harpoon/init.lua | 3 +++ lua/harpoon/ui.lua | 1 - 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lua/harpoon/buffer.lua b/lua/harpoon/buffer.lua index b08b72b9..1c6f6232 100644 --- a/lua/harpoon/buffer.lua +++ b/lua/harpoon/buffer.lua @@ -62,13 +62,6 @@ function M.setup_autocmds_and_keymaps(bufnr) "lua require('harpoon').ui:select_menu_item()", {} ) - -- TODO: Update these to use the new autocmd api - vim.cmd( - string.format( - "autocmd BufWriteCmd lua require('harpoon').ui:save()", - bufnr - ) - ) -- TODO: Do we want this? is this a thing? -- its odd... why save on text change? shouldn't we wait until close / w / esc? @@ -89,6 +82,17 @@ function M.setup_autocmds_and_keymaps(bufnr) ) ) + vim.api.nvim_create_autocmd({ "BufWriteCmd" }, { + group = HarpoonGroup, + pattern = "__harpoon*", + callback = function() + require("harpoon").ui:save() + vim.schedule(function() + require("harpoon").ui:toggle_quick_menu() + end) + end + }) + vim.api.nvim_create_autocmd({ "BufLeave" }, { group = HarpoonGroup, pattern = "__harpoon*", diff --git a/lua/harpoon/config.lua b/lua/harpoon/config.lua index daaf028c..54d7a771 100644 --- a/lua/harpoon/config.lua +++ b/lua/harpoon/config.lua @@ -164,6 +164,7 @@ end ---@param latest_config HarpoonConfig? ---@return HarpoonConfig function M.merge_config(partial_config, latest_config) + partial_config = partial_config or {} local config = latest_config or M.get_default_config() for k, v in pairs(partial_config) do if k == "settings" then diff --git a/lua/harpoon/init.lua b/lua/harpoon/init.lua index 20530dfc..12ed8104 100644 --- a/lua/harpoon/init.lua +++ b/lua/harpoon/init.lua @@ -1,3 +1,4 @@ +local Path = require("plenary.path") local Ui = require("harpoon.ui") local Data = require("harpoon.data") local Config = require("harpoon.config") @@ -144,3 +145,5 @@ function Harpoon:__debug_reset() end return Harpoon:new() + + diff --git a/lua/harpoon/ui.lua b/lua/harpoon/ui.lua index 20cc5462..1543d3f2 100644 --- a/lua/harpoon/ui.lua +++ b/lua/harpoon/ui.lua @@ -123,7 +123,6 @@ end function HarpoonUI:save() local list = Buffer.get_contents(self.bufnr) self.active_list:resolve_displayed(list) - self:close_menu() end ---@param settings HarpoonSettings