vim/lualine: add trailing whitespace
This commit is contained in:
parent
31b9a726eb
commit
7a73598f76
2 changed files with 25 additions and 1 deletions
|
@ -65,6 +65,23 @@ function mode:update_status(is_focused)
|
||||||
return ' '
|
return ' '
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local trailing_whitespace = function()
|
||||||
|
local pattern = [[\s\+$]]
|
||||||
|
local lineno = vim.fn.search(pattern, 'nwc')
|
||||||
|
if lineno == 0 then
|
||||||
|
return ''
|
||||||
|
end
|
||||||
|
|
||||||
|
local result = '·' .. lineno
|
||||||
|
|
||||||
|
local info = vim.fn.searchcount { pattern = pattern }
|
||||||
|
if info.total then
|
||||||
|
result = result .. string.format(' Σ%d', info.total)
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
local colored_if_focused = function(component)
|
local colored_if_focused = function(component)
|
||||||
if type(component) == 'string' then
|
if type(component) == 'string' then
|
||||||
local c = require('lualine.components.' .. component):extend()
|
local c = require('lualine.components.' .. component):extend()
|
||||||
|
@ -96,5 +113,6 @@ return {
|
||||||
colored_if_focused = colored_if_focused,
|
colored_if_focused = colored_if_focused,
|
||||||
filename = filename,
|
filename = filename,
|
||||||
mode = mode,
|
mode = mode,
|
||||||
|
trailing_whitespace = trailing_whitespace,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,12 @@ return {
|
||||||
fg = '#f9f5d7',
|
fg = '#f9f5d7',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
trailing_whitespace = {
|
||||||
|
colored_if_focused(require('fschauen.lualine').trailing_whitespace),
|
||||||
|
color = {
|
||||||
|
bg = orange,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local sections = {
|
local sections = {
|
||||||
|
@ -64,7 +70,7 @@ return {
|
||||||
lualine_c = { C.filename, C.status },
|
lualine_c = { C.filename, C.status },
|
||||||
lualine_x = { C.diagnostics, C.filetype },
|
lualine_x = { C.diagnostics, C.filetype },
|
||||||
lualine_y = { C.fileformat, 'progress' },
|
lualine_y = { C.fileformat, 'progress' },
|
||||||
lualine_z = { 'location' },
|
lualine_z = { 'location', C.trailing_whitespace },
|
||||||
}
|
}
|
||||||
|
|
||||||
require('lualine').setup {
|
require('lualine').setup {
|
||||||
|
|
Loading…
Add table
Reference in a new issue