| 1 |
-- Copyright (c) 2020-2021 shadmansaleh |
| 2 |
-- MIT license, see LICENSE for more details. |
| 3 |
|
| 4 |
local eq = assert.are.same |
| 5 |
local statusline = require('tests.statusline').new(120, 'active') |
| 6 |
local inactive_statusline = statusline.new(120, 'inactive') |
| 7 |
local tabline = statusline.new(120, 'tabline') |
| 8 |
|
| 9 |
describe('Lualine', function() |
| 10 |
local config |
| 11 |
before_each(function() |
| 12 |
config = { |
| 13 |
options = { |
| 14 |
icons_enabled = true, |
| 15 |
theme = 'gruvbox', |
| 16 |
component_separators = { left = '', right = '' }, |
| 17 |
section_separators = { left = '', right = '' }, |
| 18 |
disabled_filetypes = { |
| 19 |
statusline = {}, |
| 20 |
winbar = {}, |
| 21 |
}, |
| 22 |
ignore_focus = {}, |
| 23 |
always_divide_middle = true, |
| 24 |
always_show_tabline = true, |
| 25 |
globalstatus = false, |
| 26 |
refresh = { |
| 27 |
statusline = 1000, |
| 28 |
tabline = 1000, |
| 29 |
winbar = 1000, |
| 30 |
refresh_time = 16, -- ~60fps |
| 31 |
events = { |
| 32 |
'WinEnter', |
| 33 |
'BufEnter', |
| 34 |
'BufWritePost', |
| 35 |
'SessionLoadPost', |
| 36 |
'FileChangedShellPost', |
| 37 |
'VimResized', |
| 38 |
'Filetype', |
| 39 |
'CursorMoved', |
| 40 |
'CursorMovedI', |
| 41 |
'ModeChanged', |
| 42 |
}, |
| 43 |
}, |
| 44 |
}, |
| 45 |
sections = { |
| 46 |
lualine_a = { 'mode' }, |
| 47 |
-- We can't test branch component inside lualines repo. |
| 48 |
-- As branch name will differ in pr/CI. We could setup a dummy repo |
| 49 |
-- but plenary doesn't yet support setup() & teardown() so replacing |
| 50 |
-- branch with a dummy component. |
| 51 |
lualine_b = { |
| 52 |
{ |
| 53 |
function() |
| 54 |
return 'master' |
| 55 |
end, |
| 56 |
icon = '', |
| 57 |
}, |
| 58 |
'diagnostics', |
| 59 |
}, |
| 60 |
lualine_c = { 'filename' }, |
| 61 |
lualine_x = { 'encoding', 'fileformat', 'filetype' }, |
| 62 |
lualine_y = { 'progress' }, |
| 63 |
lualine_z = { 'location' }, |
| 64 |
}, |
| 65 |
inactive_sections = { |
| 66 |
lualine_a = {}, |
| 67 |
lualine_b = {}, |
| 68 |
lualine_c = { 'filename' }, |
| 69 |
lualine_x = { 'location' }, |
| 70 |
lualine_y = {}, |
| 71 |
lualine_z = {}, |
| 72 |
}, |
| 73 |
tabline = {}, |
| 74 |
winbar = {}, |
| 75 |
inactive_winbar = {}, |
| 76 |
extensions = {}, |
| 77 |
} |
| 78 |
|
| 79 |
vim.opt.swapfile = false |
| 80 |
vim.cmd('bufdo bdelete') |
| 81 |
pcall(vim.cmd, 'tabdo tabclose') |
| 82 |
require('lualine').setup(config) |
| 83 |
end) |
| 84 |
|
| 85 |
it('shows active statusline', function() |
| 86 |
statusline:expect([===[ |
| 87 |
highlights = { |
| 88 |
1: lualine_a_normal = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 89 |
2: lualine_transitional_lualine_a_normal_to_lualine_b_normal = { bg = "#504945", fg = "#a89984", nocombine = true } |
| 90 |
3: lualine_b_normal = { bg = "#504945", fg = "#ebdbb2", nocombine = true } |
| 91 |
4: lualine_transitional_lualine_b_normal_to_lualine_c_normal = { bg = "#3c3836", fg = "#504945", nocombine = true } |
| 92 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 93 |
} |
| 94 |
|{1: NORMAL } |
| 95 |
{2:} |
| 96 |
{3: master } |
| 97 |
{4:} |
| 98 |
{5: [No Name] } |
| 99 |
{5: } |
| 100 |
{5: } |
| 101 |
{4:} |
| 102 |
{3: Top } |
| 103 |
{2:} |
| 104 |
{1: 1:1 }| |
| 105 |
]===]) |
| 106 |
end) |
| 107 |
|
| 108 |
it('shows inactive statusline', function() |
| 109 |
inactive_statusline:expect([===[ |
| 110 |
highlights = { |
| 111 |
1: lualine_c_inactive = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 112 |
} |
| 113 |
|{1: [No Name] } |
| 114 |
{1: } |
| 115 |
{1: 1:1 }| |
| 116 |
]===]) |
| 117 |
end) |
| 118 |
|
| 119 |
it('get_config can retrieve config', function() |
| 120 |
eq(config, require('lualine').get_config()) |
| 121 |
end) |
| 122 |
|
| 123 |
it('can live update config', function() |
| 124 |
local conf = require('lualine').get_config() |
| 125 |
conf.sections.lualine_a = {} |
| 126 |
require('lualine').setup(conf) |
| 127 |
statusline:expect([===[ |
| 128 |
highlights = { |
| 129 |
1: lualine_b_normal = { bg = "#504945", fg = "#ebdbb2", nocombine = true } |
| 130 |
2: lualine_transitional_lualine_b_normal_to_lualine_c_normal = { bg = "#3c3836", fg = "#504945", nocombine = true } |
| 131 |
3: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 132 |
4: lualine_transitional_lualine_a_normal_to_lualine_b_normal = { bg = "#504945", fg = "#a89984", nocombine = true } |
| 133 |
5: lualine_a_normal = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 134 |
} |
| 135 |
|{1: master } |
| 136 |
{2:} |
| 137 |
{3: [No Name] } |
| 138 |
{3: } |
| 139 |
{3: } |
| 140 |
{2:} |
| 141 |
{1: Top } |
| 142 |
{4:} |
| 143 |
{5: 1:1 }| |
| 144 |
]===]) |
| 145 |
end) |
| 146 |
|
| 147 |
it('Can work without section separators', function() |
| 148 |
config.options.section_separators = '' |
| 149 |
require('lualine').setup(config) |
| 150 |
statusline:expect([===[ |
| 151 |
highlights = { |
| 152 |
1: lualine_a_normal = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 153 |
2: lualine_b_normal = { bg = "#504945", fg = "#ebdbb2", nocombine = true } |
| 154 |
3: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 155 |
} |
| 156 |
|{1: NORMAL } |
| 157 |
{2: master } |
| 158 |
{3: [No Name] } |
| 159 |
{3: } |
| 160 |
{3: } |
| 161 |
{2: Top } |
| 162 |
{1: 1:1 }| |
| 163 |
]===]) |
| 164 |
end) |
| 165 |
|
| 166 |
it('Can work without component_separators', function() |
| 167 |
table.insert(config.sections.lualine_a, function() |
| 168 |
return 'test_comp1' |
| 169 |
end) |
| 170 |
table.insert(config.sections.lualine_z, function() |
| 171 |
return 'test_comp2' |
| 172 |
end) |
| 173 |
|
| 174 |
require('lualine').setup(config) |
| 175 |
statusline:expect([===[ |
| 176 |
highlights = { |
| 177 |
1: lualine_a_normal = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 178 |
2: lualine_transitional_lualine_a_normal_to_lualine_b_normal = { bg = "#504945", fg = "#a89984", nocombine = true } |
| 179 |
3: lualine_b_normal = { bg = "#504945", fg = "#ebdbb2", nocombine = true } |
| 180 |
4: lualine_transitional_lualine_b_normal_to_lualine_c_normal = { bg = "#3c3836", fg = "#504945", nocombine = true } |
| 181 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 182 |
} |
| 183 |
|{1: NORMAL } |
| 184 |
{1: test_comp1 } |
| 185 |
{2:} |
| 186 |
{3: master } |
| 187 |
{4:} |
| 188 |
{5: [No Name] } |
| 189 |
{5: } |
| 190 |
{5: } |
| 191 |
{4:} |
| 192 |
{3: Top } |
| 193 |
{2:} |
| 194 |
{1: 1:1 } |
| 195 |
{1: test_comp2 }| |
| 196 |
]===]) |
| 197 |
|
| 198 |
config.options.component_separators = '' |
| 199 |
require('lualine').setup(config) |
| 200 |
statusline:expect([===[ |
| 201 |
highlights = { |
| 202 |
1: lualine_a_normal = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 203 |
2: lualine_transitional_lualine_a_normal_to_lualine_b_normal = { bg = "#504945", fg = "#a89984", nocombine = true } |
| 204 |
3: lualine_b_normal = { bg = "#504945", fg = "#ebdbb2", nocombine = true } |
| 205 |
4: lualine_transitional_lualine_b_normal_to_lualine_c_normal = { bg = "#3c3836", fg = "#504945", nocombine = true } |
| 206 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 207 |
} |
| 208 |
|{1: NORMAL } |
| 209 |
{1: test_comp1 } |
| 210 |
{2:} |
| 211 |
{3: master } |
| 212 |
{4:} |
| 213 |
{5: [No Name] } |
| 214 |
{5: } |
| 215 |
{5: } |
| 216 |
{4:} |
| 217 |
{3: Top } |
| 218 |
{2:} |
| 219 |
{1: 1:1 } |
| 220 |
{1: test_comp2 }| |
| 221 |
]===]) |
| 222 |
end) |
| 223 |
|
| 224 |
it('mid divider can be disabled on special case', function() |
| 225 |
config.options.always_divide_middle = false |
| 226 |
config.sections.lualine_x = {} |
| 227 |
config.sections.lualine_y = {} |
| 228 |
config.sections.lualine_z = {} |
| 229 |
require('lualine').setup(config) |
| 230 |
statusline:expect([===[ |
| 231 |
highlights = { |
| 232 |
1: lualine_a_normal = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 233 |
2: lualine_transitional_lualine_a_normal_to_lualine_b_normal = { bg = "#504945", fg = "#a89984", nocombine = true } |
| 234 |
3: lualine_b_normal = { bg = "#504945", fg = "#ebdbb2", nocombine = true } |
| 235 |
4: lualine_transitional_lualine_b_normal_to_lualine_c_normal = { bg = "#3c3836", fg = "#504945", nocombine = true } |
| 236 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 237 |
} |
| 238 |
|{1: NORMAL } |
| 239 |
{2:} |
| 240 |
{3: master } |
| 241 |
{4:} |
| 242 |
{5: [No Name] }| |
| 243 |
]===]) |
| 244 |
end) |
| 245 |
|
| 246 |
it('works with icons disabled', function() |
| 247 |
config.options.icons_enabled = false |
| 248 |
config.options.section_separators = '' |
| 249 |
require('lualine').setup(config) |
| 250 |
statusline:expect([===[ |
| 251 |
highlights = { |
| 252 |
1: lualine_a_normal = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 253 |
2: lualine_b_normal = { bg = "#504945", fg = "#ebdbb2", nocombine = true } |
| 254 |
3: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 255 |
} |
| 256 |
|{1: NORMAL } |
| 257 |
{2: master } |
| 258 |
{3: [No Name] } |
| 259 |
{3: } |
| 260 |
{3: unix } |
| 261 |
{2: Top } |
| 262 |
{1: 1:1 }| |
| 263 |
]===]) |
| 264 |
end) |
| 265 |
|
| 266 |
it('can be desabled for specific filetypes', function() |
| 267 |
config.options.disabled_filetypes = { 'test_ft' } |
| 268 |
require('lualine').setup(config) |
| 269 |
local old_ft = vim.bo.ft |
| 270 |
vim.bo.ft = 'test_ft' |
| 271 |
statusline:expect(nil) |
| 272 |
vim.bo.ft = old_ft |
| 273 |
end) |
| 274 |
|
| 275 |
it('can apply custom extensions', function() |
| 276 |
table.insert(config.extensions, { |
| 277 |
filetypes = { 'test_ft' }, |
| 278 |
sections = { |
| 279 |
lualine_a = { |
| 280 |
function() |
| 281 |
return 'custom_extension_component' |
| 282 |
end, |
| 283 |
}, |
| 284 |
}, |
| 285 |
}) |
| 286 |
local old_ft = vim.bo.ft |
| 287 |
vim.bo.ft = 'test_ft' |
| 288 |
require('lualine').setup(config) |
| 289 |
statusline:expect([===[ |
| 290 |
highlights = { |
| 291 |
1: lualine_a_normal = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 292 |
2: lualine_transitional_lualine_a_normal_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 293 |
3: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 294 |
} |
| 295 |
|{1: custom_extension_component } |
| 296 |
{2:} |
| 297 |
{3: }| |
| 298 |
]===]) |
| 299 |
vim.bo.ft = old_ft |
| 300 |
end) |
| 301 |
|
| 302 |
it('same extension can be applied to multiple filetypes', function() |
| 303 |
table.insert(config.extensions, { |
| 304 |
filetypes = { 'test_ft1', 'test_ft2' }, |
| 305 |
sections = { |
| 306 |
lualine_a = { |
| 307 |
function() |
| 308 |
return 'custom_extension_component' |
| 309 |
end, |
| 310 |
}, |
| 311 |
}, |
| 312 |
}) |
| 313 |
local old_ft = vim.bo.ft |
| 314 |
vim.bo.ft = 'test_ft1' |
| 315 |
require('lualine').setup(config) |
| 316 |
statusline:expect([===[ |
| 317 |
highlights = { |
| 318 |
1: lualine_a_normal = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 319 |
2: lualine_transitional_lualine_a_normal_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 320 |
3: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 321 |
} |
| 322 |
|{1: custom_extension_component } |
| 323 |
{2:} |
| 324 |
{3: }| |
| 325 |
]===]) |
| 326 |
vim.bo.ft = old_ft |
| 327 |
statusline:expect([===[ |
| 328 |
highlights = { |
| 329 |
1: lualine_a_normal = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 330 |
2: lualine_transitional_lualine_a_normal_to_lualine_b_normal = { bg = "#504945", fg = "#a89984", nocombine = true } |
| 331 |
3: lualine_b_normal = { bg = "#504945", fg = "#ebdbb2", nocombine = true } |
| 332 |
4: lualine_transitional_lualine_b_normal_to_lualine_c_normal = { bg = "#3c3836", fg = "#504945", nocombine = true } |
| 333 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 334 |
} |
| 335 |
|{1: NORMAL } |
| 336 |
{2:} |
| 337 |
{3: master } |
| 338 |
{4:} |
| 339 |
{5: [No Name] } |
| 340 |
{5: } |
| 341 |
{5: } |
| 342 |
{4:} |
| 343 |
{3: Top } |
| 344 |
{2:} |
| 345 |
{1: 1:1 }| |
| 346 |
]===]) |
| 347 |
vim.bo.ft = 'test_ft2' |
| 348 |
statusline:expect([===[ |
| 349 |
highlights = { |
| 350 |
1: lualine_a_normal = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 351 |
2: lualine_transitional_lualine_a_normal_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 352 |
3: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 353 |
} |
| 354 |
|{1: custom_extension_component } |
| 355 |
{2:} |
| 356 |
{3: }| |
| 357 |
]===]) |
| 358 |
vim.bo.ft = old_ft |
| 359 |
end) |
| 360 |
|
| 361 |
it('extensions with shared section subtables load without error', function() |
| 362 |
local ext = { |
| 363 |
filetypes = { 'test_ft_shared' }, |
| 364 |
winbar = { |
| 365 |
lualine_a = { |
| 366 |
function() |
| 367 |
return 'shared_extension_component' |
| 368 |
end, |
| 369 |
}, |
| 370 |
}, |
| 371 |
} |
| 372 |
ext.inactive_winbar = ext.winbar |
| 373 |
table.insert(config.extensions, ext) |
| 374 |
local old_ft = vim.bo.ft |
| 375 |
vim.bo.ft = 'test_ft_shared' |
| 376 |
require('lualine').setup(config) |
| 377 |
vim.bo.ft = old_ft |
| 378 |
end) |
| 379 |
|
| 380 |
-- TODO: figure put why some of the tablines tests fail in CI |
| 381 |
describe('tabline', function() |
| 382 |
local tab_conf = vim.deepcopy(config) |
| 383 |
tab_conf.tabline = { |
| 384 |
lualine_a = { |
| 385 |
function() |
| 386 |
return 'tabline_component' |
| 387 |
end, |
| 388 |
}, |
| 389 |
lualine_b = {}, |
| 390 |
lualine_c = {}, |
| 391 |
lualine_x = {}, |
| 392 |
lualine_y = {}, |
| 393 |
lualine_z = {}, |
| 394 |
} |
| 395 |
|
| 396 |
it('can use tabline', function() |
| 397 |
local conf = vim.deepcopy(tab_conf) |
| 398 |
conf.tabline.lualine_a = { |
| 399 |
function() |
| 400 |
return 'tabline_component' |
| 401 |
end, |
| 402 |
} |
| 403 |
require('lualine').setup(conf) |
| 404 |
require('lualine').statusline() |
| 405 |
tabline:expect([===[ |
| 406 |
highlights = { |
| 407 |
1: lualine_a_normal = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 408 |
2: lualine_transitional_lualine_a_normal_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 409 |
3: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 410 |
} |
| 411 |
|{1: tabline_component } |
| 412 |
{2:} |
| 413 |
{3: }| |
| 414 |
]===]) |
| 415 |
end) |
| 416 |
|
| 417 |
it('can use tabline as statusline', function() |
| 418 |
local conf = vim.deepcopy(config) |
| 419 |
conf.tabline = conf.sections |
| 420 |
conf.sections = {} |
| 421 |
conf.inactive_sections = {} |
| 422 |
require('lualine').setup(conf) |
| 423 |
require('lualine').statusline() |
| 424 |
|
| 425 |
-- TODO: check why this test fails because of debounce |
| 426 |
-- eq('%#Normal#', vim.go.statusline) |
| 427 |
|
| 428 |
tabline:expect([===[ |
| 429 |
highlights = { |
| 430 |
1: lualine_a_normal = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 431 |
2: lualine_transitional_lualine_a_normal_to_lualine_b_normal = { bg = "#504945", fg = "#a89984", nocombine = true } |
| 432 |
3: lualine_b_normal = { bg = "#504945", fg = "#ebdbb2", nocombine = true } |
| 433 |
4: lualine_transitional_lualine_b_normal_to_lualine_c_normal = { bg = "#3c3836", fg = "#504945", nocombine = true } |
| 434 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 435 |
} |
| 436 |
|{1: NORMAL } |
| 437 |
{2:} |
| 438 |
{3: master } |
| 439 |
{4:} |
| 440 |
{5: [No Name] } |
| 441 |
{5: } |
| 442 |
{5: } |
| 443 |
{4:} |
| 444 |
{3: Top } |
| 445 |
{2:} |
| 446 |
{1: 1:1 }| |
| 447 |
]===]) |
| 448 |
end) |
| 449 |
describe('tabs component', function() |
| 450 |
it('works', function() |
| 451 |
local conf = vim.deepcopy(tab_conf) |
| 452 |
conf.tabline.lualine_a = { { 'tabs', max_length = 1e3 } } |
| 453 |
vim.cmd('tabnew') |
| 454 |
vim.cmd('tabnew') |
| 455 |
require('lualine').setup(conf) |
| 456 |
require('lualine').statusline() |
| 457 |
tabline:expect([===[ |
| 458 |
highlights = { |
| 459 |
1: lualine_a_tabs_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 460 |
2: lualine_transitional_lualine_a_tabs_inactive_to_lualine_a_tabs_active = { bg = "#a89984", fg = "#3c3836", nocombine = true } |
| 461 |
3: lualine_a_tabs_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 462 |
4: lualine_transitional_lualine_a_tabs_active_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 463 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 464 |
} |
| 465 |
|{1: 1 } |
| 466 |
{1: 2 } |
| 467 |
{2:} |
| 468 |
{3: 3 } |
| 469 |
{4:} |
| 470 |
{5: }| |
| 471 |
]===]) |
| 472 |
|
| 473 |
vim.cmd('tabprev') |
| 474 |
tabline:expect([===[ |
| 475 |
highlights = { |
| 476 |
1: lualine_a_tabs_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 477 |
2: lualine_transitional_lualine_a_tabs_inactive_to_lualine_a_tabs_active = { bg = "#a89984", fg = "#3c3836", nocombine = true } |
| 478 |
3: lualine_a_tabs_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 479 |
4: lualine_transitional_lualine_a_tabs_active_to_lualine_a_tabs_inactive = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 480 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 481 |
} |
| 482 |
|{1: 1 } |
| 483 |
{2:} |
| 484 |
{3: 2 } |
| 485 |
{4:} |
| 486 |
{1: 3 } |
| 487 |
{5: }| |
| 488 |
]===]) |
| 489 |
|
| 490 |
vim.cmd('tabprev') |
| 491 |
tabline:expect([===[ |
| 492 |
highlights = { |
| 493 |
1: lualine_a_tabs_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 494 |
2: lualine_transitional_lualine_a_tabs_active_to_lualine_a_tabs_inactive = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 495 |
3: lualine_a_tabs_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 496 |
4: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 497 |
} |
| 498 |
|{1: 1 } |
| 499 |
{2:} |
| 500 |
{3: 2 } |
| 501 |
{3: 3 } |
| 502 |
{4: }| |
| 503 |
]===]) |
| 504 |
end) |
| 505 |
|
| 506 |
it('mode option can change layout', function() |
| 507 |
local conf = vim.deepcopy(tab_conf) |
| 508 |
conf.tabline.lualine_a = { { 'tabs', max_length = 1e3, mode = 0 } } |
| 509 |
vim.cmd('tabe ' .. 'a.txt') |
| 510 |
vim.cmd('tabe ' .. 'b.txt') |
| 511 |
require('lualine').setup(conf) |
| 512 |
require('lualine').statusline() |
| 513 |
tabline:expect([===[ |
| 514 |
highlights = { |
| 515 |
1: lualine_a_tabs_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 516 |
2: lualine_transitional_lualine_a_tabs_inactive_to_lualine_a_tabs_active = { bg = "#a89984", fg = "#3c3836", nocombine = true } |
| 517 |
3: lualine_a_tabs_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 518 |
4: lualine_transitional_lualine_a_tabs_active_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 519 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 520 |
} |
| 521 |
|{1: 1 } |
| 522 |
{1: 2 } |
| 523 |
{2:} |
| 524 |
{3: 3 } |
| 525 |
{4:} |
| 526 |
{5: }| |
| 527 |
]===]) |
| 528 |
|
| 529 |
tabline:expect([===[ |
| 530 |
highlights = { |
| 531 |
1: lualine_a_tabs_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 532 |
2: lualine_transitional_lualine_a_tabs_inactive_to_lualine_a_tabs_active = { bg = "#a89984", fg = "#3c3836", nocombine = true } |
| 533 |
3: lualine_a_tabs_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 534 |
4: lualine_transitional_lualine_a_tabs_active_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 535 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 536 |
} |
| 537 |
|{1: 1 } |
| 538 |
{1: 2 } |
| 539 |
{2:} |
| 540 |
{3: 3 } |
| 541 |
{4:} |
| 542 |
{5: }| |
| 543 |
]===]) |
| 544 |
|
| 545 |
conf.tabline.lualine_a = { { 'tabs', max_length = 1e3, mode = 1 } } |
| 546 |
require('lualine').setup(conf) |
| 547 |
require('lualine').statusline() |
| 548 |
tabline:expect([===[ |
| 549 |
highlights = { |
| 550 |
1: lualine_a_tabs_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 551 |
2: lualine_transitional_lualine_a_tabs_inactive_to_lualine_a_tabs_active = { bg = "#a89984", fg = "#3c3836", nocombine = true } |
| 552 |
3: lualine_a_tabs_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 553 |
4: lualine_transitional_lualine_a_tabs_active_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 554 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 555 |
} |
| 556 |
|{1: [No Name] } |
| 557 |
{1: a.txt } |
| 558 |
{2:} |
| 559 |
{3: b.txt } |
| 560 |
{4:} |
| 561 |
{5: }| |
| 562 |
]===]) |
| 563 |
|
| 564 |
conf.tabline.lualine_a = { { 'tabs', max_length = 1e3, mode = 2 } } |
| 565 |
require('lualine').setup(conf) |
| 566 |
require('lualine').statusline() |
| 567 |
tabline:expect([===[ |
| 568 |
highlights = { |
| 569 |
1: lualine_a_tabs_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 570 |
2: lualine_transitional_lualine_a_tabs_inactive_to_lualine_a_tabs_active = { bg = "#a89984", fg = "#3c3836", nocombine = true } |
| 571 |
3: lualine_a_tabs_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 572 |
4: lualine_transitional_lualine_a_tabs_active_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 573 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 574 |
} |
| 575 |
|{1: 1 [No Name] } |
| 576 |
{1: 2 a.txt } |
| 577 |
{2:} |
| 578 |
{3: 3 b.txt } |
| 579 |
{4:} |
| 580 |
{5: }| |
| 581 |
]===]) |
| 582 |
end) |
| 583 |
end) |
| 584 |
|
| 585 |
describe('buffers component', function() |
| 586 |
it('works', function() |
| 587 |
local conf = vim.deepcopy(tab_conf) |
| 588 |
conf.tabline.lualine_a = { { 'buffers', max_length = 1e3, icons_enabled = false } } |
| 589 |
vim.cmd('tabe ' .. 'a.txt') |
| 590 |
vim.cmd('tabe ' .. 'b.txt') |
| 591 |
require('lualine').setup(conf) |
| 592 |
require('lualine').statusline() |
| 593 |
tabline:expect([===[ |
| 594 |
highlights = { |
| 595 |
1: lualine_a_buffers_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 596 |
2: lualine_transitional_lualine_a_buffers_inactive_to_lualine_a_buffers_active = { bg = "#a89984", fg = "#3c3836", nocombine = true } |
| 597 |
3: lualine_a_buffers_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 598 |
4: lualine_transitional_lualine_a_buffers_active_to_lualine_a_buffers_inactive = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 599 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 600 |
} |
| 601 |
|{1: #a.txt } |
| 602 |
{2:} |
| 603 |
{3: b.txt } |
| 604 |
{4:} |
| 605 |
{1: [No Name] } |
| 606 |
{MATCH:{5:%s+}|} |
| 607 |
]===]) |
| 608 |
|
| 609 |
vim.cmd('tabprev') |
| 610 |
tabline:expect([===[ |
| 611 |
highlights = { |
| 612 |
1: lualine_a_buffers_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 613 |
2: lualine_transitional_lualine_a_buffers_active_to_lualine_a_buffers_inactive = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 614 |
3: lualine_a_buffers_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 615 |
4: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 616 |
} |
| 617 |
|{1: a.txt } |
| 618 |
{2:} |
| 619 |
{3: b.txt } |
| 620 |
{3: #[No Name] } |
| 621 |
{MATCH:{4:%s+}|} |
| 622 |
]===]) |
| 623 |
|
| 624 |
vim.cmd('tabprev') |
| 625 |
tabline:expect([===[ |
| 626 |
highlights = { |
| 627 |
1: lualine_a_buffers_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 628 |
2: lualine_transitional_lualine_a_buffers_inactive_to_lualine_a_buffers_active = { bg = "#a89984", fg = "#3c3836", nocombine = true } |
| 629 |
3: lualine_a_buffers_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 630 |
4: lualine_transitional_lualine_a_buffers_active_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 631 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 632 |
} |
| 633 |
|{1: a.txt } |
| 634 |
{1: #b.txt } |
| 635 |
{2:} |
| 636 |
{3: [No Name] } |
| 637 |
{4:} |
| 638 |
{MATCH:{5:%s+}|} |
| 639 |
]===]) |
| 640 |
end) |
| 641 |
|
| 642 |
it('mode option can change layout', function() |
| 643 |
local conf = vim.deepcopy(tab_conf) |
| 644 |
conf.tabline.lualine_a = { { 'tabs', max_length = 1e3, mode = 0, icons_enabled = false } } |
| 645 |
vim.cmd('tabe ' .. 'a.txt') |
| 646 |
vim.cmd('tabe ' .. 'b.txt') |
| 647 |
require('lualine').setup(conf) |
| 648 |
require('lualine').statusline() |
| 649 |
tabline:expect([===[ |
| 650 |
highlights = { |
| 651 |
1: lualine_a_tabs_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 652 |
2: lualine_transitional_lualine_a_tabs_inactive_to_lualine_a_tabs_active = { bg = "#a89984", fg = "#3c3836", nocombine = true } |
| 653 |
3: lualine_a_tabs_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 654 |
4: lualine_transitional_lualine_a_tabs_active_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 655 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 656 |
} |
| 657 |
{MATCH:|{1: %d+ }} |
| 658 |
{MATCH:{1: %d+ }} |
| 659 |
{2:} |
| 660 |
{MATCH:{3: %d+ }} |
| 661 |
{4:} |
| 662 |
{MATCH:{5:%s+}|} |
| 663 |
]===]) |
| 664 |
|
| 665 |
conf.tabline.lualine_a = { { 'buffers', max_length = 1e3, mode = 1, icons_enabled = false } } |
| 666 |
require('lualine').setup(conf) |
| 667 |
require('lualine').statusline() |
| 668 |
tabline:expect([===[ |
| 669 |
highlights = { |
| 670 |
1: lualine_a_buffers_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 671 |
2: lualine_transitional_lualine_a_buffers_inactive_to_lualine_a_buffers_active = { bg = "#a89984", fg = "#3c3836", nocombine = true } |
| 672 |
3: lualine_a_buffers_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 673 |
4: lualine_transitional_lualine_a_buffers_active_to_lualine_a_buffers_inactive = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 674 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 675 |
} |
| 676 |
{MATCH:|{1: #%d+ }} |
| 677 |
{2:} |
| 678 |
{MATCH:{3: %d+ }} |
| 679 |
{4:} |
| 680 |
{MATCH:{1: %d+ }} |
| 681 |
{MATCH:{5:%s+}|} |
| 682 |
]===]) |
| 683 |
|
| 684 |
conf.tabline.lualine_a = { { 'buffers', max_length = 1e3, mode = 2, icons_enabled = false } } |
| 685 |
require('lualine').setup(conf) |
| 686 |
require('lualine').statusline() |
| 687 |
tabline:expect([===[ |
| 688 |
highlights = { |
| 689 |
1: lualine_a_buffers_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 690 |
2: lualine_transitional_lualine_a_buffers_inactive_to_lualine_a_buffers_active = { bg = "#a89984", fg = "#3c3836", nocombine = true } |
| 691 |
3: lualine_a_buffers_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 692 |
4: lualine_transitional_lualine_a_buffers_active_to_lualine_a_buffers_inactive = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 693 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 694 |
} |
| 695 |
{MATCH:|{1: #%d+ a.txt }} |
| 696 |
{2:} |
| 697 |
{MATCH:{3: %d+ b.txt }} |
| 698 |
{4:} |
| 699 |
{MATCH:{1: %d+ %[No Name%] }} |
| 700 |
{MATCH:{5:%s+}|} |
| 701 |
]===]) |
| 702 |
end) |
| 703 |
|
| 704 |
it('can show modified status', function() |
| 705 |
local conf = vim.deepcopy(tab_conf) |
| 706 |
conf.tabline.lualine_a = { { 'buffers', max_length = 1e3, show_modified_status = true, icons_enabled = false } } |
| 707 |
require('lualine').setup(conf) |
| 708 |
require('lualine').statusline() |
| 709 |
tabline:expect([===[ |
| 710 |
highlights = { |
| 711 |
1: lualine_a_buffers_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 712 |
2: lualine_transitional_lualine_a_buffers_active_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 713 |
3: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 714 |
} |
| 715 |
|{1: [No Name] } |
| 716 |
{2:} |
| 717 |
{3: }| |
| 718 |
]===]) |
| 719 |
|
| 720 |
vim.bo.modified = true |
| 721 |
tabline:expect([===[ |
| 722 |
highlights = { |
| 723 |
1: lualine_a_buffers_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 724 |
2: lualine_transitional_lualine_a_buffers_active_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 725 |
3: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 726 |
} |
| 727 |
|{1: [No Name] ● } |
| 728 |
{2:} |
| 729 |
{3: }| |
| 730 |
]===]) |
| 731 |
vim.bo.modified = false |
| 732 |
end) |
| 733 |
|
| 734 |
it('can show relative path', function() |
| 735 |
local conf = vim.deepcopy(tab_conf) |
| 736 |
conf.tabline.lualine_a = { { 'buffers', max_length = 1e3, show_filename_only = false, icons_enabled = false } } |
| 737 |
require('lualine').setup(conf) |
| 738 |
require('lualine').statusline() |
| 739 |
local path = 'aaaaaa/bbbbb/cccccc/ddddd/eeeee/ffff/gggg' |
| 740 |
vim.fn.mkdir(path, 'p') |
| 741 |
vim.cmd('e ' .. path .. '/asdf.txt') |
| 742 |
tabline:expect([===[ |
| 743 |
highlights = { |
| 744 |
1: lualine_a_buffers_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 745 |
2: lualine_transitional_lualine_a_buffers_active_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 746 |
3: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 747 |
} |
| 748 |
|{1: a/b/c/d/e/f/g/asdf.txt } |
| 749 |
{2:} |
| 750 |
{3: }| |
| 751 |
]===]) |
| 752 |
vim.fn.delete(path:match('(%w+)/.*'), 'rf') |
| 753 |
end) |
| 754 |
|
| 755 |
it('can show ellipsis when max_width is crossed', function() |
| 756 |
local conf = vim.deepcopy(tab_conf) |
| 757 |
conf.tabline.lualine_a = { { 'buffers', max_length = 1 } } |
| 758 |
vim.cmd('tabe a.txt') |
| 759 |
vim.cmd('tabe b.txt') |
| 760 |
vim.cmd('tabprev') |
| 761 |
require('lualine').setup(conf) |
| 762 |
require('lualine').statusline() |
| 763 |
tabline:expect([===[ |
| 764 |
highlights = { |
| 765 |
1: lualine_a_buffers_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 766 |
2: lualine_transitional_lualine_a_buffers_active_to_lualine_a_buffers_inactive = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 767 |
3: lualine_a_buffers_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 768 |
4: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 769 |
} |
| 770 |
|{1: a.txt } |
| 771 |
{2:} |
| 772 |
{3: ... } |
| 773 |
{4: }| |
| 774 |
]===]) |
| 775 |
end) |
| 776 |
|
| 777 |
it('can show filetype icons', function() |
| 778 |
local conf = vim.deepcopy(tab_conf) |
| 779 |
conf.tabline.lualine_a = { { 'buffers', max_length = 1e3, show_filename_only = false } } |
| 780 |
require('lualine').setup(conf) |
| 781 |
require('lualine').statusline() |
| 782 |
vim.cmd('e t.lua') |
| 783 |
tabline:expect([===[ |
| 784 |
highlights = { |
| 785 |
1: lualine_a_buffers_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 786 |
2: lualine_transitional_lualine_a_buffers_active_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 787 |
3: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 788 |
} |
| 789 |
|{1: t.lua } |
| 790 |
{2:} |
| 791 |
{3: }| |
| 792 |
]===]) |
| 793 |
end) |
| 794 |
|
| 795 |
it('can show buffer numbers instead of indices (without file names)', function() |
| 796 |
local conf = vim.deepcopy(tab_conf) |
| 797 |
conf.tabline.lualine_a = { { 'buffers', mode = 3, max_length = 1e3, icons_enabled = false } } |
| 798 |
require('lualine').setup(conf) |
| 799 |
require('lualine').statusline() |
| 800 |
vim.cmd('e a.txt') |
| 801 |
vim.cmd('silent! bd #') -- NeoVim 0.5 does not create an unnamed buffer. This ensures consistent results between NeoVim versions. |
| 802 |
vim.cmd('e b.txt') |
| 803 |
local bufnr_a = vim.fn.bufnr('a.txt') |
| 804 |
local bufnr_b = vim.fn.bufnr('b.txt') |
| 805 |
tabline:expect([===[ |
| 806 |
highlights = { |
| 807 |
1: lualine_a_buffers_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 808 |
2: lualine_transitional_lualine_a_buffers_inactive_to_lualine_a_buffers_active = { bg = "#a89984", fg = "#3c3836", nocombine = true } |
| 809 |
3: lualine_a_buffers_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 810 |
4: lualine_transitional_lualine_a_buffers_active_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 811 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 812 |
} |
| 813 |
|{1: #]===] .. bufnr_a .. [===[ } |
| 814 |
{2:} |
| 815 |
{3: ]===] .. bufnr_b .. [===[ } |
| 816 |
{4:} |
| 817 |
{MATCH:{5:%s+}|} |
| 818 |
]===]) |
| 819 |
end) |
| 820 |
|
| 821 |
it('can show buffer numbers instead of indices (with file names)', function() |
| 822 |
local conf = vim.deepcopy(tab_conf) |
| 823 |
conf.tabline.lualine_a = { { 'buffers', mode = 4, max_length = 1e3, icons_enabled = false } } |
| 824 |
vim.cmd('e a.txt') |
| 825 |
vim.cmd('silent! bd #') -- NeoVim 0.5 does not create an unnamed buffer. This ensures consistent results between NeoVim versions. |
| 826 |
vim.cmd('e b.txt') |
| 827 |
local bufnr_a = vim.fn.bufnr('a.txt') |
| 828 |
local bufnr_b = vim.fn.bufnr('b.txt') |
| 829 |
require('lualine').setup(conf) |
| 830 |
require('lualine').statusline() |
| 831 |
tabline:expect([===[ |
| 832 |
highlights = { |
| 833 |
1: lualine_a_buffers_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 834 |
2: lualine_transitional_lualine_a_buffers_inactive_to_lualine_a_buffers_active = { bg = "#a89984", fg = "#3c3836", nocombine = true } |
| 835 |
3: lualine_a_buffers_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 836 |
4: lualine_transitional_lualine_a_buffers_active_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 837 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 838 |
} |
| 839 |
|{1: #]===] .. bufnr_a .. [===[ a.txt } |
| 840 |
{2:} |
| 841 |
{3: ]===] .. bufnr_b .. [===[ b.txt } |
| 842 |
{4:} |
| 843 |
{MATCH:{5:%s+}|} |
| 844 |
]===]) |
| 845 |
end) |
| 846 |
|
| 847 |
it('displays alternate buffer correctly when switching buffers', function() |
| 848 |
local conf = vim.deepcopy(tab_conf) |
| 849 |
conf.tabline.lualine_a = { { 'buffers', mode = 3, max_length = 1e3, icons_enabled = false } } |
| 850 |
require('lualine').setup(conf) |
| 851 |
require('lualine').statusline() |
| 852 |
vim.cmd('e a.txt') |
| 853 |
vim.cmd('silent! bd #') -- NeoVim 0.5 does not create an unnamed buffer. This ensures consistent results between NeoVim versions. |
| 854 |
vim.cmd('e b.txt') |
| 855 |
local bufnr_a = vim.fn.bufnr('a.txt') |
| 856 |
local bufnr_b = vim.fn.bufnr('b.txt') |
| 857 |
tabline:expect([===[ |
| 858 |
highlights = { |
| 859 |
1: lualine_a_buffers_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 860 |
2: lualine_transitional_lualine_a_buffers_inactive_to_lualine_a_buffers_active = { bg = "#a89984", fg = "#3c3836", nocombine = true } |
| 861 |
3: lualine_a_buffers_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 862 |
4: lualine_transitional_lualine_a_buffers_active_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 863 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 864 |
} |
| 865 |
|{1: #]===] .. bufnr_a .. [===[ } |
| 866 |
{2:} |
| 867 |
{3: ]===] .. bufnr_b .. [===[ } |
| 868 |
{4:} |
| 869 |
{MATCH:{5:%s+}|} |
| 870 |
]===]) |
| 871 |
vim.cmd('e a.txt') |
| 872 |
tabline:expect([===[ |
| 873 |
highlights = { |
| 874 |
1: lualine_a_buffers_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 875 |
2: lualine_transitional_lualine_a_buffers_active_to_lualine_a_buffers_inactive = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 876 |
3: lualine_a_buffers_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 877 |
4: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 878 |
} |
| 879 |
|{1: ]===] .. bufnr_a .. [===[ } |
| 880 |
{2:} |
| 881 |
{3: #]===] .. bufnr_b .. [===[ } |
| 882 |
{MATCH:{4:%s+}|} |
| 883 |
]===]) |
| 884 |
vim.cmd('bprev') |
| 885 |
tabline:expect([===[ |
| 886 |
highlights = { |
| 887 |
1: lualine_a_buffers_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 888 |
2: lualine_transitional_lualine_a_buffers_inactive_to_lualine_a_buffers_active = { bg = "#a89984", fg = "#3c3836", nocombine = true } |
| 889 |
3: lualine_a_buffers_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 890 |
4: lualine_transitional_lualine_a_buffers_active_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 891 |
5: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 892 |
} |
| 893 |
|{1: #]===] .. bufnr_a .. [===[ } |
| 894 |
{2:} |
| 895 |
{3: ]===] .. bufnr_b .. [===[ } |
| 896 |
{4:} |
| 897 |
{MATCH:{5:%s+}|} |
| 898 |
]===]) |
| 899 |
end) |
| 900 |
end) |
| 901 |
|
| 902 |
describe('windows component', function() |
| 903 |
it('works', function() |
| 904 |
local conf = vim.deepcopy(tab_conf) |
| 905 |
conf.tabline.lualine_a = { { 'windows', max_length = 1e3, mode = 2, icons_enabled = false } } |
| 906 |
vim.cmd('e ' .. 'a.txt') |
| 907 |
vim.cmd('tabe ' .. 'b.txt') |
| 908 |
vim.cmd('vsplit ' .. 'c.txt') |
| 909 |
vim.cmd('tabe ' .. 'd.txt') |
| 910 |
require('lualine').setup(conf) |
| 911 |
require('lualine').statusline() |
| 912 |
tabline:expect([===[ |
| 913 |
highlights = { |
| 914 |
1: lualine_a_windows_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 915 |
2: lualine_transitional_lualine_a_windows_active_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 916 |
3: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 917 |
} |
| 918 |
|{1: 1 d.txt } |
| 919 |
{2:} |
| 920 |
{3: }| |
| 921 |
]===]) |
| 922 |
|
| 923 |
vim.cmd('tabprev') |
| 924 |
tabline:expect([===[ |
| 925 |
highlights = { |
| 926 |
1: lualine_a_windows_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 927 |
2: lualine_transitional_lualine_a_windows_active_to_lualine_a_windows_inactive = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 928 |
3: lualine_a_windows_inactive = { bg = "#3c3836", bold = true, fg = "#a89984", nocombine = true } |
| 929 |
4: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 930 |
} |
| 931 |
|{1: 1 c.txt } |
| 932 |
{2:} |
| 933 |
{3: 2 b.txt } |
| 934 |
{4: }| |
| 935 |
]===]) |
| 936 |
|
| 937 |
vim.cmd('tabprev') |
| 938 |
tabline:expect([===[ |
| 939 |
highlights = { |
| 940 |
1: lualine_a_windows_active = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 941 |
2: lualine_transitional_lualine_a_windows_active_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 942 |
3: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 943 |
} |
| 944 |
|{1: 1 a.txt } |
| 945 |
{2:} |
| 946 |
{3: }| |
| 947 |
]===]) |
| 948 |
end) |
| 949 |
end) |
| 950 |
end) |
| 951 |
|
| 952 |
describe('diagnostics', function() |
| 953 |
local diagnostics_conf = vim.deepcopy(config) |
| 954 |
diagnostics_conf.sections = { |
| 955 |
lualine_a = { |
| 956 |
{ |
| 957 |
'diagnostics', |
| 958 |
symbols = { error = 'E:', warn = 'W:', info = 'I:', hint = 'H:' }, |
| 959 |
diagnostics_color = { |
| 960 |
error = { bg = '#a89984', fg = '#ff0000' }, |
| 961 |
warn = { bg = '#a89984', fg = '#ffa500' }, |
| 962 |
info = { bg = '#a89984', fg = '#add8e6' }, |
| 963 |
hint = { bg = '#a89984', fg = '#d3d3d3' }, |
| 964 |
}, |
| 965 |
sources = { |
| 966 |
function() |
| 967 |
return {} |
| 968 |
end, |
| 969 |
}, |
| 970 |
}, |
| 971 |
}, |
| 972 |
lualine_b = {}, |
| 973 |
lualine_c = {}, |
| 974 |
lualine_x = {}, |
| 975 |
lualine_y = {}, |
| 976 |
lualine_z = {}, |
| 977 |
} |
| 978 |
|
| 979 |
it('does not show without diagnostics', function() |
| 980 |
local conf = vim.deepcopy(diagnostics_conf) |
| 981 |
require('lualine').setup(conf) |
| 982 |
statusline:expect([===[ |
| 983 |
highlights = { |
| 984 |
1: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 985 |
} |
| 986 |
|{1: }| |
| 987 |
]===]) |
| 988 |
end) |
| 989 |
|
| 990 |
it('shows only positive diagnostics', function() |
| 991 |
local conf = vim.deepcopy(diagnostics_conf) |
| 992 |
conf.sections.lualine_a[1].sources[1] = function() |
| 993 |
return { error = 0, warn = 0, info = 1, hint = 0 } |
| 994 |
end |
| 995 |
require('lualine').setup(conf) |
| 996 |
statusline:expect([===[ |
| 997 |
highlights = { |
| 998 |
1: lualine_a_diagnostics_info = { bg = "#a89984", fg = "#add8e6", nocombine = true } |
| 999 |
2: lualine_transitional_lualine_a_diagnostics_info_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 1000 |
3: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 1001 |
} |
| 1002 |
|{1: I:1 } |
| 1003 |
{2:} |
| 1004 |
{3: }| |
| 1005 |
]===]) |
| 1006 |
end) |
| 1007 |
|
| 1008 |
it('shows all diagnostics with same background', function() |
| 1009 |
local conf = vim.deepcopy(diagnostics_conf) |
| 1010 |
conf.sections.lualine_a[1].sources[1] = function() |
| 1011 |
return { error = 1, warn = 2, info = 3, hint = 4 } |
| 1012 |
end |
| 1013 |
require('lualine').setup(conf) |
| 1014 |
statusline:expect([===[ |
| 1015 |
highlights = { |
| 1016 |
1: lualine_a_diagnostics_error = { bg = "#a89984", fg = "#ff0000", nocombine = true } |
| 1017 |
2: lualine_a_diagnostics_warn = { bg = "#a89984", fg = "#ffa500", nocombine = true } |
| 1018 |
3: lualine_a_diagnostics_info = { bg = "#a89984", fg = "#add8e6", nocombine = true } |
| 1019 |
4: lualine_a_diagnostics_hint = { bg = "#a89984", fg = "#d3d3d3", nocombine = true } |
| 1020 |
5: lualine_transitional_lualine_a_diagnostics_hint_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 1021 |
6: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 1022 |
} |
| 1023 |
|{1: E:1 } |
| 1024 |
{2:W:2 } |
| 1025 |
{3:I:3 } |
| 1026 |
{4:H:4 } |
| 1027 |
{5:} |
| 1028 |
{6: }| |
| 1029 |
]===]) |
| 1030 |
end) |
| 1031 |
|
| 1032 |
it('shows all diagnostics with padding when background changes', function() |
| 1033 |
local conf = vim.deepcopy(diagnostics_conf) |
| 1034 |
conf.sections.lualine_a[1].sources[1] = function() |
| 1035 |
return { error = 1, warn = 2, info = 3, hint = 4 } |
| 1036 |
end |
| 1037 |
conf.sections.lualine_a[1].diagnostics_color = { |
| 1038 |
error = { bg = '#ff0000', fg = '#a89984' }, |
| 1039 |
warn = { bg = '#ffa500', fg = '#a89984' }, |
| 1040 |
info = { bg = '#add8e6', fg = '#a89984' }, |
| 1041 |
hint = { bg = '#add8e6', fg = '#a89984' }, |
| 1042 |
} |
| 1043 |
require('lualine').setup(conf) |
| 1044 |
statusline:expect([===[ |
| 1045 |
highlights = { |
| 1046 |
1: lualine_a_diagnostics_error = { bg = "#ff0000", fg = "#a89984", nocombine = true } |
| 1047 |
2: lualine_a_diagnostics_warn = { bg = "#ffa500", fg = "#a89984", nocombine = true } |
| 1048 |
3: lualine_a_diagnostics_info = { bg = "#add8e6", fg = "#a89984", nocombine = true } |
| 1049 |
4: lualine_a_diagnostics_hint = { bg = "#add8e6", fg = "#a89984", nocombine = true } |
| 1050 |
5: lualine_transitional_lualine_a_diagnostics_hint_to_lualine_c_normal = { bg = "#3c3836", fg = "#add8e6", nocombine = true } |
| 1051 |
6: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 1052 |
} |
| 1053 |
|{1: E:1 } |
| 1054 |
{2: W:2 } |
| 1055 |
{3: I:3 } |
| 1056 |
{4:H:4 } |
| 1057 |
{5:} |
| 1058 |
{6: }| |
| 1059 |
]===]) |
| 1060 |
end) |
| 1061 |
end) |
| 1062 |
|
| 1063 |
describe('supports compound filetypes', function() |
| 1064 |
it('disabled filetypes', function() |
| 1065 |
local conf = require('lualine').get_config() |
| 1066 |
conf.options.disabled_filetypes = { 'java' } |
| 1067 |
require('lualine').setup(conf) |
| 1068 |
local old_ft = vim.bo.ft |
| 1069 |
vim.bo.ft = 'lua.java' |
| 1070 |
vim.opt.filetype = 'lua.java' |
| 1071 |
statusline:expect(nil) |
| 1072 |
vim.bo.ft = old_ft |
| 1073 |
end) |
| 1074 |
|
| 1075 |
it('extensions for work on compound filetypes', function() |
| 1076 |
local conf = require('lualine').get_config() |
| 1077 |
table.insert(conf.extensions, { |
| 1078 |
filetypes = { 'test_ft' }, |
| 1079 |
sections = { |
| 1080 |
lualine_a = { |
| 1081 |
function() |
| 1082 |
return 'custom_extension_component' |
| 1083 |
end, |
| 1084 |
}, |
| 1085 |
}, |
| 1086 |
}) |
| 1087 |
local old_ft = vim.bo.ft |
| 1088 |
vim.bo.ft = 'lua.test_ft' |
| 1089 |
require('lualine').setup(conf) |
| 1090 |
statusline:expect([===[ |
| 1091 |
highlights = { |
| 1092 |
1: lualine_a_normal = { bg = "#a89984", bold = true, fg = "#282828", nocombine = true } |
| 1093 |
2: lualine_transitional_lualine_a_normal_to_lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 1094 |
3: lualine_c_normal = { bg = "#3c3836", fg = "#a89984", nocombine = true } |
| 1095 |
} |
| 1096 |
|{1: custom_extension_component } |
| 1097 |
{2:} |
| 1098 |
{3: }| |
| 1099 |
]===]) |
| 1100 |
vim.bo.ft = old_ft |
| 1101 |
end) |
| 1102 |
end) |
| 1103 |
end) |