From b4b2549e2175cee50d2ed63b951955aef632dd21 Mon Sep 17 00:00:00 2001 From: Olivier Roques Date: Fri, 25 Dec 2020 18:50:30 +0100 Subject: [PATCH] General update --- lua/hardline.lua | 4 +++- lua/hardline/parts/filename.lua | 3 +-- lua/hardline/parts/line.lua | 16 +++------------- lua/hardline/parts/mode.lua | 4 ++-- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/lua/hardline.lua b/lua/hardline.lua index 40c3958..69472a6 100644 --- a/lua/hardline.lua +++ b/lua/hardline.lua @@ -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) diff --git a/lua/hardline/parts/filename.lua b/lua/hardline/parts/filename.lua index bd668d3..5d4d671 100644 --- a/lua/hardline/parts/filename.lua +++ b/lua/hardline/parts/filename.lua @@ -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 { diff --git a/lua/hardline/parts/line.lua b/lua/hardline/parts/line.lua index 526c331..96b7eb3 100644 --- a/lua/hardline/parts/line.lua +++ b/lua/hardline/parts/line.lua @@ -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() diff --git a/lua/hardline/parts/mode.lua b/lua/hardline/parts/mode.lua index 7bf8dd0..12c9080 100644 --- a/lua/hardline/parts/mode.lua +++ b/lua/hardline/parts/mode.lua @@ -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()