Skip to content

Commit 2579569

Browse files
committed
bufferline_nvim.lua: highlight through colorscheme
now highlight depends on colorscheme instead of hardcoding. PS: code style formatted
1 parent c0e6dff commit 2579569

File tree

1 file changed

+68
-67
lines changed

1 file changed

+68
-67
lines changed

lua/plugins/bufferline_nvim.lua

Lines changed: 68 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ --
23
-- ───────────────────────────────────────────────── --
34
-- Plugin: nvim-bufferline.lua
@@ -12,75 +13,75 @@
1213
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ --
1314
-- ━━━━━━━━━━━━━━━━━━━❰ configs ❱━━━━━━━━━━━━━━━━━━━ --
1415
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ --
16+
1517
require('bufferline').setup {
16-
options = {
17-
numbers = "ordinal", -- "none" | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string
18-
always_show_bufferline = false, -- don't show bufferline if there is only one file is opened
19-
20-
--- @deprecated, please specify numbers as a function to customize the styling
21-
-- number_style = "ssubscript", -- options -> "superscript" | "" | { "none", "subscript" }, buffer_id at index 1, ordinal at index 2
22-
close_command = "bdelete! %d", -- can be a string | function, see "Mouse actions"
23-
right_mouse_command = "bdelete! %d", -- can be a string | function, see "Mouse actions"
24-
left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions"
25-
middle_mouse_command= nil, -- can be a string | function, see "Mouse actions"
26-
27-
-- NOTE: this plugin is designed with this icon in mind,
28-
-- and so changing this is NOT recommended, this is intended
29-
-- as an escape hatch for people who cannot bear it for whatever reason
30-
indicator_icon = '',
31-
-- indicator_icon = '',
32-
buffer_close_icon = '',
33-
modified_icon = '',
34-
close_icon = '',
35-
left_trunc_marker = '',
36-
right_trunc_marker = '',
37-
38-
--- name_formatter can be used to change the buffer's label in the bufferline.
39-
--- Please note some names can/will break the
40-
--- bufferline so use this at your discretion knowing that it has
41-
--- some limitations that will *NOT* be fixed.
42-
name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr"
43-
-- remove extension from markdown files for example
44-
if buf.name:match('%.md') then
45-
return vim.fn.fnamemodify(buf.name, ':t:r')
46-
end
47-
end,
48-
49-
max_name_length = 18,
50-
max_prefix_length = 15, -- prefix used when a buffer is de-duplicate
51-
tab_size = 18,
52-
53-
show_close_icon = false,
54-
show_buffer_icons = true, -- disable filetype icons for buffers
55-
show_buffer_close_icons = false,
56-
show_tab_indicators = false,
57-
58-
view = "multiwindow",
59-
-- can also be a table containing 2 custom separators
60-
-- [focused and unfocused]. eg: { '|', '|' }
61-
separator_style = {"", ""}, -- options "slant" | "thick" | "thin" | { 'any', 'any' },
62-
offsets = {
63-
-- options function , text_" "h always_show_bufferline = false
64-
{
65-
filetype = "NvimTree",
66-
text = "Explorer",
67-
text_align = "left"
68-
}
69-
}
70-
},
71-
72-
highlights = {
73-
74-
fill = {guibg = "#21252d"},
75-
background = {guifg = '#FFFFFF', guibg = "#21252d"},
76-
separator = {guifg = "#141414"},
77-
separator_selected = {guifg = "#060606"},
78-
close_button_selected = {guibg = "#21252d", guifg = "#F1252d"}
79-
80-
}
18+
options = {
19+
numbers = "ordinal", -- "none" | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string
20+
always_show_bufferline = false, -- don't show bufferline if there is only one file is opened
21+
22+
close_command = "bdelete! %d", -- can be a string | function, see "Mouse actions"
23+
right_mouse_command = "bdelete! %d", -- can be a string | function, see "Mouse actions"
24+
left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions"
25+
middle_mouse_command = nil, -- can be a string | function, see "Mouse actions"
26+
27+
-- NOTE: this plugin is designed with this icon in mind,
28+
-- and so changing this is NOT recommended, this is intended
29+
-- as an escape hatch for people who cannot bear it for whatever reason
30+
indicator_icon = '',
31+
-- indicator_icon = '',
32+
buffer_close_icon = '',
33+
modified_icon = '',
34+
close_icon = '',
35+
left_trunc_marker = '',
36+
right_trunc_marker = '',
37+
38+
--- name_formatter can be used to change the buffer's label in the bufferline.
39+
--- Please note some names can/will break the
40+
--- bufferline so use this at your discretion knowing that it has
41+
--- some limitations that will *NOT* be fixed.
42+
name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr"
43+
-- remove extension from markdown files for example
44+
if buf.name:match('%.md') then return vim.fn.fnamemodify(buf.name, ':t:r') end
45+
end,
46+
47+
max_name_length = 18,
48+
max_prefix_length = 15, -- prefix used when a buffer is de-duplicate
49+
tab_size = 18,
50+
51+
show_close_icon = false,
52+
show_buffer_icons = true, -- disable filetype icons for buffers
53+
show_buffer_close_icons = false,
54+
show_tab_indicators = false,
55+
56+
view = "multiwindow",
57+
-- can also be a table containing 2 custom separators
58+
-- [focused and unfocused]. eg: { '|', '|' }
59+
separator_style = {"", ""}, -- options "slant" | "thick" | "thin" | { 'any', 'any' },
60+
offsets = {
61+
-- options function , text_" "h always_show_bufferline = false
62+
{filetype = "NvimTree", text = "Explorer", text_align = "left"},
63+
},
64+
},
65+
66+
highlights = {
67+
fill = {guibg = {highlight = "BufferLineFill", attribute = "bg"}},
68+
background = { -- current tab
69+
guifg = {highlight = "BufferCurrent", attribute = "fg"},
70+
guibg = {highlight = "BufferCurrent", attribute = "bg"},
71+
},
72+
separator = {guifg = {highlight = "BufferSeparator", attribute = "fg"}},
73+
separator_selected = {
74+
guifg = {highlight = "BufferSeparatorSelected", attribute = "fg"},
75+
},
76+
close_button_selected = {
77+
guifg = {highlight = "BufferCloseButtonSelected", attribute = "fg"},
78+
guibg = {highlight = "BufferCloseButtonSelected", attribute = "bg"},
79+
},
80+
},
81+
8182
}
8283

83-
vim.cmd( "autocmd BufDelete * if len(getbufinfo({'buflisted':1})) -1 < 1 | set showtabline=1 | endif")
84+
vim.cmd("autocmd BufDelete * if len(getbufinfo({'buflisted':1})) -1 < 1 | set showtabline=1 | endif")
8485

8586
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ --
8687
-- ━━━━━━━━━━━━━━━━━❰ end configs ❱━━━━━━━━━━━━━━━━━ --
@@ -90,7 +91,7 @@ vim.cmd( "autocmd BufDelete * if len(getbufinfo({'buflisted':1})) -1 < 1 | set s
9091

9192

9293
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ --
93-
-- ━━━━━━━━━━━━━━━━━━❰ Mappings ❱━━━━━━━━━━━━━━━━━━━ --
94+
-- ━━━━━━━━━━━━━━━━━━❰ Mappings ❱━━━━━━━━━━━━━━━━━━━ --
9495
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ --
9596

9697
local keymap = vim.api.nvim_set_keymap

0 commit comments

Comments
 (0)