ui: Check if FocusedSymbol highlight exists before creating it

This way, users / themes can set their own
Closes #2
This commit is contained in:
simrat39
2021-04-24 19:15:36 -07:00
parent ae5f990f01
commit e03a9aee80

View File

@@ -18,7 +18,6 @@ end
function M.add_hover_highlight(bufnr, line, col_start) function M.add_hover_highlight(bufnr, line, col_start)
vim.api.nvim_buf_add_highlight(bufnr, M.hovered_hl_ns, "FocusedSymbol", vim.api.nvim_buf_add_highlight(bufnr, M.hovered_hl_ns, "FocusedSymbol",
line, col_start, -1) line, col_start, -1)
end end
local function highlight_text(name, text, hl_group) local function highlight_text(name, text, hl_group)
@@ -37,7 +36,13 @@ function M.setup_highlights()
local symbol = symbols[value] local symbol = symbols[value]
highlight_text(value, symbol.icon, symbol.hl) highlight_text(value, symbol.icon, symbol.hl)
end end
vim.cmd('hi FocusedSymbol term=italic,bold cterm=italic ctermbg=yellow ctermfg=darkblue gui=bold,italic guibg=yellow guifg=darkblue')
-- 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 end
return M return M