BREAKING,feat: Customizable guide markers
See readme
This commit is contained in:
18
README.md
18
README.md
@@ -48,7 +48,8 @@ Features/Changes:
|
|||||||
- simrat39/symbols-outline.nvim#207
|
- simrat39/symbols-outline.nvim#207
|
||||||
|
|
||||||
- Feat: when `auto_close=true` only auto close if `goto_location` is used (where
|
- Feat: when `auto_close=true` only auto close if `goto_location` is used (where
|
||||||
focus changed), and not for `focus_location` (simrat39/symbols-outline.nvim#119)
|
focus changed), and not for `focus_location`
|
||||||
|
(simrat39/symbols-outline.nvim#119)
|
||||||
|
|
||||||
- Feat: Cursorline option for the outline window
|
- Feat: Cursorline option for the outline window
|
||||||
|
|
||||||
@@ -64,6 +65,9 @@ focus changed), and not for `focus_location` (simrat39/symbols-outline.nvim#119)
|
|||||||
- Feat: Added function and command to show provider and outline window status,
|
- Feat: Added function and command to show provider and outline window status,
|
||||||
somewhat like `:LspInfo`.
|
somewhat like `:LspInfo`.
|
||||||
|
|
||||||
|
- BREAKING: Marker icons used for guides can now be customized. `show_guides`
|
||||||
|
deprecated in favor of `guides.enabled`.
|
||||||
|
|
||||||
Fixes:
|
Fixes:
|
||||||
|
|
||||||
- Fix symbol preview (simrat39/symbols-outline.nvim#176)
|
- Fix symbol preview (simrat39/symbols-outline.nvim#176)
|
||||||
@@ -284,8 +288,16 @@ local opts = {
|
|||||||
|
|
||||||
-- Whether to highlight the currently hovered symbol (high cpu usage)
|
-- Whether to highlight the currently hovered symbol (high cpu usage)
|
||||||
highlight_hovered_item = true,
|
highlight_hovered_item = true,
|
||||||
-- Whether to show outline guides
|
-- Options for outline guides
|
||||||
show_guides = true,
|
guides = {
|
||||||
|
enabled = true,
|
||||||
|
markers = {
|
||||||
|
bottom = '└',
|
||||||
|
middle = '├',
|
||||||
|
vertical = '│',
|
||||||
|
horizontal = '─',
|
||||||
|
},
|
||||||
|
},
|
||||||
-- Automatically open preview of code on hover
|
-- Automatically open preview of code on hover
|
||||||
auto_preview = false,
|
auto_preview = false,
|
||||||
-- Automatically open hover_symbol when opening toggle_preview (see keymaps).
|
-- Automatically open hover_symbol when opening toggle_preview (see keymaps).
|
||||||
|
|||||||
@@ -6,7 +6,15 @@ M.defaults = {
|
|||||||
position = 'right',
|
position = 'right',
|
||||||
width = 25,
|
width = 25,
|
||||||
highlight_hovered_item = true,
|
highlight_hovered_item = true,
|
||||||
show_guides = true,
|
guides = {
|
||||||
|
enabled = true,
|
||||||
|
markers = {
|
||||||
|
bottom = '└',
|
||||||
|
middle = '├',
|
||||||
|
vertical = '│',
|
||||||
|
horizontal = '─',
|
||||||
|
},
|
||||||
|
},
|
||||||
border = 'single',
|
border = 'single',
|
||||||
relative_width = true,
|
relative_width = true,
|
||||||
auto_close = false,
|
auto_close = false,
|
||||||
|
|||||||
@@ -113,19 +113,21 @@ function M.get_lines(flattened_outline_items)
|
|||||||
|
|
||||||
for index, _ in ipairs(line) do
|
for index, _ in ipairs(line) do
|
||||||
-- all items start with a space (or two)
|
-- all items start with a space (or two)
|
||||||
if config.options.show_guides then
|
if config.options.guides.enabled then
|
||||||
-- makes the guides
|
-- makes the guides and add guide markers
|
||||||
|
local guide_markers = config.options.guides.markers
|
||||||
if index == 1 then
|
if index == 1 then
|
||||||
line[index] = ' '
|
line[index] = ' '
|
||||||
-- if index is last, add a bottom marker if current item is last,
|
-- if index is last, add a bottom marker if current item is last,
|
||||||
-- else add a middle marker
|
-- else add a middle marker
|
||||||
elseif index == #line then
|
elseif index == #line then
|
||||||
-- add fold markers
|
-- add fold markers
|
||||||
if config.options.fold_markers and folding.is_foldable(node) then
|
local fold_markers = config.options.fold_markers
|
||||||
|
if fold_markers and folding.is_foldable(node) then
|
||||||
if folding.is_folded(node) then
|
if folding.is_folded(node) then
|
||||||
line[index] = config.options.fold_markers[1]
|
line[index] = fold_markers[1]
|
||||||
else
|
else
|
||||||
line[index] = config.options.fold_markers[2]
|
line[index] = fold_markers[2]
|
||||||
end
|
end
|
||||||
|
|
||||||
add_guide_hl(
|
add_guide_hl(
|
||||||
@@ -136,16 +138,16 @@ function M.get_lines(flattened_outline_items)
|
|||||||
-- the root level has no vertical markers
|
-- the root level has no vertical markers
|
||||||
elseif depth > 1 then
|
elseif depth > 1 then
|
||||||
if node.isLast then
|
if node.isLast then
|
||||||
line[index] = ui.markers.bottom
|
line[index] = guide_markers.bottom
|
||||||
add_guide_hl(
|
add_guide_hl(
|
||||||
running_length,
|
running_length,
|
||||||
running_length + vim.fn.strlen(ui.markers.bottom) - 1
|
running_length + vim.fn.strlen(guide_markers.bottom) - 1
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
line[index] = ui.markers.middle
|
line[index] = guide_markers.middle
|
||||||
add_guide_hl(
|
add_guide_hl(
|
||||||
running_length,
|
running_length,
|
||||||
running_length + vim.fn.strlen(ui.markers.middle) - 1
|
running_length + vim.fn.strlen(guide_markers.middle) - 1
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -153,11 +155,11 @@ function M.get_lines(flattened_outline_items)
|
|||||||
-- vertical marker because there are items under us and we need
|
-- vertical marker because there are items under us and we need
|
||||||
-- to point to those
|
-- to point to those
|
||||||
elseif not node.hierarchy[index] and depth > 1 then
|
elseif not node.hierarchy[index] and depth > 1 then
|
||||||
line[index + marker_space] = ui.markers.vertical
|
line[index + marker_space] = guide_markers.vertical
|
||||||
add_guide_hl(
|
add_guide_hl(
|
||||||
running_length - 1 + 2 * marker_space,
|
running_length - 1 + 2 * marker_space,
|
||||||
running_length
|
running_length
|
||||||
+ vim.fn.strlen(ui.markers.vertical)
|
+ vim.fn.strlen(guide_markers.vertical)
|
||||||
- 1
|
- 1
|
||||||
+ 2 * marker_space
|
+ 2 * marker_space
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,12 +1,5 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.markers = {
|
|
||||||
bottom = '└',
|
|
||||||
middle = '├',
|
|
||||||
vertical = '│',
|
|
||||||
horizontal = '─',
|
|
||||||
}
|
|
||||||
|
|
||||||
M.hovered_hl_ns = vim.api.nvim_create_namespace 'hovered_item'
|
M.hovered_hl_ns = vim.api.nvim_create_namespace 'hovered_item'
|
||||||
|
|
||||||
function M.clear_hover_highlight(bufnr)
|
function M.clear_hover_highlight(bufnr)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ function View:setup_view()
|
|||||||
vim.api.nvim_win_set_option(self.winnr, 'wrap', config.options.wrap)
|
vim.api.nvim_win_set_option(self.winnr, 'wrap', config.options.wrap)
|
||||||
vim.api.nvim_win_set_option(self.winnr, 'linebreak', true) -- only has effect when wrap=true
|
vim.api.nvim_win_set_option(self.winnr, 'linebreak', true) -- only has effect when wrap=true
|
||||||
vim.api.nvim_win_set_option(self.winnr, 'breakindent', true) -- only has effect when wrap=true
|
vim.api.nvim_win_set_option(self.winnr, 'breakindent', true) -- only has effect when wrap=true
|
||||||
-- Would be nice to use ui.markers.vertical as part of showbreak to keep
|
-- Would be nice to use guides.markers.vertical as part of showbreak to keep
|
||||||
-- continuity of the tree UI, but there's currently no way to style the
|
-- continuity of the tree UI, but there's currently no way to style the
|
||||||
-- color, apart from globally overriding hl-NonText, which will potentially
|
-- color, apart from globally overriding hl-NonText, which will potentially
|
||||||
-- mess with other theme/user settings. So just use empty spaces for now.
|
-- mess with other theme/user settings. So just use empty spaces for now.
|
||||||
|
|||||||
Reference in New Issue
Block a user