fix: wq would cause the editor to exit

This commit is contained in:
mpaulson 2023-11-30 16:06:15 -07:00
parent d044315c89
commit 6522b48a4e
4 changed files with 15 additions and 8 deletions

View File

@ -62,13 +62,6 @@ function M.setup_autocmds_and_keymaps(bufnr)
"<Cmd>lua require('harpoon').ui:select_menu_item()<CR>", "<Cmd>lua require('harpoon').ui:select_menu_item()<CR>",
{} {}
) )
-- TODO: Update these to use the new autocmd api
vim.cmd(
string.format(
"autocmd BufWriteCmd <buffer=%s> lua require('harpoon').ui:save()",
bufnr
)
)
-- TODO: Do we want this? is this a thing? -- TODO: Do we want this? is this a thing?
-- its odd... why save on text change? shouldn't we wait until close / w / esc? -- 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" }, { vim.api.nvim_create_autocmd({ "BufLeave" }, {
group = HarpoonGroup, group = HarpoonGroup,
pattern = "__harpoon*", pattern = "__harpoon*",

View File

@ -164,6 +164,7 @@ end
---@param latest_config HarpoonConfig? ---@param latest_config HarpoonConfig?
---@return HarpoonConfig ---@return HarpoonConfig
function M.merge_config(partial_config, latest_config) function M.merge_config(partial_config, latest_config)
partial_config = partial_config or {}
local config = latest_config or M.get_default_config() local config = latest_config or M.get_default_config()
for k, v in pairs(partial_config) do for k, v in pairs(partial_config) do
if k == "settings" then if k == "settings" then

View File

@ -1,3 +1,4 @@
local Path = require("plenary.path")
local Ui = require("harpoon.ui") local Ui = require("harpoon.ui")
local Data = require("harpoon.data") local Data = require("harpoon.data")
local Config = require("harpoon.config") local Config = require("harpoon.config")
@ -144,3 +145,5 @@ function Harpoon:__debug_reset()
end end
return Harpoon:new() return Harpoon:new()

View File

@ -123,7 +123,6 @@ end
function HarpoonUI:save() function HarpoonUI:save()
local list = Buffer.get_contents(self.bufnr) local list = Buffer.get_contents(self.bufnr)
self.active_list:resolve_displayed(list) self.active_list:resolve_displayed(list)
self:close_menu()
end end
---@param settings HarpoonSettings ---@param settings HarpoonSettings