mirror of
https://github.com/stevearc/aerial.nvim
synced 2024-09-16 14:34:08 +02:00
Address #5: allow window placement at edge of editor
This commit is contained in:
parent
a8b4ff6f8e
commit
70a6820708
6 changed files with 35 additions and 10 deletions
|
@ -95,6 +95,10 @@ vim.g.aerial = {
|
|||
-- different buffer in the way of the preferred direction
|
||||
default_direction = 'prefer_right',
|
||||
|
||||
-- Set to true to only open aerial at the far right/left of the editor
|
||||
-- Default behavior opens aerial relative to current window
|
||||
placement_editor_edge = false,
|
||||
|
||||
-- Fetch document symbols when LSP diagnostics change.
|
||||
-- If you set this to false, you will need to manually fetch symbols
|
||||
diagnostics_trigger_update = true,
|
||||
|
|
|
@ -112,6 +112,11 @@ g:aerial_default_direction *g:aerial_default_direction
|
|||
prefer_right Open to the right unless there are other windows right
|
||||
and none to the left (default)
|
||||
|
||||
g:aerial_placement_editor_edge *g:aerial_placement_editor_edge*
|
||||
If `true`, only open aerial at the far right/left of the editor. Default
|
||||
behavior will open aerial as far right/left as possible while remaining
|
||||
adjacent to a window containing the source buffer.
|
||||
|
||||
g:aerial_diagnostics_trigger_update *g:aerial_diagnostics_trigger_update*
|
||||
Call |vim.lsp.buf.document_symbol()| to update symbols whenenever the LSP
|
||||
client receives diagnostics. Default `true`.
|
||||
|
|
1
doc/tags
1
doc/tags
|
@ -51,6 +51,7 @@ g:aerial_nerd_font aerial.txt /*g:aerial_nerd_font*
|
|||
g:aerial_open_automatic aerial.txt /*g:aerial_open_automatic*
|
||||
g:aerial_open_automatic_min_lines aerial.txt /*g:aerial_open_automatic_min_lines*
|
||||
g:aerial_open_automatic_min_symbols aerial.txt /*g:aerial_open_automatic_min_symbols*
|
||||
g:aerial_placement_editor_edge aerial.txt /*g:aerial_placement_editor_edge*
|
||||
g:aerial_post_jump_cmd aerial.txt /*g:aerial_post_jump_cmd*
|
||||
g:aerial_update_when_errors aerial.txt /*g:aerial_update_when_errors*
|
||||
symbol aerial.txt /*symbol*
|
||||
|
|
|
@ -20,6 +20,10 @@ local default_options = {
|
|||
-- different buffer in the way of the preferred direction
|
||||
default_direction = 'prefer_right',
|
||||
|
||||
-- Set to true to only open aerial at the far right/left of the editor
|
||||
-- Default behavior opens aerial relative to current window
|
||||
placement_editor_edge = false,
|
||||
|
||||
-- Fetch document symbols when LSP diagnostics change.
|
||||
-- If you set this to false, you will need to manually fetch symbols
|
||||
diagnostics_trigger_update = true,
|
||||
|
|
|
@ -153,25 +153,31 @@ M.detect_split_direction = function(bufnr)
|
|||
elseif default == 'right' then
|
||||
return 'right'
|
||||
end
|
||||
if not bufnr or bufnr == 0 then
|
||||
bufnr = vim.api.nvim_get_current_buf()
|
||||
end
|
||||
local wins = M.get_fixed_wins()
|
||||
local first_window = vim.fn.winbufnr(wins[1]) == bufnr
|
||||
local last_window = vim.fn.winbufnr(wins[#wins]) == bufnr
|
||||
local left_available, right_available
|
||||
if config.placement_editor_edge then
|
||||
left_available = not M.is_aerial_buffer(vim.api.nvim_win_get_buf(wins[1]))
|
||||
right_available = not M.is_aerial_buffer(vim.api.nvim_win_get_buf(wins[#wins]))
|
||||
else
|
||||
if not bufnr or bufnr == 0 then
|
||||
bufnr = vim.api.nvim_get_current_buf()
|
||||
end
|
||||
left_available = vim.api.nvim_win_get_buf(wins[1]) == bufnr
|
||||
right_available = vim.api.nvim_win_get_buf(wins[#wins]) == bufnr
|
||||
end
|
||||
|
||||
if default == 'prefer_left' then
|
||||
if first_window then
|
||||
if left_available then
|
||||
return 'left'
|
||||
elseif last_window then
|
||||
elseif right_available then
|
||||
return 'right'
|
||||
else
|
||||
return 'left'
|
||||
end
|
||||
else
|
||||
if last_window then
|
||||
if right_available then
|
||||
return 'right'
|
||||
elseif first_window then
|
||||
elseif left_available then
|
||||
return 'left'
|
||||
else
|
||||
return 'right'
|
||||
|
|
|
@ -63,7 +63,12 @@ local function create_aerial_window(bufnr, aer_bufnr, direction, existing_win)
|
|||
end
|
||||
local my_winid = vim.api.nvim_get_current_win()
|
||||
if not existing_win then
|
||||
local winids = util.get_fixed_wins(bufnr)
|
||||
local winids
|
||||
if config.placement_editor_edge then
|
||||
winids = util.get_fixed_wins()
|
||||
else
|
||||
winids = util.get_fixed_wins(bufnr)
|
||||
end
|
||||
local split_target
|
||||
if direction == 'left' then
|
||||
split_target = winids[1]
|
||||
|
|
Loading…
Reference in a new issue