fix: Preview window position based on outline split position

- preview window can adapt based on position of outline window, and not
  based on config value of `position` left/right
- it can also properly vertically center-align, even when there are
  horizontal splits below the outline
- fixed a few bugs associated with previous rewrite commits in init.lua

config:
- Added min_height for preview window
This commit is contained in:
hedy
2023-11-18 15:04:26 +08:00
parent 62183f9d51
commit 090da7633b
6 changed files with 112 additions and 102 deletions

View File

@@ -6,15 +6,17 @@ function View:new()
return setmetatable({ bufnr = nil, winnr = nil }, { __index = View })
end
---creates the outline window and sets it up
function View:setup_view()
---Creates the outline window and sets it up
---@param split_command string A valid split command that is to be executed in order to create the view.
function View:setup_view(split_command)
-- create a scratch unlisted buffer
self.bufnr = vim.api.nvim_create_buf(false, true)
-- delete buffer when window is closed / buffer is hidden
vim.api.nvim_buf_set_option(self.bufnr, 'bufhidden', 'delete')
-- create a split
vim.cmd(cfg.get_split_command())
vim.cmd(split_command)
-- resize to a % of the current window size
vim.cmd('vertical resize ' .. cfg.get_window_width())