mirror of
https://github.com/stevearc/aerial.nvim
synced 2024-09-16 14:34:08 +02:00
feat: pass is_collapsed to get_highlight config function (#257)
This commit is contained in:
parent
01d63e5599
commit
b154c0cbe0
3 changed files with 7 additions and 6 deletions
|
@ -252,7 +252,7 @@ local default_options = {
|
|||
},
|
||||
|
||||
-- Set this function to override the highlight groups for certain symbols
|
||||
get_highlight = function(symbol, is_icon)
|
||||
get_highlight = function(symbol, is_icon, is_collapsed)
|
||||
-- return "MyHighlight" .. symbol.kind
|
||||
end,
|
||||
|
||||
|
|
|
@ -38,14 +38,15 @@ local symbol_kinds = {
|
|||
|
||||
---@param symbol aerial.Symbol
|
||||
---@param is_icon boolean
|
||||
---@param is_collapsed boolean
|
||||
---@return nil|string
|
||||
M.get_highlight = function(symbol, is_icon)
|
||||
local hl_group = config.get_highlight(symbol, is_icon)
|
||||
M.get_highlight = function(symbol, is_icon, is_collapsed)
|
||||
local hl_group = config.get_highlight(symbol, is_icon, is_collapsed)
|
||||
if hl_group then
|
||||
return hl_group
|
||||
end
|
||||
|
||||
-- Default functionality will set the highlight for private and protected symbol names
|
||||
-- If the symbol has a non-public scope, use that as the highlight group (e.g. AerialPrivate)
|
||||
if symbol.scope and not is_icon and symbol.scope ~= "public" then
|
||||
return string.format("Aerial%s", symbol.scope:gsub("^%l", string.upper))
|
||||
end
|
||||
|
|
|
@ -151,7 +151,7 @@ M.update_aerial_buffer = function(buf)
|
|||
end
|
||||
local text = util.remove_newlines(string.format("%s%s %s", spacing, kind, item.name))
|
||||
local text_cols = vim.api.nvim_strwidth(text)
|
||||
local icon_hl = highlight.get_highlight(item, true)
|
||||
local icon_hl = highlight.get_highlight(item, true, collapsed)
|
||||
if icon_hl then
|
||||
table.insert(highlights, {
|
||||
group = icon_hl,
|
||||
|
@ -160,7 +160,7 @@ M.update_aerial_buffer = function(buf)
|
|||
col_end = string_len[spacing] + string_len[kind],
|
||||
})
|
||||
end
|
||||
local name_hl = highlight.get_highlight(item, false)
|
||||
local name_hl = highlight.get_highlight(item, false, collapsed)
|
||||
if name_hl then
|
||||
table.insert(highlights, {
|
||||
group = name_hl,
|
||||
|
|
Loading…
Reference in a new issue