feat(config): Add option to change split position

Default: 'right'
Possible Values: 'right' and 'left'
This commit is contained in:
simrat39
2021-04-24 19:02:01 -07:00
parent 19fd160a66
commit ae5f990f01
2 changed files with 21 additions and 4 deletions

View File

@@ -113,10 +113,10 @@ function M._prevent_buffer_override()
local current_win_width = vim.api.nvim_win_get_width(curwin) local current_win_width = vim.api.nvim_win_get_width(curwin)
if #wins < 2 then if #wins < 2 then
vim.cmd("vsplit") vim.cmd(config.get_split_command())
vim.cmd("vertical resize " .. math.ceil(current_win_width * 0.75)) vim.cmd("vertical resize " .. math.ceil(current_win_width * 0.75))
else else
vim.cmd("wincmd l") vim.cmd("wincmd " .. config.get_position_navigation_direction())
end end
vim.cmd("buffer " .. curbuf) vim.cmd("buffer " .. curbuf)
@@ -164,7 +164,7 @@ local function setup_buffer()
local current_win = vim.api.nvim_get_current_win() local current_win = vim.api.nvim_get_current_win()
local current_win_width = vim.api.nvim_win_get_width(current_win) local current_win_width = vim.api.nvim_win_get_width(current_win)
vim.cmd("vsplit") vim.cmd(config.get_split_command())
vim.cmd("vertical resize " .. math.ceil(current_win_width * 0.25)) vim.cmd("vertical resize " .. math.ceil(current_win_width * 0.25))
M.state.outline_win = vim.api.nvim_get_current_win() M.state.outline_win = vim.api.nvim_get_current_win()
vim.api.nvim_win_set_buf(M.state.outline_win, M.state.outline_buf) vim.api.nvim_win_set_buf(M.state.outline_win, M.state.outline_buf)

View File

@@ -5,10 +5,27 @@ local M = {}
local defaults = { local defaults = {
highlight_hovered_item = true, highlight_hovered_item = true,
show_guides = true, show_guides = true,
position = 'right'
} }
M.options = {} M.options = {}
function M.get_position_navigation_direction()
if M.options.position == 'left' then
return 'h'
else
return 'l'
end
end
function M.get_split_command()
if M.options.position == 'left' then
return "topleft vs"
else
return "vs"
end
end
function M.setup(options) function M.setup(options)
M.options = vim.tbl_deep_extend("force", {}, defaults, options or {}) M.options = vim.tbl_deep_extend("force", {}, defaults, options or {})
end end