feat: #372 -- configurable fallback width and width ratio

This commit is contained in:
mpaulson 2023-12-05 07:35:01 -07:00
parent e2e582e776
commit 23fe6410bc
2 changed files with 6 additions and 3 deletions

View File

@ -27,6 +27,8 @@ M.DEFAULT_LIST = DEFAULT_LIST
---@class HarpoonSettings
---@field border_chars string[] defaults to { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }
---@field save_on_toggle boolean defaults to true
---@field ui_fallback_width number defaults 69, nice
---@field ui_width_ratio number defaults to 0.62569
---@field key (fun(): string)
---@class HarpoonPartialSettings
@ -55,6 +57,8 @@ function M.get_default_config()
settings = {
save_on_toggle = false,
border_chars = { "", "", "", "", "", "", "", "" },
ui_fallback_width = 69,
ui_width_ratio = 0.62569,
key = function()
return vim.loop.cwd()
end,

View File

@ -1,7 +1,6 @@
local popup = require("plenary").popup
local Buffer = require("harpoon.buffer")
local Logger = require("harpoon.logger")
local DEFAULT_WINDOW_WIDTH = 69 -- nice
---@class HarpoonUI
---@field win_id number
@ -69,11 +68,11 @@ end
function HarpoonUI:_create_window()
local win = vim.api.nvim_list_uis()
local width = DEFAULT_WINDOW_WIDTH
local width = self.settings.ui_fallback_width
if #win > 0 then
-- no ackshual reason for 0.62569, just looks complicated, and i want
-- to make my boss think i am smart
width = math.floor(win[1].width * 0.62569)
width = math.floor(win[1].width * self.settings.ui_width_ratio)
end
local height = 8