Skip to content

Commit

Permalink
feat(config): allow specifying style presets
Browse files Browse the repository at this point in the history
This adds the concept of presets for the bufferline. It's already quite
configurable so I don't intend to have loads but this can be an easy way
to have certain preference e.g. a "minimal" preference which makes the
bg and fg colours the same so only the buffer text is shown

This could also include things like `no_italics` and `no_bold` so there
is an easier way to disable these

chore(config): move and rename highlight resolver

helper function
  • Loading branch information
akinsho committed Apr 20, 2023
1 parent f2c0c3f commit 13cb114
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 111 deletions.
22 changes: 21 additions & 1 deletion doc/bufferline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Usage..................................: |bufferline-usage|
Configuration..........................: |bufferline-configuration|
Hover Events...........................: |bufferline-hover-events|
Styling................................: |bufferline-styling|
Style Presets..........................: |bufferline-style-presets|
Tabpages...............................: |bufferline-tabpages|
Numbers................................: |bufferline-numbers|
LSP Diagnostics........................: |bufferline-diagnostics|
Expand Down Expand Up @@ -63,9 +64,11 @@ CONFIGURATION *bufferline-configuration*

The available configuration are:
>lua
require('bufferline').setup {
local bufferline = require('bufferline')
bufferline.setup {
options = {
mode = "buffers", -- set to "tabs" to only show tabpages instead
style_preset = bufferline.presets.default, -- or bufferline.presets.minimal,
themable = true | false, -- allows highlight groups to be overriden i.e. sets highlights as default
numbers = "none" | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string,
close_command = "bdelete! %d", -- can be a string | function, | false see "Mouse actions"
Expand Down Expand Up @@ -202,7 +205,24 @@ You can change the appearance of the bufferline separators by setting the
used as the separators e.g. `{"|", "|"}`, the first is the left and the
second is the right separator

==============================================================================
STYLE PRESETS *bufferline-style-presets*

You also use one of the pre-defined rulesets i.e. preset for the bufferline
e.g. you can remove all bold text by setting the `options.style_preset` to
`require('bufferline').presets.no_bold` or `no_italics`.
There are also stylist presets such as `minimal` which makes the foreground
match the background so that only the text of the buffers is visible and the
bufferline is more unobtrusive.

e.g.
>lua
options = {
style_preset = require('bufferline').preset.no_italics,
-- or you can combine these e.g.
style_preset = {require('bufferline').preset.no_italics, require('bufferline').preset.no_bold},
}
<
==============================================================================
TABPAGES *bufferline-tabpages*

Expand Down
2 changes: 2 additions & 0 deletions lua/bufferline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ local M = {
sort_buffers_by = commands.sort_by,
close_buffer_with_pick = commands.close_with_pick,
unpin_and_close = commands.unpin_and_close,

style_preset = config.STYLE_PRESETS,
}
-----------------------------------------------------------------------------//
-- Helpers
Expand Down
Loading

0 comments on commit 13cb114

Please sign in to comment.