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
|
||||
|
||||
- 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
|
||||
|
||||
@@ -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,
|
||||
somewhat like `:LspInfo`.
|
||||
|
||||
- BREAKING: Marker icons used for guides can now be customized. `show_guides`
|
||||
deprecated in favor of `guides.enabled`.
|
||||
|
||||
Fixes:
|
||||
|
||||
- Fix symbol preview (simrat39/symbols-outline.nvim#176)
|
||||
@@ -284,8 +288,16 @@ local opts = {
|
||||
|
||||
-- Whether to highlight the currently hovered symbol (high cpu usage)
|
||||
highlight_hovered_item = true,
|
||||
-- Whether to show outline guides
|
||||
show_guides = true,
|
||||
-- Options for outline guides
|
||||
guides = {
|
||||
enabled = true,
|
||||
markers = {
|
||||
bottom = '└',
|
||||
middle = '├',
|
||||
vertical = '│',
|
||||
horizontal = '─',
|
||||
},
|
||||
},
|
||||
-- Automatically open preview of code on hover
|
||||
auto_preview = false,
|
||||
-- Automatically open hover_symbol when opening toggle_preview (see keymaps).
|
||||
|
||||
@@ -6,7 +6,15 @@ M.defaults = {
|
||||
position = 'right',
|
||||
width = 25,
|
||||
highlight_hovered_item = true,
|
||||
show_guides = true,
|
||||
guides = {
|
||||
enabled = true,
|
||||
markers = {
|
||||
bottom = '└',
|
||||
middle = '├',
|
||||
vertical = '│',
|
||||
horizontal = '─',
|
||||
},
|
||||
},
|
||||
border = 'single',
|
||||
relative_width = true,
|
||||
auto_close = false,
|
||||
|
||||
@@ -113,19 +113,21 @@ function M.get_lines(flattened_outline_items)
|
||||
|
||||
for index, _ in ipairs(line) do
|
||||
-- all items start with a space (or two)
|
||||
if config.options.show_guides then
|
||||
-- makes the guides
|
||||
if config.options.guides.enabled then
|
||||
-- makes the guides and add guide markers
|
||||
local guide_markers = config.options.guides.markers
|
||||
if index == 1 then
|
||||
line[index] = ' '
|
||||
-- if index is last, add a bottom marker if current item is last,
|
||||
-- else add a middle marker
|
||||
elseif index == #line then
|
||||
-- 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
|
||||
line[index] = config.options.fold_markers[1]
|
||||
line[index] = fold_markers[1]
|
||||
else
|
||||
line[index] = config.options.fold_markers[2]
|
||||
line[index] = fold_markers[2]
|
||||
end
|
||||
|
||||
add_guide_hl(
|
||||
@@ -136,16 +138,16 @@ function M.get_lines(flattened_outline_items)
|
||||
-- the root level has no vertical markers
|
||||
elseif depth > 1 then
|
||||
if node.isLast then
|
||||
line[index] = ui.markers.bottom
|
||||
line[index] = guide_markers.bottom
|
||||
add_guide_hl(
|
||||
running_length,
|
||||
running_length + vim.fn.strlen(ui.markers.bottom) - 1
|
||||
running_length + vim.fn.strlen(guide_markers.bottom) - 1
|
||||
)
|
||||
else
|
||||
line[index] = ui.markers.middle
|
||||
line[index] = guide_markers.middle
|
||||
add_guide_hl(
|
||||
running_length,
|
||||
running_length + vim.fn.strlen(ui.markers.middle) - 1
|
||||
running_length + vim.fn.strlen(guide_markers.middle) - 1
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -153,11 +155,11 @@ function M.get_lines(flattened_outline_items)
|
||||
-- vertical marker because there are items under us and we need
|
||||
-- to point to those
|
||||
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(
|
||||
running_length - 1 + 2 * marker_space,
|
||||
running_length
|
||||
+ vim.fn.strlen(ui.markers.vertical)
|
||||
+ vim.fn.strlen(guide_markers.vertical)
|
||||
- 1
|
||||
+ 2 * marker_space
|
||||
)
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
local M = {}
|
||||
|
||||
M.markers = {
|
||||
bottom = '└',
|
||||
middle = '├',
|
||||
vertical = '│',
|
||||
horizontal = '─',
|
||||
}
|
||||
|
||||
M.hovered_hl_ns = vim.api.nvim_create_namespace 'hovered_item'
|
||||
|
||||
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, 'linebreak', 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
|
||||
-- color, apart from globally overriding hl-NonText, which will potentially
|
||||
-- mess with other theme/user settings. So just use empty spaces for now.
|
||||
|
||||
Reference in New Issue
Block a user