Skip to content

Commit

Permalink
fix: wq would cause the editor to exit
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePrimeagen committed Nov 30, 2023
1 parent d044315 commit 6522b48
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
18 changes: 11 additions & 7 deletions lua/harpoon/buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@ function M.setup_autocmds_and_keymaps(bufnr)
"<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?
-- its odd... why save on text change? shouldn't we wait until close / w / esc?
Expand All @@ -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*",
Expand Down
1 change: 1 addition & 0 deletions lua/harpoon/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lua/harpoon/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local Path = require("plenary.path")
local Ui = require("harpoon.ui")
local Data = require("harpoon.data")
local Config = require("harpoon.config")
Expand Down Expand Up @@ -144,3 +145,5 @@ function Harpoon:__debug_reset()
end

return Harpoon:new()


1 change: 0 additions & 1 deletion lua/harpoon/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6522b48

Please sign in to comment.