From 4c549cd9ac30f0338e82d6b6582071412c4e3bd8 Mon Sep 17 00:00:00 2001 From: Iron-E <36409591+Iron-E@users.noreply.github.com> Date: Tue, 9 May 2023 19:25:43 +0000 Subject: [PATCH] feat: `BufferSignRight` highlight (#485) * feat: `BufferSignRight` * docs: `BufferSignRight` --- README.md | 31 ++++++++++++++++--------------- doc/barbar.txt | 33 +++++++++++++++++---------------- lua/barbar/highlight.lua | 14 +++++++++----- lua/barbar/ui/render.lua | 13 ++++++++----- 4 files changed, 50 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index c6ee1873..5bc59fcd 100644 --- a/README.md +++ b/README.md @@ -395,21 +395,22 @@ Highlight groups are created in this way: `Buffer`. | `Inactive` | `:h hidden-buffer`s and `:h inactive-buffer`s. | | `Visible` | `:h active-buffer`s which are not alternate or current. | -| `` | Meaning | -|:----------|:-------------------------------------------------------------------------------------| -| `ADDED` | Git status added. | -| `CHANGED` | Git status changed. | -| `DELETED` | Git status deleted. | -| `ERROR` | Diagnostic errors. | -| `HINT` | Diagnostic hints. | -| `Icon` | The filetype icon (when `icons.filetype == {custom_colors = true, enabled = true}`). | -| `Index` | The buffer's position in the tabline. | -| `INFO` | Diagnostic info. | -| `Mod` | When the buffer is modified. | -| `Number` | The `:h bufnr()`. | -| `Sign` | The separator between buffers. | -| `Target` | The letter in buffer-pick mode. | -| `WARN` | Diagnostic warnings. | +| `` | Meaning | +|:---------------|:-------------------------------------------------------------------------------------| +| `ADDED` | Git status added. | +| `CHANGED` | Git status changed. | +| `DELETED` | Git status deleted. | +| `ERROR` | Diagnostic errors. | +| `HINT` | Diagnostic hints. | +| `Icon` | The filetype icon (when `icons.filetype == {custom_colors = true, enabled = true}`). | +| `Index` | The buffer's position in the tabline. | +| `INFO` | Diagnostic info. | +| `Mod` | When the buffer is modified. | +| `Number` | The `:h bufnr()`. | +| `Sign` | The separator between buffers. | +| `SignRight` | The separator between buffers. | +| `Target` | The letter in buffer-pick mode. | +| `WARN` | Diagnostic warnings. | * e.g. the current buffer's highlight when modified is `BufferCurrentMod` diff --git a/doc/barbar.txt b/doc/barbar.txt index c1ab44d9..d90ca815 100644 --- a/doc/barbar.txt +++ b/doc/barbar.txt @@ -93,22 +93,23 @@ Highlight groups are created in this way: `Buffer`. `Inactive` |hidden-buffer|s and |inactive-buffer|s. `Visible` |active-buffer|s which are not alternate or current. -`` Meaning ------- ----------------------- -`ADDED` Git status added. -`CHANGED` Git status changed. -`DELETED` Git status deleted. -`ERROR` Diagnostic errors. -`HINT` Diagnostic hints. -`Icon` The filetype icon - (when `icons.filetype == {custom_colors = true, enabled = true}`). -`Index` The buffer's position in the tabline. -`INFO` Diagnostic info. -`Mod` When the buffer is modified. -`Number` The |bufnr()|. -`Sign` The separator between buffers. -`Target` The letter in buffer-pick mode. -`WARN` Diagnostic warnings. +`` Meaning +------ ----------------------- +`ADDED` Git status added. +`CHANGED` Git status changed. +`DELETED` Git status deleted. +`ERROR` Diagnostic errors. +`HINT` Diagnostic hints. +`Icon` The filetype icon + (when `icons.filetype == {custom_colors = true, enabled = true}`). +`Index` The buffer's position in the tabline. +`INFO` Diagnostic info. +`Mod` When the buffer is modified. +`Number` The |bufnr()|. +`Sign` The separator between buffers. +`SignRight` The separator between buffers. +`Target` The letter in buffer-pick mode. +`WARN` Diagnostic warnings. ============================================================================== 4. Settings *barbar-setup* diff --git a/lua/barbar/highlight.lua b/lua/barbar/highlight.lua index 6161c84f..4109d0b7 100644 --- a/lua/barbar/highlight.lua +++ b/lua/barbar/highlight.lua @@ -17,6 +17,7 @@ hl.set_default_link('BufferAlternateINFO', 'BufferDefaultAlternateINFO') hl.set_default_link('BufferAlternateMod', 'BufferDefaultAlternateMod') hl.set_default_link('BufferAlternateNumber', 'BufferDefaultAlternateNumber') hl.set_default_link('BufferAlternateSign', 'BufferDefaultAlternateSign') +hl.set_default_link('BufferAlternateSignRight', 'BufferAlternateSign') hl.set_default_link('BufferAlternateTarget', 'BufferDefaultAlternateTarget') hl.set_default_link('BufferAlternateWARN', 'BufferDefaultAlternateWARN') @@ -32,6 +33,7 @@ hl.set_default_link('BufferCurrentINFO', 'BufferDefaultCurrentINFO') hl.set_default_link('BufferCurrentMod', 'BufferDefaultCurrentMod') hl.set_default_link('BufferCurrentNumber', 'BufferDefaultCurrentNumber') hl.set_default_link('BufferCurrentSign', 'BufferDefaultCurrentSign') +hl.set_default_link('BufferCurrentSignRight', 'BufferCurrentSign') hl.set_default_link('BufferCurrentTarget', 'BufferDefaultCurrentTarget') hl.set_default_link('BufferCurrentWARN', 'BufferDefaultCurrentWARN') @@ -47,6 +49,7 @@ hl.set_default_link('BufferInactiveINFO', 'BufferDefaultInactiveINFO') hl.set_default_link('BufferInactiveMod', 'BufferDefaultInactiveMod') hl.set_default_link('BufferInactiveNumber', 'BufferDefaultInactiveNumber') hl.set_default_link('BufferInactiveSign', 'BufferDefaultInactiveSign') +hl.set_default_link('BufferInactiveSignRight', 'BufferInactiveSign') hl.set_default_link('BufferInactiveTarget', 'BufferDefaultInactiveTarget') hl.set_default_link('BufferInactiveWARN', 'BufferDefaultInactiveWARN') @@ -68,6 +71,7 @@ hl.set_default_link('BufferVisibleINFO', 'BufferDefaultVisibleINFO') hl.set_default_link('BufferVisibleMod', 'BufferDefaultVisibleMod') hl.set_default_link('BufferVisibleNumber', 'BufferDefaultVisibleNumber') hl.set_default_link('BufferVisibleSign', 'BufferDefaultVisibleSign') +hl.set_default_link('BufferVisibleSignRight', 'BufferVisibleSign') hl.set_default_link('BufferVisibleTarget', 'BufferDefaultVisibleTarget') hl.set_default_link('BufferVisibleWARN', 'BufferDefaultVisibleWARN') @@ -93,15 +97,15 @@ function highlight.setup() local fg_target = {gui = 'red'} --- @type barbar.utils.hl.color fg_target.cterm = fg_target.gui - local fg_error = hl.fg_or_default({'ErrorMsg'}, '#A80000', 124) - local fg_hint = hl.fg_or_default({'HintMsg'}, '#D5508F', 168) - local fg_info = hl.fg_or_default({'InfoMsg'}, '#FFB7B7', 217) - local fg_warn = hl.fg_or_default({'WarningMsg'}, '#FF8900', 208) - local fg_added = hl.fg_or_default({'GitSignsAdd'}, '#59ff5a', 82) local fg_changed = hl.fg_or_default({'GitSignsChange'}, '#599eff', 75) local fg_deleted = hl.fg_or_default({'GitSignsDelete'}, '#A80000', 124) + local fg_error = hl.fg_or_default({'DiagnosticSignError'}, '#A80000', 124) + local fg_hint = hl.fg_or_default({'DiagnosticSignHint'}, '#D5508F', 168) + local fg_info = hl.fg_or_default({'DiagnosticSignInfo'}, '#FFB7B7', 217) + local fg_warn = hl.fg_or_default({'DiagnosticSignWarn'}, '#FF8900', 208) + local fg_modified = hl.fg_or_default({'WarningMsg'}, '#E5AB0E', 178) local fg_special = hl.fg_or_default({'Special'}, '#599eff', 75) local fg_subtle = hl.fg_or_default({'NonText', 'Comment'}, '#555555', 240) diff --git a/lua/barbar/ui/render.lua b/lua/barbar/ui/render.lua index af20ebda..4fedcf3e 100644 --- a/lua/barbar/ui/render.lua +++ b/lua/barbar/ui/render.lua @@ -5,7 +5,6 @@ local max = math.max local min = math.min local table_insert = table.insert -local table_remove = table.remove local buf_get_option = vim.api.nvim_buf_get_option --- @type function local buf_is_valid = vim.api.nvim_buf_is_valid --- @type function @@ -502,10 +501,11 @@ local function get_bufferline_containers(data, bufnrs, refocus) icon.text = #name.text > 0 and iconChar .. ' ' or iconChar end - local hl_sign = wrap_hl('Buffer' .. activity_name .. 'Sign') - --- @type barbar.ui.node - local left_separator = { hl = clickable .. hl_sign, text = icons_option.separator.left } + local left_separator = { + hl = clickable .. wrap_hl('Buffer' .. activity_name .. 'Sign'), + text = icons_option.separator.left, + } --- @type barbar.ui.node local padding = { hl = buffer_hl, text = pinned and pinned_pad_text or unpinned_pad_text } @@ -533,7 +533,10 @@ local function get_bufferline_containers(data, bufnrs, refocus) end) --- @type barbar.ui.node - local right_separator = { hl = left_separator.hl, text = icons_option.separator.right } + local right_separator = { + hl = clickable .. wrap_hl('Buffer' .. activity_name .. 'SignRight'), + text = icons_option.separator.right, + } list_extend(container.nodes, { padding, button, right_separator }) table_insert(pinned and pinned_containers or containers, container)