From 260227983a013d1b5f7acad3d224d7fbf742c8ec Mon Sep 17 00:00:00 2001 From: simrat39 Date: Tue, 27 Jul 2021 15:27:54 -0700 Subject: [PATCH] feat: Add width option * This is relative to the size of the current split --- README.md | 2 ++ lua/symbols-outline.lua | 2 +- lua/symbols-outline/config.lua | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 443f0d0..700a4c8 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ vim.g.symbols_outline = { show_guides = true, auto_preview = true, position = 'right', + width = 25, show_numbers = false, show_relative_numbers = false, show_symbol_details = true, @@ -81,6 +82,7 @@ vim.g.symbols_outline = { | highlight_hovered_item | Whether to highlight the currently hovered symbol (high cpu usage) | boolean | true | | show_guides | Wether to show outline guides | boolean | true | | position | Where to open the split window | 'right' or 'left' | 'right' | +| width | How big the window is (relative to the current split) | int | 25 | | auto_preview | Show a preview of the code on hover | boolean | true | | show_numbers | Shows numbers with the outline | boolean | false | | show_relative_numbers | Shows relative numbers with the outline | boolean | false | diff --git a/lua/symbols-outline.lua b/lua/symbols-outline.lua index d1584a4..4f5eb5a 100644 --- a/lua/symbols-outline.lua +++ b/lua/symbols-outline.lua @@ -198,7 +198,7 @@ local function setup_buffer() local current_win_width = vim.api.nvim_win_get_width(current_win) 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 * config.get_width_percentage())) 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 bb96938..a59aa5c 100644 --- a/lua/symbols-outline/config.lua +++ b/lua/symbols-outline/config.lua @@ -6,6 +6,7 @@ local defaults = { highlight_hovered_item = true, show_guides = true, position = 'right', + width = 25, auto_preview = true, show_numbers = false, show_relative_numbers = false, @@ -64,6 +65,10 @@ function M.get_position_navigation_direction() end end +function M.get_width_percentage() + return M.options.width / 100 +end + function M.get_split_command() if M.options.position == 'left' then return "topleft vs"