General update

This commit is contained in:
Olivier Roques
2020-12-25 18:50:30 +01:00
parent ba1f73adb9
commit b4b2549e21
4 changed files with 9 additions and 18 deletions

View File

@@ -13,9 +13,10 @@ M.options = {
theme = 'default',
sections = {
{class = 'mode', item = require('hardline.parts.mode').get_item},
'%<',
{class = 'high', item = require('hardline.parts.git').get_item},
{class = 'med', item = require('hardline.parts.filename').get_item},
{class = 'med', item = '%='},
'%=',
{class = 'med', item = require('hardline.parts.wordcount').get_item},
{class = 'error', item = require('hardline.parts.lsp').get_error},
{class = 'warning', item = require('hardline.parts.lsp').get_warning},
@@ -36,6 +37,7 @@ local function get_state(class)
end
local function color_section(section)
if type(section) ~= 'table' then return section end
if not section.class or section.class == 'none' then return section.item end
local state = get_state(section.class)
local hlgroup = string.format('Hardline_%s_%s', section.class, state)

View File

@@ -1,8 +1,7 @@
local fn = vim.fn
local function get_item()
local name = fn.expand('%:~:.')
return table.concat({' ', '%<', name, ' '})
return table.concat({' ', fn.expand('%:~:.'), ' %r%m '})
end
return {

View File

@@ -1,32 +1,22 @@
local fn = vim.fn
local function get_dots(current, max)
current = string.len(tostring(current))
max = string.len(tostring(max))
return string.rep('·', max - current)
end
local function get_line()
local nb_lines = fn.line('$')
local line = fn.line('.')
local dots = get_dots(line, nb_lines)
return string.format('%s%d/%d', dots, line, nb_lines)
return string.format('%3d/%3d', line, nb_lines)
end
local function get_column()
local nb_columns = fn.col('$') - 1
local column = fn.col('.')
local max_dots = get_dots(nb_columns, 999)
local dots = get_dots(column, 999)
return string.format('|%s%d/%s%d', dots, column, max_dots, nb_columns)
return string.format(' %2d/%2d', column, nb_columns)
end
local function get_percent()
local nb_lines = fn.line('$')
local line = fn.line('.')
local percent = math.floor(line * 100 / nb_lines)
local dots = get_dots(percent, 100)
return string.format('|%s%d%%%%', dots, percent)
return string.format(' %3d%%%%', percent)
end
local function get_item()

View File

@@ -8,12 +8,12 @@ end
local function get_paste()
if not o.paste then return '' end
return '|PASTE'
return ' PASTE'
end
local function 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
local function get_item()