2021-09-20 11:46:38 +00:00
|
|
|
-- Copyright (c) 2020-2021 shadmansaleh
|
|
|
|
-- MIT license, see LICENSE for more details.
|
|
|
|
|
2021-05-09 21:11:18 +00:00
|
|
|
local eq = assert.are.same
|
|
|
|
|
2021-05-05 18:04:16 +00:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
M.meths = setmetatable({}, {
|
2021-09-03 18:28:20 +00:00
|
|
|
__index = function(_, key)
|
|
|
|
return vim.api['nvim_' .. key]
|
|
|
|
end,
|
2021-05-05 18:04:16 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
-- Checks ouput of a component
|
|
|
|
M.assert_component = function(component, opts, result)
|
|
|
|
-- for testing global options
|
2021-09-03 18:28:20 +00:00
|
|
|
if component == nil then
|
|
|
|
component = 'special.function_component'
|
2021-10-10 16:43:00 +00:00
|
|
|
else
|
|
|
|
opts.component_name = component
|
|
|
|
end
|
|
|
|
local comp = require('lualine.components.' .. component)
|
|
|
|
if type(comp) == 'table' then
|
|
|
|
comp = comp(opts)
|
|
|
|
elseif type(comp) == 'function' then
|
|
|
|
opts[1] = comp
|
|
|
|
comp = require 'lualine.components.special.function_component'(opts)
|
2021-09-03 18:28:20 +00:00
|
|
|
end
|
2021-05-09 21:11:18 +00:00
|
|
|
eq(result, comp:draw(opts.hl))
|
2021-05-05 18:04:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- sets defaults for component options
|
|
|
|
M.build_component_opts = function(opts)
|
2021-09-03 18:28:20 +00:00
|
|
|
if not opts then
|
|
|
|
opts = {}
|
|
|
|
end
|
|
|
|
if opts[1] == nil then
|
|
|
|
opts[1] = function()
|
|
|
|
return 'test'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if not opts.self then
|
|
|
|
opts.self = { section = 'lualine_c' }
|
|
|
|
end
|
|
|
|
if not opts.theme then
|
|
|
|
opts.theme = 'gruvbox'
|
|
|
|
end
|
|
|
|
if not opts.hl then
|
|
|
|
opts.hl = ''
|
|
|
|
end
|
|
|
|
if opts.icons_enabled == nil then
|
|
|
|
opts.icons_enabled = true
|
|
|
|
end
|
2021-05-05 18:04:16 +00:00
|
|
|
if not opts.component_separators then
|
2021-09-14 15:14:23 +00:00
|
|
|
opts.component_separators = { left = '', right = '' }
|
2021-09-03 18:28:20 +00:00
|
|
|
end
|
|
|
|
if not opts.section_separators then
|
2021-09-14 15:14:23 +00:00
|
|
|
opts.section_separators = { left = '', right = '' }
|
2021-05-05 18:04:16 +00:00
|
|
|
end
|
|
|
|
return opts
|
|
|
|
end
|
|
|
|
|
2021-09-03 18:28:20 +00:00
|
|
|
M.P = function(t)
|
|
|
|
print(vim.inspect(t))
|
|
|
|
end
|
2021-05-05 18:04:16 +00:00
|
|
|
|
|
|
|
return M
|