feat: Option for split command
Idea provided by silvercircle, see issue: Closes #8
This commit is contained in:
14
README.md
14
README.md
@@ -169,6 +169,8 @@ Features/Changes:
|
|||||||
- Option to use lspkind for icons, and use your own fetcher function. See
|
- Option to use lspkind for icons, and use your own fetcher function. See
|
||||||
[config](#configuration) and [tips](#tips)
|
[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).
|
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 = {
|
outline_window = {
|
||||||
-- Where to open the split window: right/left
|
-- Where to open the split window: right/left
|
||||||
position = 'right',
|
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
|
-- Percentage or integer of columns
|
||||||
width = 25,
|
width = 25,
|
||||||
-- Whether width is relative to the total width of nvim
|
-- 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
|
A fallback is always used if the previous candidate returned either an empty
|
||||||
string or a falsey value.
|
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
|
## Recipes
|
||||||
|
|
||||||
Behaviour you may want to achieve and the combination of configuration options
|
Behaviour you may want to achieve and the combination of configuration options
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ M.defaults = {
|
|||||||
},
|
},
|
||||||
outline_window = {
|
outline_window = {
|
||||||
position = 'right',
|
position = 'right',
|
||||||
|
split_command = nil,
|
||||||
width = 25,
|
width = 25,
|
||||||
relative_width = true,
|
relative_width = true,
|
||||||
wrap = false,
|
wrap = false,
|
||||||
@@ -151,6 +152,10 @@ function M.get_preview_width()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.get_split_command()
|
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
|
if M.o.outline_window.position == 'left' then
|
||||||
return 'topleft vs'
|
return 'topleft vs'
|
||||||
else
|
else
|
||||||
@@ -194,6 +199,18 @@ function M.check_config()
|
|||||||
end
|
end
|
||||||
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)
|
function M.setup(options)
|
||||||
vim.g.symbols_outline_loaded = 1
|
vim.g.symbols_outline_loaded = 1
|
||||||
M.o = vim.tbl_deep_extend('force', {}, M.defaults, options or {})
|
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
|
M.o.guides = M.defaults.guides
|
||||||
end
|
end
|
||||||
M.check_config()
|
M.check_config()
|
||||||
|
M.resolve_config()
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
Reference in New Issue
Block a user