Skip to content

Commit

Permalink
feat(pick): add option to ignore first letter usage
Browse files Browse the repository at this point in the history
  • Loading branch information
joaovfsousa committed Oct 22, 2024
1 parent 41f6cbc commit c65508a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions doc/bufferline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ The available configuration are:
end,
pick = {
alphabet = "abcdefghijklmopqrstuvwxyzABCDEFGHIJKLMOPQRSTUVWXYZ1234567890",
use_first_letter = true,
},
}
}
Expand Down Expand Up @@ -674,6 +675,18 @@ alphanumeric characters are used.

With the configuration above, bufferline will only use lowercase letters.

By default, bufferline assigns the first letter of the buffer name if available.
>lua
options = {
pick = {
use_first_letter = false
}
}
<

With the configuration above, bufferline will use the first letter available
in the alphabet.

==============================================================================
MOUSE ACTIONS *bufferline-mouse-actions*

Expand Down
1 change: 1 addition & 0 deletions lua/bufferline/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ local function get_defaults()
debug = { logging = false },
pick = {
alphabet = "abcdefghijklmopqrstuvwxyzABCDEFGHIJKLMOPQRSTUVWXYZ1234567890",
use_first_letter = true,
},
}
return { options = opts, highlights = derive_colors(opts.style_preset) }
Expand Down
3 changes: 2 additions & 1 deletion lua/bufferline/pick.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ function M.get(element)

local is_valid_char = first_letter:match("[" .. config.options.pick.alphabet .. "]")

if not M.current[first_letter] and is_valid_char then
if not M.current[first_letter] and is_valid_char and config.options.pick.use_first_letter then
M.current[first_letter] = element.id
return first_letter
end

for letter in valid_alphabet:gmatch(".") do
if not M.current[letter] then
M.current[letter] = element.id
Expand Down

0 comments on commit c65508a

Please sign in to comment.