From 1784dcc5207d1613b0ca9a988e87f2e1036bd2a7 Mon Sep 17 00:00:00 2001 From: simrat39 Date: Tue, 27 Jul 2021 15:16:03 -0700 Subject: [PATCH] fix(ui): Use a seperate highlight for connectors * Some colorschemes do some funky things with the comment highlight, most notably making them italic, which messes up the outline connector. Fix this by copying the foreground color from the comment hl into a new highlight. * Closes #42 --- lua/symbols-outline/ui.lua | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/lua/symbols-outline/ui.lua b/lua/symbols-outline/ui.lua index d727193..ea8dc0d 100644 --- a/lua/symbols-outline/ui.lua +++ b/lua/symbols-outline/ui.lua @@ -27,25 +27,40 @@ local function highlight_text(name, text, hl_group) end function M.setup_highlights() + -- Setup the FocusedSymbol highlight group if it hasnt been done already by + -- a theme or manually set + if vim.fn.hlexists('FocusedSymbol') == 0 then + vim.cmd 'hi FocusedSymbol term=italic,bold cterm=italic ctermbg=yellow ctermfg=darkblue gui=bold,italic guibg=yellow guifg=darkblue' + end + + -- Some colorschemes do some funky things with the comment highlight, most + -- notably making them italic, which messes up the outline connector. Fix + -- this by copying the foreground color from the comment hl into a new + -- highlight. + local comment_fg_gui = vim.fn.synIDattr(vim.fn.hlID('SignColumn'), 'fg', + 'gui') + local comment_fg_cterm = vim.fn.synIDattr(vim.fn.hlID('SignColumn'), 'fg', + 'cterm') + + + vim.cmd(string.format('hi SymbolsOutlineConnector ctermfg=%s guifg=%s', + comment_fg_cterm, comment_fg_gui)) + local symbols = config.options.symbols -- markers - highlight_text("marker_middle", M.markers.middle, "Comment") - highlight_text("marker_vertical", M.markers.vertical, "Comment") - highlight_text("markers_horizontal", M.markers.horizontal, "Comment") - highlight_text("markers_bottom", M.markers.bottom, "Comment") + highlight_text("marker_middle", M.markers.middle, "SymbolsOutlineConnector") + highlight_text("marker_vertical", M.markers.vertical, + "SymbolsOutlineConnector") + highlight_text("markers_horizontal", M.markers.horizontal, + "SymbolsOutlineConnector") + highlight_text("markers_bottom", M.markers.bottom, "SymbolsOutlineConnector") for _, value in ipairs(symbol_kinds) do local symbol = symbols[value] highlight_text(value, symbol.icon, symbol.hl) end - -- Setup the FocusedSymbol highlight group if it hasnt been done already by - -- a theme or manually set - if vim.fn.hlexists('FocusedSymbol') == 0 then - vim.cmd( - 'hi FocusedSymbol term=italic,bold cterm=italic ctermbg=yellow ctermfg=darkblue gui=bold,italic guibg=yellow guifg=darkblue') - end end return M