feat: Winhl options for outline and preview windows

This commit is contained in:
hedy
2023-11-08 19:15:29 +08:00
parent 8abd2f6e9b
commit 10ee0008ed
6 changed files with 112 additions and 49 deletions

View File

@@ -28,16 +28,16 @@ M.defaults = {
show_numbers = false,
show_relative_numbers = false,
show_cursorline = true,
winhl = "SymbolsOutlineDetails:Comment,SymbolsOutlineLineno:LineNr",
},
preview_window = {
auto_preview = false,
width = 50,
min_width = 50,
relative_width = true,
bg_hl = 'Pmenu',
border = 'single',
border_hl = 'Pmenu',
open_hover_on_preview = true,
winhl = '',
winblend = 0,
},
symbol_folding = {

View File

@@ -94,12 +94,8 @@ local function setup_preview_buf()
end
local function set_bg_hl()
local winhi = 'Normal:' .. cfg.o.preview_window.bg_hl
vim.api.nvim_win_set_option(state.preview_win, 'winhighlight', winhi)
-- vim.api.nvim_win_set_option(state.hover_win, 'winhighlight', winhi)
local winblend = cfg.o.preview_window.winblend
vim.api.nvim_win_set_option(state.preview_win, 'winblend', winblend)
-- vim.api.nvim_win_set_option(state.hover_win, 'winblend', winblend)
vim.api.nvim_win_set_option(state.preview_win, 'winhl', cfg.o.preview_window.winhl)
vim.api.nvim_win_set_option(state.preview_win, 'winblend', cfg.o.preview_window.winblend)
end
local function show_preview()

View File

@@ -10,7 +10,7 @@ function M.add_hover_highlight(bufnr, line, col_start)
vim.api.nvim_buf_add_highlight(
bufnr,
M.hovered_hl_ns,
'FocusedSymbol',
'SymbolsOutlineCurrent',
line,
col_start,
-1
@@ -18,15 +18,15 @@ function M.add_hover_highlight(bufnr, line, col_start)
end
function M.setup_highlights()
-- Setup the FocusedSymbol highlight group if it hasn't been done already by
-- Setup the SymbolsOutlineCurrent highlight group if it hasn't been done already by
-- a theme or manually set
if vim.fn.hlexists 'FocusedSymbol' == 0 then
if vim.fn.hlexists 'SymbolsOutlineCurrent' == 0 then
local cline_hl = vim.api.nvim_get_hl_by_name('CursorLine', true)
local string_hl = vim.api.nvim_get_hl_by_name('String', true)
vim.api.nvim_set_hl(
0,
'FocusedSymbol',
'SymbolsOutlineCurrent',
{ bg = cline_hl.background, fg = string_hl.foreground }
)
end

View File

@@ -31,6 +31,7 @@ function View:setup_view()
vim.api.nvim_win_set_option(self.winnr, 'winfixwidth', true)
vim.api.nvim_win_set_option(self.winnr, 'list', false)
vim.api.nvim_win_set_option(self.winnr, 'wrap', cfg.o.outline_window.wrap)
vim.api.nvim_win_set_option(self.winnr, 'winhl', cfg.o.outline_window.winhl)
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 guides.markers.vertical as part of showbreak to keep

View File

@@ -58,7 +58,7 @@ function M.write_details(bufnr, lines)
for index, value in ipairs(lines) do
vim.api.nvim_buf_set_extmark(bufnr, ns, index - 1, -1, {
virt_text = { { value, 'Comment' } },
virt_text = { { value, 'SymbolsOutlineDetails' } },
virt_text_pos = 'eol',
hl_mode = 'combine',
})
@@ -77,7 +77,7 @@ function M.write_lineno(bufnr, lines, max)
for index, value in ipairs(lines) do
local leftpad = string.rep(' ', maxwidth-#value)
vim.api.nvim_buf_set_extmark(bufnr, ns, index - 1, -1, {
virt_text = { {leftpad..value, 'LineNr' } },
virt_text = { {leftpad..value, 'SymbolsOutlineLineno' } },
virt_text_pos = 'overlay',
virt_text_win_col = 0,
hl_mode = 'combine',