Prepare components

This commit is contained in:
Olivier Roques
2020-12-22 23:53:44 +01:00
parent 355aacba17
commit 1d80803552
9 changed files with 36 additions and 26 deletions

View File

@@ -24,14 +24,16 @@ M.events = {
}
M.sections = {
require('hardline.mode'), ' ',
require('hardline.git'), ' ',
require('hardline.file'), ' ',
{class = 'A', item = require('hardline.mode').get_item()}, ' ',
{class = 'B', item = require('hardline.git').get_item()}, ' ',
{class = 'C', item = require('hardline.filename').get_item()}, ' ',
'%=',
-- require('hardline.lsp'),
-- require('hardline.whitespace'),
require('hardline.filetype'), ' ',
require('hardline.line'),
-- {class = 'error', item = require('hardline.lsp').get_error()}, ' ',
-- {class = 'warning', item = require('hardline.lsp').get_warning()}, ' ',
-- {class = 'warning', item = require('hardline.whitespace').get_item()}, ' ',
-- {class = 'X', item = require('hardline.wordcount').get_item()}, ' ',
{class = 'Y', item = require('hardline.filetype').get_item()}, ' ',
{class = 'Z', item = require('hardline.line').get_item()},
}
-------------------- HELPERS -------------------------------
@@ -48,9 +50,9 @@ local function load_section(section)
elseif type(section) == 'string' then
return section
elseif type(section) == 'table' then
return load_section(section.get_component)
return load_section(section.item)
end
echo('WarningMsg', 'Section must be a function or a string!')
echo('WarningMsg', 'Invalid section.')
return ''
end

View File

@@ -2,17 +2,17 @@ local fn, vim = vim.fn, vim
local M = {}
function M.get_mode()
return ' %h%r'
return '%h%r'
end
function M.get_name()
return fn.expand('%:~:.')
end
function M.get_component()
function M.get_item()
return table.concat({
[[%<]],
[[%{luaeval('require("hardline.file").get_name()')}]],
'%<',
[[%{luaeval('require("hardline.filename").get_name()')}]], ' ',
M.get_mode(),
})
end

View File

@@ -6,7 +6,7 @@ function M.get_filetype()
return bo.filetype
end
function M.get_component()
function M.get_item()
return table.concat({
[[%{luaeval('require("hardline.filetype").get_filetype()')}]],
})

View File

@@ -18,12 +18,12 @@ function M.get_branch()
if not g.loaded_gitgutter then
return ''
end
return string.format(' %s', fn.FugitiveHead())
return string.format('%s', fn.FugitiveHead())
end
function M.get_component()
function M.get_item()
return table.concat({
[[%{luaeval('require("hardline.git").get_hunks()')}]],
[[%{luaeval('require("hardline.git").get_hunks()')}]], ' ',
[[%{luaeval('require("hardline.git").get_branch()')}]],
})
end

View File

@@ -13,7 +13,7 @@ function M.get_percent()
return '%03p%%'
end
function M.get_component()
function M.get_item()
return table.concat({
[[%{luaeval('require("hardline.line").get_line()')}]], ':',
[[%{luaeval('require("hardline.line").get_column()')}]], ' ',

View File

@@ -1,7 +1,7 @@
local fn, vim = vim.fn, vim
local M = {}
function M.get_component()
function M.get_item()
return table.concat({})
end

View File

@@ -25,21 +25,21 @@ function M.get_paste()
if not o.paste then
return ''
end
return ' PASTE'
return 'PASTE'
end
function M.get_spell()
if not wo.spell then
return ''
end
return string.format(' SPELL [%s]', string.upper(bo.spelllang))
return string.format('SPELL [%s]', string.upper(bo.spelllang))
end
function M.get_component()
function M.get_item()
return table.concat({
[[%{luaeval('require("hardline.mode").get_mode()')}]],
[[%{luaeval('require("hardline.mode").get_paste()')}]],
[[%{luaeval('require("hardline.mode").get_spell()')}]],
[[%{luaeval('require("hardline.mode").get_mode()')}]], ' ',
[[%{luaeval('require("hardline.mode").get_paste()')}]], ' ',
[[%{luaeval('require("hardline.mode").get_spell()')}]], ' '
})
end

View File

@@ -1,7 +1,7 @@
local fn, vim = vim.fn, vim
local M = {}
function M.get_component()
function M.get_item()
return table.concat({})
end

View File

@@ -0,0 +1,8 @@
local fn, vim = vim.fn, vim
local M = {}
function M.get_item()
return table.concat({})
end
return M