feat: Option for split command

Idea provided by silvercircle, see issue:

Closes #8
This commit is contained in:
hedy
2023-11-12 09:42:19 +08:00
parent 58b1bee0be
commit 2746f6f423
2 changed files with 32 additions and 0 deletions

View File

@@ -169,6 +169,8 @@ Features/Changes:
- Option to use lspkind for icons, and use your own fetcher function. See
[config](#configuration) and [tips](#tips)
- Option for outline window split command
Screen recordings/shots of some of the features is shown at the [bottom of the readme](#recipes).
@@ -447,6 +449,15 @@ Default values are shown:
outline_window = {
-- Where to open the split window: right/left
position = 'right',
-- Only in this fork:
-- The default split commands used are 'topleft vs' and 'botright vs'
-- depending on `position`. You can change this by providing your own
-- `split_command`.
-- `position` will not be considered if `split_command` is non-nil.
-- This should be a valid vim command used for opening the split for the
-- outline window. Eg, 'rightbelow vsplit'.
split_command = nil,
-- Percentage or integer of columns
width = 25,
-- Whether width is relative to the total width of nvim
@@ -867,6 +878,9 @@ require'symbols-outline'
A fallback is always used if the previous candidate returned either an empty
string or a falsey value.
- You can customize the split command used for creating the outline window split
using `outline_window.split_command`, such as `"topleft vsp"`. See `:h windows`
## Recipes
Behaviour you may want to achieve and the combination of configuration options

View File

@@ -19,6 +19,7 @@ M.defaults = {
},
outline_window = {
position = 'right',
split_command = nil,
width = 25,
relative_width = true,
wrap = false,
@@ -151,6 +152,10 @@ function M.get_preview_width()
end
function M.get_split_command()
local sc = M.o.outline_window.split_command
if sc then
return sc
end
if M.o.outline_window.position == 'left' then
return 'topleft vs'
else
@@ -194,6 +199,18 @@ function M.check_config()
end
end
function M.resolve_config()
local sc = M.o.outline_window.split_command
if not sc then
return
end
-- This should not be needed, nor is it failsafe. But in case user only provides
-- the, eg, "topleft", we append the ' vs'.
if not sc:find(' vs', 1, true) then
M.o.outline_window.split_command = sc..' vs'
end
end
function M.setup(options)
vim.g.symbols_outline_loaded = 1
M.o = vim.tbl_deep_extend('force', {}, M.defaults, options or {})
@@ -202,6 +219,7 @@ function M.setup(options)
M.o.guides = M.defaults.guides
end
M.check_config()
M.resolve_config()
end
return M