Skip to content

Commit

Permalink
feat: Buffer<Activity>SignRight highlight (#485)
Browse files Browse the repository at this point in the history
* feat: `Buffer<Activity>SignRight`

* docs: `Buffer<Activity>SignRight`
  • Loading branch information
Iron-E authored May 9, 2023
1 parent de10307 commit 4c549cd
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 41 deletions.
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,21 +395,22 @@ Highlight groups are created in this way: `Buffer<STATUS><PART>`.
| `Inactive` | `:h hidden-buffer`s and `:h inactive-buffer`s. |
| `Visible` | `:h active-buffer`s which are not alternate or current. |

| `<PART>` | 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. |
| `<PART>` | 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`

Expand Down
33 changes: 17 additions & 16 deletions doc/barbar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,23 @@ Highlight groups are created in this way: `Buffer<STATUS><PART>`.
`Inactive` |hidden-buffer|s and |inactive-buffer|s.
`Visible` |active-buffer|s which are not alternate or current.

`<PART>` 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.
`<PART>` 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*
Expand Down
14 changes: 9 additions & 5 deletions lua/barbar/highlight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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')

Expand All @@ -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')

Expand All @@ -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')

Expand All @@ -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)
Expand Down
13 changes: 8 additions & 5 deletions lua/barbar/ui/render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4c549cd

Please sign in to comment.