diff --git a/lua/symbols-outline.lua b/lua/symbols-outline.lua index a443fec..c2830b0 100644 --- a/lua/symbols-outline.lua +++ b/lua/symbols-outline.lua @@ -113,10 +113,10 @@ function M._prevent_buffer_override() local current_win_width = vim.api.nvim_win_get_width(curwin) if #wins < 2 then - vim.cmd("vsplit") + vim.cmd(config.get_split_command()) vim.cmd("vertical resize " .. math.ceil(current_win_width * 0.75)) else - vim.cmd("wincmd l") + vim.cmd("wincmd " .. config.get_position_navigation_direction()) end vim.cmd("buffer " .. curbuf) @@ -164,7 +164,7 @@ local function setup_buffer() local current_win = vim.api.nvim_get_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)) M.state.outline_win = vim.api.nvim_get_current_win() vim.api.nvim_win_set_buf(M.state.outline_win, M.state.outline_buf) diff --git a/lua/symbols-outline/config.lua b/lua/symbols-outline/config.lua index cacfcfd..17dc574 100644 --- a/lua/symbols-outline/config.lua +++ b/lua/symbols-outline/config.lua @@ -5,12 +5,29 @@ local M = {} local defaults = { highlight_hovered_item = true, show_guides = true, + position = 'right' } 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) - M.options = vim.tbl_deep_extend("force", {}, defaults, options or {}) + M.options = vim.tbl_deep_extend("force", {}, defaults, options or {}) end return M