chore: autogen (vimdocs+formating)
This commit is contained in:
parent
bf6e2eaf54
commit
6f28adb21f
|
@ -31,7 +31,7 @@ local bubbles_theme = {
|
|||
},
|
||||
}
|
||||
|
||||
require('lualine').setup({
|
||||
require('lualine').setup {
|
||||
options = {
|
||||
theme = bubbles_theme,
|
||||
component_separators = '|',
|
||||
|
@ -59,4 +59,4 @@ require('lualine').setup({
|
|||
},
|
||||
tabline = {},
|
||||
extensions = {},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -78,15 +78,15 @@ local function ins_right(component)
|
|||
table.insert(config.sections.lualine_x, component)
|
||||
end
|
||||
|
||||
ins_left({
|
||||
ins_left {
|
||||
function()
|
||||
return '▊'
|
||||
end,
|
||||
color = { fg = colors.blue }, -- Sets highlighting of component
|
||||
padding = { left = 0, right = 1 }, -- We don't need space before this
|
||||
})
|
||||
}
|
||||
|
||||
ins_left({
|
||||
ins_left {
|
||||
-- mode component
|
||||
function()
|
||||
-- auto change color according to neovims mode
|
||||
|
@ -117,25 +117,25 @@ ins_left({
|
|||
end,
|
||||
color = 'LualineMode',
|
||||
padding = { right = 1 },
|
||||
})
|
||||
}
|
||||
|
||||
ins_left({
|
||||
ins_left {
|
||||
-- filesize component
|
||||
'filesize',
|
||||
cond = conditions.buffer_not_empty,
|
||||
})
|
||||
}
|
||||
|
||||
ins_left({
|
||||
ins_left {
|
||||
'filename',
|
||||
cond = conditions.buffer_not_empty,
|
||||
color = { fg = colors.magenta, gui = 'bold' },
|
||||
})
|
||||
}
|
||||
|
||||
ins_left({ 'location' })
|
||||
ins_left { 'location' }
|
||||
|
||||
ins_left({ 'progress', color = { fg = colors.fg, gui = 'bold' } })
|
||||
ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } }
|
||||
|
||||
ins_left({
|
||||
ins_left {
|
||||
'diagnostics',
|
||||
sources = { 'nvim_diagnostic' },
|
||||
symbols = { error = ' ', warn = ' ', info = ' ' },
|
||||
|
@ -144,17 +144,17 @@ ins_left({
|
|||
color_warn = { fg = colors.yellow },
|
||||
color_info = { fg = colors.cyan },
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
-- Insert mid section. You can make any number of sections in neovim :)
|
||||
-- for lualine it's any number greater then 2
|
||||
ins_left({
|
||||
ins_left {
|
||||
function()
|
||||
return '%='
|
||||
end,
|
||||
})
|
||||
}
|
||||
|
||||
ins_left({
|
||||
ins_left {
|
||||
-- Lsp server name .
|
||||
function()
|
||||
local msg = 'No Active Lsp'
|
||||
|
@ -173,30 +173,30 @@ ins_left({
|
|||
end,
|
||||
icon = ' LSP:',
|
||||
color = { fg = '#ffffff', gui = 'bold' },
|
||||
})
|
||||
}
|
||||
|
||||
-- Add components to right sections
|
||||
ins_right({
|
||||
ins_right {
|
||||
'o:encoding', -- option component same as &encoding in viml
|
||||
fmt = string.upper, -- I'm not sure why it's upper case either ;)
|
||||
cond = conditions.hide_in_width,
|
||||
color = { fg = colors.green, gui = 'bold' },
|
||||
})
|
||||
}
|
||||
|
||||
ins_right({
|
||||
ins_right {
|
||||
'fileformat',
|
||||
fmt = string.upper,
|
||||
icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh
|
||||
color = { fg = colors.green, gui = 'bold' },
|
||||
})
|
||||
}
|
||||
|
||||
ins_right({
|
||||
ins_right {
|
||||
'branch',
|
||||
icon = '',
|
||||
color = { fg = colors.violet, gui = 'bold' },
|
||||
})
|
||||
}
|
||||
|
||||
ins_right({
|
||||
ins_right {
|
||||
'diff',
|
||||
-- Is it me or the symbol for modified us really weird
|
||||
symbols = { added = ' ', modified = '柳 ', removed = ' ' },
|
||||
|
@ -206,15 +206,15 @@ ins_right({
|
|||
removed = { fg = colors.red },
|
||||
},
|
||||
cond = conditions.hide_in_width,
|
||||
})
|
||||
}
|
||||
|
||||
ins_right({
|
||||
ins_right {
|
||||
function()
|
||||
return '▊'
|
||||
end,
|
||||
color = { fg = colors.blue },
|
||||
padding = { left = 1 },
|
||||
})
|
||||
}
|
||||
|
||||
-- Now don't forget to initialize lualine
|
||||
lualine.setup(config)
|
||||
|
|
|
@ -55,7 +55,7 @@ local function search_result()
|
|||
if not last_search or last_search == '' then
|
||||
return ''
|
||||
end
|
||||
local searchcount = vim.fn.searchcount({ maxcount = 9999 })
|
||||
local searchcount = vim.fn.searchcount { maxcount = 9999 }
|
||||
return last_search .. '(' .. searchcount.current .. '/' .. searchcount.total .. ')'
|
||||
end
|
||||
|
||||
|
@ -68,13 +68,13 @@ local function modified()
|
|||
return ''
|
||||
end
|
||||
|
||||
require('lualine').setup({
|
||||
require('lualine').setup {
|
||||
options = {
|
||||
theme = theme,
|
||||
component_separators = '',
|
||||
section_separators = { left = '', right = '' },
|
||||
},
|
||||
sections = process_sections({
|
||||
sections = process_sections {
|
||||
lualine_a = { 'mode' },
|
||||
lualine_b = {
|
||||
'branch',
|
||||
|
@ -116,9 +116,9 @@ require('lualine').setup({
|
|||
lualine_x = {},
|
||||
lualine_y = { search_result, 'filetype' },
|
||||
lualine_z = { '%l:%c', '%p%%/%L' },
|
||||
}),
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_c = { '%f %y %m' },
|
||||
lualine_x = {},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
-- Copyright (c) 2020-2021 hoob3rt
|
||||
-- MIT license, see LICENSE for more details.
|
||||
local lualine_require = require('lualine_require')
|
||||
local modules = lualine_require.lazy_require({
|
||||
local modules = lualine_require.lazy_require {
|
||||
highlight = 'lualine.highlight',
|
||||
loader = 'lualine.utils.loader',
|
||||
utils_section = 'lualine.utils.section',
|
||||
utils = 'lualine.utils.utils',
|
||||
utils_notices = 'lualine.utils.notices',
|
||||
config_module = 'lualine.config',
|
||||
})
|
||||
}
|
||||
local config -- Stores currently applied config
|
||||
local new_config = true -- Stores config that will be applied
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ function M:update_status()
|
|||
local buffers = {}
|
||||
for b = 1, vim.fn.bufnr('$') do
|
||||
if vim.fn.buflisted(b) ~= 0 and vim.api.nvim_buf_get_option(b, 'buftype') ~= 'quickfix' then
|
||||
buffers[#buffers + 1] = Buffer({ bufnr = b, options = self.options, highlights = self.highlights })
|
||||
buffers[#buffers + 1] = Buffer { bufnr = b, options = self.options, highlights = self.highlights }
|
||||
end
|
||||
end
|
||||
local current_bufnr = vim.api.nvim_get_current_buf()
|
||||
|
@ -110,7 +110,7 @@ function M:update_status()
|
|||
-- start drawing from current buffer and draw left and right of it until
|
||||
-- all buffers are drawn or max_length has been reached.
|
||||
if current == -2 then
|
||||
local b = Buffer({ bufnr = vim.api.nvim_get_current_buf(), options = self.options, highlights = self.highlights })
|
||||
local b = Buffer { bufnr = vim.api.nvim_get_current_buf(), options = self.options, highlights = self.highlights }
|
||||
b.current = true
|
||||
if self.options.self.section < 'lualine_x' then
|
||||
b.last = true
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
-- Copyright (c) 2020-2021 hoob3rt
|
||||
-- MIT license, see LICENSE for more details.
|
||||
local lualine_require = require('lualine_require')
|
||||
local modules = lualine_require.lazy_require({
|
||||
local modules = lualine_require.lazy_require {
|
||||
default_config = 'lualine.components.diagnostics.config',
|
||||
sources = 'lualine.components.diagnostics.sources',
|
||||
highlight = 'lualine.highlight',
|
||||
utils = 'lualine.utils.utils',
|
||||
utils_notices = 'lualine.utils.notices',
|
||||
})
|
||||
}
|
||||
|
||||
local M = lualine_require.require('lualine.component'):extend()
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
local lualine_require = require('lualine_require')
|
||||
local modules = lualine_require.lazy_require({
|
||||
local modules = lualine_require.lazy_require {
|
||||
utils = 'lualine.utils.utils',
|
||||
Job = 'lualine.utils.job',
|
||||
})
|
||||
}
|
||||
|
||||
local M = {}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
-- Copyright (c) 2020-2021 shadmansaleh
|
||||
-- MIT license, see LICENSE for more details.
|
||||
local lualine_require = require('lualine_require')
|
||||
local modules = lualine_require.lazy_require({
|
||||
local modules = lualine_require.lazy_require {
|
||||
git_diff = 'lualine.components.diff.git_diff',
|
||||
utils = 'lualine.utils.utils',
|
||||
utils_notices = 'lualine.utils.notices',
|
||||
highlight = 'lualine.highlight',
|
||||
})
|
||||
}
|
||||
local M = lualine_require.require('lualine.component'):extend()
|
||||
|
||||
local default_options = {
|
||||
|
@ -81,7 +81,7 @@ function M:update_status(is_focused)
|
|||
|
||||
local result = {}
|
||||
-- loop though data and load available sections in result table
|
||||
for _, name in ipairs({ 'added', 'modified', 'removed' }) do
|
||||
for _, name in ipairs { 'added', 'modified', 'removed' } do
|
||||
if git_diff[name] and git_diff[name] > 0 then
|
||||
if self.options.colored then
|
||||
table.insert(result, colors[name] .. self.options.symbols[name] .. git_diff[name])
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
-- Copyright (c) 2020-2021 hoob3rt
|
||||
-- MIT license, see LICENSE for more details.
|
||||
local lualine_require = require('lualine_require')
|
||||
local modules = lualine_require.lazy_require({
|
||||
local modules = lualine_require.lazy_require {
|
||||
highlight = 'lualine.highlight',
|
||||
utils = 'lualine.utils.utils',
|
||||
})
|
||||
}
|
||||
local M = lualine_require.require('lualine.component'):extend()
|
||||
|
||||
local default_options = {
|
||||
|
|
|
@ -58,7 +58,7 @@ function M:update_status()
|
|||
local data = {}
|
||||
local tabs = {}
|
||||
for t = 1, vim.fn.tabpagenr('$') do
|
||||
tabs[#tabs + 1] = Tab({ tabnr = t, options = self.options, highlights = self.highlights })
|
||||
tabs[#tabs + 1] = Tab { tabnr = t, options = self.options, highlights = self.highlights }
|
||||
end
|
||||
-- mark the first, last, current, before current, after current tabpages
|
||||
-- for rendering
|
||||
|
@ -93,7 +93,7 @@ function M:update_status()
|
|||
-- start drawing from current tab and draw left and right of it until
|
||||
-- all tabpages are drawn or max_length has been reached.
|
||||
if current_tab == nil then -- maybe redundent code
|
||||
local t = Tab({ tabnr = vim.fn.tabpagenr(), options = self.options, highlights = self.highlights })
|
||||
local t = Tab { tabnr = vim.fn.tabpagenr(), options = self.options, highlights = self.highlights }
|
||||
t.current = true
|
||||
t.last = true
|
||||
data[#data + 1] = t:render()
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
local M = {}
|
||||
local lualine_require = require('lualine_require')
|
||||
local require = lualine_require.require
|
||||
local modules = lualine_require.lazy_require({
|
||||
local modules = lualine_require.lazy_require {
|
||||
utils = 'lualine.utils.utils',
|
||||
color_utils = 'lualine.utils.color_utils',
|
||||
})
|
||||
}
|
||||
|
||||
local section_highlight_map = { x = 'c', y = 'b', z = 'a' }
|
||||
local active_theme = nil
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
-- MIT license, see LICENSE for more details.
|
||||
|
||||
local lualine_require = require('lualine_require')
|
||||
local modules = lualine_require.lazy_require({
|
||||
local modules = lualine_require.lazy_require {
|
||||
utils_notices = 'lualine.utils.notices',
|
||||
})
|
||||
}
|
||||
local sep = package.config:sub(1, 1)
|
||||
local wal_colors_path = table.concat({ os.getenv('HOME'), '.cache', 'wal', 'colors.sh' }, sep)
|
||||
local wal_colors_file = io.open(wal_colors_path, 'r')
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
local lualine_require = require('lualine_require')
|
||||
local require = lualine_require.require
|
||||
local modules = lualine_require.lazy_require({
|
||||
local modules = lualine_require.lazy_require {
|
||||
utils = 'lualine.utils.utils',
|
||||
notice = 'lualine.utils.notices',
|
||||
})
|
||||
}
|
||||
local is_valid_filename = lualine_require.is_valid_filename
|
||||
local sep = lualine_require.sep
|
||||
|
||||
|
@ -213,10 +213,10 @@ end
|
|||
local function load_theme(theme_name)
|
||||
assert(is_valid_filename(theme_name), 'Invalid filename')
|
||||
local retval
|
||||
local path = table.concat({ 'lua/lualine/themes/', theme_name, '.lua' })
|
||||
local path = table.concat { 'lua/lualine/themes/', theme_name, '.lua' }
|
||||
local files = vim.api.nvim_get_runtime_file(path, true)
|
||||
if #files <= 0 then
|
||||
path = table.concat({ 'lua/lualine/themes/', theme_name, '/init.lua' })
|
||||
path = table.concat { 'lua/lualine/themes/', theme_name, '/init.lua' }
|
||||
files = vim.api.nvim_get_runtime_file(path, true)
|
||||
end
|
||||
local n_files = #files
|
||||
|
|
|
@ -53,10 +53,10 @@ function M.require(module)
|
|||
end
|
||||
end
|
||||
|
||||
pattern_path = table.concat({ 'lua/', module:gsub('%.', '/'), '.lua' })
|
||||
pattern_path = table.concat { 'lua/', module:gsub('%.', '/'), '.lua' }
|
||||
local paths = vim.api.nvim_get_runtime_file(pattern_path, false)
|
||||
if #paths <= 0 then
|
||||
pattern_path = table.concat({ 'lua/', module:gsub('%.', '/'), '/init.lua' })
|
||||
pattern_path = table.concat { 'lua/', module:gsub('%.', '/'), '/init.lua' }
|
||||
paths = vim.api.nvim_get_runtime_file(pattern_path, false)
|
||||
end
|
||||
if #paths > 0 then
|
||||
|
|
|
@ -15,7 +15,7 @@ describe('Component:', function()
|
|||
local comp = require('lualine.components.special.function_component')(opts)
|
||||
-- correct for lualine_c
|
||||
eq('', comp.options.separator)
|
||||
local opts2 = build_component_opts({ self = { section = 'lualine_y' } })
|
||||
local opts2 = build_component_opts { self = { section = 'lualine_y' } }
|
||||
local comp2 = require('lualine.components.special.function_component')(opts2)
|
||||
-- correct for lualine_u
|
||||
eq('', comp2.options.separator)
|
||||
|
@ -31,7 +31,7 @@ describe('Component:', function()
|
|||
|
||||
it('create option highlights', function()
|
||||
local color = { fg = '#224532', bg = '#892345' }
|
||||
local opts1 = build_component_opts({ color = color })
|
||||
local opts1 = build_component_opts { color = color }
|
||||
local hl = require('lualine.highlight')
|
||||
stub(hl, 'create_component_highlight_group')
|
||||
hl.create_component_highlight_group.returns('MyCompHl')
|
||||
|
@ -43,7 +43,7 @@ describe('Component:', function()
|
|||
assert.stub(hl.create_component_highlight_group).was_called_with(color, comp1.options.component_name, comp1.options)
|
||||
hl.create_component_highlight_group:revert()
|
||||
color = 'MyHl'
|
||||
local opts2 = build_component_opts({ color = color })
|
||||
local opts2 = build_component_opts { color = color }
|
||||
stub(hl, 'create_component_highlight_group')
|
||||
hl.create_component_highlight_group.returns('MyCompLinkedHl')
|
||||
local comp2 = require('lualine.components.special.function_component')(opts2)
|
||||
|
@ -56,143 +56,143 @@ describe('Component:', function()
|
|||
end)
|
||||
|
||||
it('can draw', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
})
|
||||
}
|
||||
assert_component(nil, opts, 'test')
|
||||
end)
|
||||
|
||||
it('can apply separators', function()
|
||||
local opts = build_component_opts({ padding = 0 })
|
||||
local opts = build_component_opts { padding = 0 }
|
||||
assert_component(nil, opts, 'test')
|
||||
end)
|
||||
|
||||
it('can apply default highlight', function()
|
||||
local opts = build_component_opts({ padding = 0, hl = '%#My_highlight#' })
|
||||
local opts = build_component_opts { padding = 0, hl = '%#My_highlight#' }
|
||||
assert_component(nil, opts, '%#My_highlight#test')
|
||||
opts = build_component_opts({
|
||||
opts = build_component_opts {
|
||||
function()
|
||||
return '%#Custom_hl#test'
|
||||
end,
|
||||
padding = 0,
|
||||
hl = '%#My_highlight#',
|
||||
})
|
||||
}
|
||||
assert_component(nil, opts, '%#Custom_hl#test%#My_highlight#')
|
||||
opts = build_component_opts({
|
||||
opts = build_component_opts {
|
||||
function()
|
||||
return 'in middle%#Custom_hl#test'
|
||||
end,
|
||||
padding = 0,
|
||||
hl = '%#My_highlight#',
|
||||
})
|
||||
}
|
||||
assert_component(nil, opts, '%#My_highlight#in middle%#Custom_hl#test%#My_highlight#')
|
||||
end)
|
||||
|
||||
describe('Global options:', function()
|
||||
it('left_padding', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = { left = 5 },
|
||||
})
|
||||
}
|
||||
assert_component(nil, opts, ' test')
|
||||
end)
|
||||
|
||||
it('right_padding', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = { right = 5 },
|
||||
})
|
||||
}
|
||||
assert_component(nil, opts, 'test ')
|
||||
end)
|
||||
|
||||
it('padding', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 5,
|
||||
})
|
||||
}
|
||||
assert_component(nil, opts, ' test ')
|
||||
end)
|
||||
|
||||
it('icon', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
icon = '0',
|
||||
})
|
||||
}
|
||||
assert_component(nil, opts, '0 test')
|
||||
end)
|
||||
|
||||
it('icons_enabled', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
icons_enabled = true,
|
||||
icon = '0',
|
||||
})
|
||||
}
|
||||
assert_component(nil, opts, '0 test')
|
||||
local opts2 = build_component_opts({
|
||||
local opts2 = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
icons_enabled = false,
|
||||
icon = '0',
|
||||
})
|
||||
}
|
||||
assert_component(nil, opts2, 'test')
|
||||
end)
|
||||
|
||||
it('separator', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
separator = '|',
|
||||
})
|
||||
}
|
||||
assert_component(nil, opts, 'test|')
|
||||
end)
|
||||
|
||||
it('fmt', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
fmt = function(data)
|
||||
return data:sub(1, 1):upper() .. data:sub(2, #data)
|
||||
end,
|
||||
})
|
||||
}
|
||||
assert_component(nil, opts, 'Test')
|
||||
end)
|
||||
|
||||
it('cond', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
cond = function()
|
||||
return true
|
||||
end,
|
||||
})
|
||||
}
|
||||
assert_component(nil, opts, 'test')
|
||||
local opts2 = build_component_opts({
|
||||
local opts2 = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
cond = function()
|
||||
return false
|
||||
end,
|
||||
})
|
||||
}
|
||||
assert_component(nil, opts2, '')
|
||||
end)
|
||||
|
||||
it('color', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
color = 'MyHl',
|
||||
})
|
||||
}
|
||||
local comp = require('lualine.components.special.function_component')(opts)
|
||||
local custom_link_hl_name = 'lualine_' .. comp.options.component_name .. '_no_mode'
|
||||
eq('%#' .. custom_link_hl_name .. '#test', comp:draw(opts.hl))
|
||||
local opts2 = build_component_opts({
|
||||
local opts2 = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
color = { bg = '#230055', fg = '#223344' },
|
||||
})
|
||||
}
|
||||
local hl = require('lualine.highlight')
|
||||
stub(hl, 'component_format_highlight')
|
||||
hl.component_format_highlight.returns('%#MyCompHl#')
|
||||
|
@ -206,10 +206,10 @@ end)
|
|||
|
||||
describe('Encoding component', function()
|
||||
it('works', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
})
|
||||
}
|
||||
local tmp_path = 'tmp.txt'
|
||||
local tmp_fp = io.open(tmp_path, 'w')
|
||||
tmp_fp:write('test file')
|
||||
|
@ -223,10 +223,10 @@ end)
|
|||
|
||||
describe('Fileformat component', function()
|
||||
it('works with icons', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
})
|
||||
}
|
||||
local fmt = vim.bo.fileformat
|
||||
vim.bo.fileformat = 'unix'
|
||||
assert_component('fileformat', opts, '')
|
||||
|
@ -237,11 +237,11 @@ describe('Fileformat component', function()
|
|||
vim.bo.fileformat = fmt
|
||||
end)
|
||||
it('works without icons', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
icons_enabled = false,
|
||||
})
|
||||
}
|
||||
assert_component('fileformat', opts, vim.bo.fileformat)
|
||||
end)
|
||||
end)
|
||||
|
@ -266,10 +266,10 @@ describe('Filetype component', function()
|
|||
end
|
||||
return old_require(...)
|
||||
end
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
})
|
||||
}
|
||||
assert_component('filetype', opts, 'lua')
|
||||
_G.require = old_require
|
||||
end)
|
||||
|
@ -288,12 +288,12 @@ describe('Filetype component', function()
|
|||
hl.create_component_highlight_group.returns('MyCompHl')
|
||||
utils.extract_highlight_colors.returns('#000')
|
||||
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
colored = true,
|
||||
icon_only = false,
|
||||
})
|
||||
}
|
||||
assert_component('filetype', opts, '%#MyCompHl_normal#*%#lualine_c_normal# lua')
|
||||
assert.stub(utils.extract_highlight_colors).was_called_with('test_highlight_group', 'fg')
|
||||
assert.stub(hl.create_component_highlight_group).was_called_with({ fg = '#000' }, 'test_highlight_group', opts)
|
||||
|
@ -314,11 +314,11 @@ describe('Filetype component', function()
|
|||
stub(utils, 'extract_highlight_colors')
|
||||
hl.create_component_highlight_group.returns('MyCompHl')
|
||||
utils.extract_highlight_colors.returns('#000')
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
colored = false,
|
||||
})
|
||||
}
|
||||
assert_component('filetype', opts, '* lua')
|
||||
hl.create_component_highlight_group:revert()
|
||||
utils.extract_highlight_colors:revert()
|
||||
|
@ -332,12 +332,12 @@ describe('Filetype component', function()
|
|||
end,
|
||||
}
|
||||
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
colored = false,
|
||||
icon_only = true,
|
||||
})
|
||||
}
|
||||
assert_component('filetype', opts, '*')
|
||||
package.loaded['nvim-web-devicons'] = nil
|
||||
end)
|
||||
|
@ -347,10 +347,10 @@ describe('Hostname component', function()
|
|||
it('works', function()
|
||||
stub(vim.loop, 'os_gethostname')
|
||||
vim.loop.os_gethostname.returns('localhost')
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
})
|
||||
}
|
||||
assert_component('hostname', opts, 'localhost')
|
||||
vim.loop.os_gethostname:revert()
|
||||
end)
|
||||
|
@ -358,20 +358,20 @@ end)
|
|||
|
||||
describe('Location component', function()
|
||||
it('works', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
})
|
||||
}
|
||||
assert_component('location', opts, '%3l:%-2v')
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('Progress component', function()
|
||||
it('works', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
})
|
||||
}
|
||||
assert_component('progress', opts, '%3p%%')
|
||||
end)
|
||||
end)
|
||||
|
@ -379,11 +379,11 @@ end)
|
|||
describe('Mode component', function()
|
||||
it('works', function()
|
||||
stub(vim.api, 'nvim_get_mode')
|
||||
vim.api.nvim_get_mode.returns({ mode = 'n', blocking = false })
|
||||
local opts = build_component_opts({
|
||||
vim.api.nvim_get_mode.returns { mode = 'n', blocking = false }
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
})
|
||||
}
|
||||
assert_component('mode', opts, 'NORMAL')
|
||||
vim.api.nvim_get_mode:revert()
|
||||
end)
|
||||
|
@ -391,10 +391,10 @@ end)
|
|||
|
||||
describe('FileSize component', function()
|
||||
it('works', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
})
|
||||
}
|
||||
local fname = 'test-file.txt'
|
||||
local f = io.open(fname, 'w')
|
||||
f:write(string.rep('........................................\n', 200))
|
||||
|
@ -421,24 +421,24 @@ describe('Filename component', function()
|
|||
end
|
||||
|
||||
it('works', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
file_status = false,
|
||||
path = 0,
|
||||
})
|
||||
}
|
||||
vim.cmd(':e test-file.txt')
|
||||
assert_component('filename', opts, 'test-file.txt')
|
||||
vim.cmd(':bdelete!')
|
||||
end)
|
||||
|
||||
it('can show file_status', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
file_status = true,
|
||||
path = 0,
|
||||
})
|
||||
}
|
||||
vim.cmd(':e test-file.txt')
|
||||
vim.bo.modified = false
|
||||
assert_component('filename', opts, 'test-file.txt')
|
||||
|
@ -451,24 +451,24 @@ describe('Filename component', function()
|
|||
end)
|
||||
|
||||
it('can show relative path', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
file_status = false,
|
||||
path = 1,
|
||||
})
|
||||
}
|
||||
vim.cmd(':e test-file.txt')
|
||||
assert_component('filename', opts, shorten_path(vim.fn.expand('%:~:.')))
|
||||
vim.cmd(':bdelete!')
|
||||
end)
|
||||
|
||||
it('can show full path', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
file_status = false,
|
||||
path = 2,
|
||||
})
|
||||
}
|
||||
vim.cmd(':e test-file.txt')
|
||||
assert_component('filename', opts, shorten_path(vim.fn.expand('%:p')))
|
||||
vim.cmd(':bdelete!')
|
||||
|
@ -476,10 +476,10 @@ describe('Filename component', function()
|
|||
end)
|
||||
|
||||
describe('vim option & variable component', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
})
|
||||
}
|
||||
|
||||
local function assert_vim_var_component(name, options, result)
|
||||
options[1] = name
|
||||
|
@ -514,10 +514,10 @@ describe('vim option & variable component', function()
|
|||
end)
|
||||
|
||||
describe('Vim option & variable component', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
})
|
||||
}
|
||||
|
||||
local function assert_vim_var_component(name, options, result)
|
||||
options[1] = name
|
||||
|
@ -569,10 +569,10 @@ describe('Branch component', function()
|
|||
end)
|
||||
|
||||
it('works with regular branches', function()
|
||||
local opts = build_component_opts({
|
||||
local opts = build_component_opts {
|
||||
component_separators = { left = '', right = '' },
|
||||
padding = 0,
|
||||
})
|
||||
}
|
||||
local branch_comp = helpers.init_component('branch', opts)
|
||||
vim.cmd('e ' .. file)
|
||||
assert_comp_ins(branch_comp, ' test_branch')
|
||||
|
|
|
@ -9,7 +9,7 @@ describe('config parsing', function()
|
|||
describe('options', function()
|
||||
describe('icons_enabled', function()
|
||||
it('default', function()
|
||||
local config = config_module.apply_configuration({})
|
||||
local config = config_module.apply_configuration {}
|
||||
eq(config.options.icons_enabled, true)
|
||||
end)
|
||||
it('custom', function()
|
||||
|
@ -21,7 +21,7 @@ describe('config parsing', function()
|
|||
|
||||
describe('theme', function()
|
||||
it('default', function()
|
||||
local config = config_module.apply_configuration({})
|
||||
local config = config_module.apply_configuration {}
|
||||
eq(config.options.theme, 'auto')
|
||||
end)
|
||||
it('custom', function()
|
||||
|
@ -36,7 +36,7 @@ describe('config parsing', function()
|
|||
|
||||
describe('separators', function()
|
||||
it('default', function()
|
||||
local config = config_module.apply_configuration({})
|
||||
local config = config_module.apply_configuration {}
|
||||
eq(config.options.component_separators, { left = '', right = '' })
|
||||
eq(config.options.section_separators, { left = '', right = '' })
|
||||
end)
|
||||
|
@ -85,7 +85,7 @@ describe('config parsing', function()
|
|||
|
||||
describe('disabled filetypes', function()
|
||||
it('default', function()
|
||||
local config = config_module.apply_configuration({})
|
||||
local config = config_module.apply_configuration {}
|
||||
eq(config.options.disabled_filetypes, {})
|
||||
end)
|
||||
it('custom', function()
|
||||
|
|
|
@ -57,7 +57,7 @@ end)
|
|||
describe('Section genarator', function()
|
||||
local sec = require('lualine.utils.section')
|
||||
it('can draw', function()
|
||||
local opts = build_component_opts({ section_separators = { left = '', right = '' } })
|
||||
local opts = build_component_opts { section_separators = { left = '', right = '' } }
|
||||
local section = {
|
||||
require('lualine.components.special.function_component')(opts),
|
||||
require('lualine.components.special.function_component')(opts),
|
||||
|
@ -66,16 +66,16 @@ describe('Section genarator', function()
|
|||
end)
|
||||
|
||||
it('can remove separators from component with custom colors', function()
|
||||
local opts = build_component_opts({ section_separators = { left = '', right = '' } })
|
||||
local opts_colored = build_component_opts({ color = 'MyColor' })
|
||||
local opts_colored2 = build_component_opts({
|
||||
local opts = build_component_opts { section_separators = { left = '', right = '' } }
|
||||
local opts_colored = build_component_opts { color = 'MyColor' }
|
||||
local opts_colored2 = build_component_opts {
|
||||
color = { bg = '#223344' },
|
||||
section_separators = { left = '', right = '' },
|
||||
})
|
||||
local opts_colored3 = build_component_opts({
|
||||
}
|
||||
local opts_colored3 = build_component_opts {
|
||||
color = { fg = '#223344' },
|
||||
section_separators = { left = '', right = '' },
|
||||
})
|
||||
}
|
||||
require('lualine.highlight').create_highlight_groups(require('lualine.themes.gruvbox'))
|
||||
local section = {
|
||||
require('lualine.components.special.function_component')(opts),
|
||||
|
|
Loading…
Reference in New Issue