-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
barbar.lua
177 lines (149 loc) · 5.86 KB
/
barbar.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
local M = {
'romgrk/barbar.nvim',
requires = { 'tiagovla/scope.nvim' },
config = function(config)
-- Temp Fix: buffers per tab
-- see https://github.com/akinsho/bufferline.nvim#how-do-i-see-only-buffers-per-tab
require('scope').setup()
require('bufferline').setup(config.barbar)
end,
}
M.keymaps = function()
local modes = { 'n', 'c', 'v' }
local opts = { noremap = true, silent = true }
return {
-- Move to previous/next
{ modes, '<M-[>', '<Cmd>BufferPrevious<CR>', opts },
{ modes, '<M-]>', '<Cmd>BufferNext<CR>', opts },
-- Re-order to previous/next
{ modes, '<M-{>', '<Cmd>BufferMovePrevious<CR>', opts },
{ modes, '<M-}>', '<Cmd>BufferMoveNext<CR>', opts },
-- Goto buffer in position...
{ modes, '<leader>1', '<Cmd>BufferGoto 1<CR>', opts },
{ modes, '<leader>2', '<Cmd>BufferGoto 2<CR>', opts },
{ modes, '<leader>3', '<Cmd>BufferGoto 3<CR>', opts },
{ modes, '<leader>4', '<Cmd>BufferGoto 4<CR>', opts },
{ modes, '<leader>5', '<Cmd>BufferGoto 5<CR>', opts },
{ modes, '<leader>6', '<Cmd>BufferGoto 6<CR>', opts },
{ modes, '<leader>7', '<Cmd>BufferGoto 7<CR>', opts },
{ modes, '<leader>8', '<Cmd>BufferGoto 8<CR>', opts },
{ modes, '<leader>9', '<Cmd>BufferGoto 9<CR>', opts },
{ modes, '<leader>0', '<Cmd>BufferLast<CR>', opts },
-- Pin/unpin buffer
{ modes, '<leader>bp', '<Cmd>BufferPin<CR>', opts },
-- Close buffer
{ modes, '<leader>bc', '<Cmd>BufferClose<CR>', opts },
-- Wipeout buffer
-- :BufferWipeout
-- Close commands
-- :BufferCloseAllButCurrent
-- :BufferCloseAllButPinned
-- :BufferCloseAllButCurrentOrPinned
-- :BufferCloseBuffersLeft
-- :BufferCloseBuffersRight
-- Magic buffer-picking mode
{ modes, '<leader>bP', '<Cmd>BufferPick<CR>', opts },
}
end
M.defaultConfig = {
'barbar',
{
-- Set barbar's options
-- Enable/disable animations
animation = false,
-- Enable/disable auto-hiding the tab bar when there is a single buffer
auto_hide = false,
-- Enable/disable current/total tabpages indicator (top right corner)
tabpages = true,
-- Enable/disable close button
closable = true,
-- Enables/disable clickable tabs
-- - left-click: go to buffer
-- - middle-click: delete buffer
clickable = true,
-- Excludes buffers from the tabline
exclude_ft = { 'alpha' },
exclude_name = {},
-- Show every buffer
hide = { current = false, inactive = false, visible = false },
-- Enable/disable icons
-- if set to 'numbers', will show buffer index in the tabline
-- if set to 'both', will show buffer index and icons in the tabline
icons = 'numbers',
-- If set, the icon color will follow its corresponding buffer
-- highlight group. By default, the Buffer*Icon group is linked to the
-- Buffer* group (see Highlighting below). Otherwise, it will take its
-- default value as defined by devicons.
icon_custom_colors = false,
-- Configure icons on the bufferline.
icon_separator_active = '▎',
icon_separator_inactive = ' ',
icon_close_tab = '',
icon_close_tab_modified = '●', -- '*'
icon_pinned = '',
-- If true, new buffers will be inserted at the start/end of the list.
-- Default is to insert after current buffer.
insert_at_end = false,
insert_at_start = false,
-- Sets the maximum padding width with which to surround each tab
maximum_padding = 1,
-- Sets the minimum padding width with which to surround each tab
minimum_padding = 1,
-- Sets the maximum buffer name length.
maximum_length = 20,
-- If set, the letters for each buffer in buffer-pick mode will be
-- assigned based on their name. Otherwise or in case all letters are
-- already assigned, the behavior is to assign letters in order of
-- usability (see order below)
semantic_letters = true,
-- New buffer letters are assigned in this order. This order is
-- optimal for the qwerty keyboard layout but might need adjustement
-- for other layouts.
letters = 'asdfjkl;ghnmxcvbziowerutyqpASDFJKLGHNMXCVBZIOWERUTYQP',
-- Sets the name of unnamed buffers. By default format is "[Buffer X]"
-- where X is the buffer number. But only a static string is accepted here.
no_name_title = nil,
},
}
M.highlights = function(config)
local c = config.colors
local selectedBG = '#1b2430'
local bufferBG = '#12151a'
local blue = c.blue
local orange = c.orange
return {
-- format: "Buffer" + status + part
-- status:
-- *Current: current buffer
-- *Visible: visible but not current buffer
-- *Inactive: invisible but not current buffer
-- part:
-- *Icon: filetype icon
-- *Index: buffer index
-- *Mod: when modified
-- *Sign: the separator between buffers
-- *Target: letter in buffer-picking mode
BufferCurrent = { fg = blue, bg = selectedBG },
BufferCurrentIndex = { link = 'BufferCurrent' },
BufferCurrentMod = { fg = c.yellow, bg = selectedBG },
BufferCurrentSign = { link = 'BufferCurrent' },
BufferCurrentTarget = { fg = orange, bg = selectedBG, bold = true },
BufferVisible = { fg = c.grey, bg = bufferBG },
BufferVisibleIndex = { link = 'BufferVisible' },
BufferVisibleMod = { fg = c.yellow, bg = bufferBG },
BufferVisibleSign = { link = 'BufferVisible' },
BufferVisibleTarget = { fg = orange, bg = bufferBG, bold = true },
BufferInactive = { fg = c.grey, bg = bufferBG },
BufferInactiveIndex = { link = 'BufferInactive' },
BufferInactiveMod = { fg = c.yellow, bg = bufferBG },
BufferInactiveSign = { link = 'BufferInactive' },
BufferInactiveTarget = { fg = orange, bg = bufferBG, bold = true },
BufferTabpages = { bg = bufferBG, bold = true },
BufferTabpageFill = { bg = bufferBG },
BufferCurrentIcon = { link = 'BufferCurrent' },
BufferVisibleIcon = { link = 'BufferVisible' },
BufferInactiveIcon = { link = 'BufferInactive' },
BufferOffset = { link = 'BufferTabpageFill' },
}
end
return M