feat: add sync_on_ui_close option

This commit is contained in:
Will Hopkins 2023-12-09 12:14:30 -08:00
parent 61742f45c8
commit ac9b93984f
No known key found for this signature in database
GPG Key ID: 643B8C585BABBB68
4 changed files with 9 additions and 3 deletions

View File

@ -170,7 +170,8 @@ Settings can alter the experience of harpoon
**Definition**
```lua
---@class HarpoonSettings
---@field save_on_toggle boolean defaults to true
---@field save_on_toggle boolean defaults to false
---@field sync_on_ui_close boolean defaults to false
---@field key (fun(): string)
```
@ -184,6 +185,7 @@ Settings can alter the experience of harpoon
```lua
settings = {
save_on_toggle = false,
sync_on_ui_close = false,
border_chars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
key = function()
return vim.loop.cwd()

View File

@ -27,12 +27,14 @@ M.DEFAULT_LIST = DEFAULT_LIST
---@class HarpoonSettings
---@field border_chars string[] defaults to { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }
---@field save_on_toggle boolean defaults to true
---@field sync_on_ui_close? boolean
---@field ui_fallback_width number defaults 69, nice
---@field ui_width_ratio number defaults to 0.62569
---@field key (fun(): string)
---@class HarpoonPartialSettings
---@field save_on_toggle? boolean
---@field sync_on_ui_close? boolean
---@field key? (fun(): string)
---@class HarpoonConfig
@ -56,6 +58,7 @@ function M.get_default_config()
settings = {
save_on_toggle = false,
sync_on_ui_close = false,
border_chars = {
"",
"",

View File

@ -158,8 +158,6 @@ function HarpoonList:resolve_displayed(displayed)
end
self.items = new_list
require("harpoon"):sync()
end
function HarpoonList:select(index, options)

View File

@ -153,6 +153,9 @@ function HarpoonUI:save()
local list = Buffer.get_contents(self.bufnr)
Logger:log("ui#save", list)
self.active_list:resolve_displayed(list)
if self.settings.sync_on_ui_close then
require("harpoon"):sync()
end
end
---@param settings HarpoonSettings