Skip to content

Commit

Permalink
fix(menu): allow relative win settings other than win
Browse files Browse the repository at this point in the history
Ensures `win` key is nil if `win_configs.relative` ~= `"win"`,
and sets the fzf window location relative to the main window instead
of calculating the `relative="editor"` width.
  • Loading branch information
willothy committed Sep 25, 2023
1 parent 8da1555 commit 5cff531
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions lua/dropbar/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,10 @@ function dropbar_menu_t:open_win()
end
self.is_opened = true

if self._win_configs.relative ~= 'win' then
self._win_configs.win = nil
end

self.win = vim.api.nvim_open_win(self.buf, true, self._win_configs)
vim.wo[self.win].scrolloff = 0
vim.wo[self.win].sidescrolloff = 0
Expand Down Expand Up @@ -888,15 +892,26 @@ function dropbar_menu_t:fuzzy_find_open(opts)
col_offset = 1
end

local win = vim.api.nvim_open_win(
buf,
false,
local win_config =
vim.tbl_extend('force', self._win_configs, opts.win_configs or {}, {
row = self._win_configs.row + self._win_configs.height,
col = self._win_configs.col - col_offset,
relative = 'win',
win = self.win,
row = self._win_configs.height,
col = col_offset,
height = 1,
})
)
-- don't show title in the fzf window
win_config.title = nil
win_config.title_pos = nil

-- hide the top border if possible
if type(win_config.border) == 'table' then
win_config.border[1] = ''
win_config.border[2] = ''
win_config.border[3] = ''
end

local win = vim.api.nvim_open_win(buf, false, win_config)
vim.wo[win].stc = opts.prompt
_G.dropbar.menus[win] = self
self.fzf_state = utils.fzf.fzf_state_t:new(self, win, opts)
Expand Down

0 comments on commit 5cff531

Please sign in to comment.