61 lines
1.3 KiB
Lua
61 lines
1.3 KiB
Lua
local function get_git_status()
|
|
local head = vim.b.gitsigns_head or ''
|
|
local signs = vim.b.gitsigns_status or ''
|
|
if signs == '' then
|
|
if head == '-' or head == '' then
|
|
return ''
|
|
end
|
|
return string.format(' %s', head)
|
|
end
|
|
return string.format(' %s %s', head, signs)
|
|
end
|
|
|
|
local function get_lsp_info()
|
|
if vim.lsp.buf.server_ready() then
|
|
local hints = vim.lsp.diagnostic.get_count(0, 'Hint')
|
|
local warnings = vim.lsp.diagnostic.get_count(0, 'Warning')
|
|
local errors = vim.lsp.diagnostic.get_count(0, 'Error')
|
|
return string.format(' :%d :%d :%d ', hints, warnings, errors)
|
|
else
|
|
return ''
|
|
end
|
|
end
|
|
|
|
local function is_modified()
|
|
if vim.bo.modified then
|
|
return ' [+]'
|
|
end
|
|
return ''
|
|
end
|
|
|
|
local function get_file_info()
|
|
return ' %l:%c'
|
|
end
|
|
|
|
function Get_flags()
|
|
return '%h%w%m%r'
|
|
end
|
|
|
|
function Get_file_name()
|
|
return '%<%F'
|
|
end
|
|
|
|
function Color_as(value, group)
|
|
return string.format('%%#%s#%s', group, value)
|
|
end
|
|
|
|
local status_line_template = '%s%s%%=%s%%=%s%s'
|
|
|
|
function RenderStatusLine()
|
|
return string.format(
|
|
status_line_template,
|
|
Color_as(get_lsp_info(), 'diffChanged'),
|
|
Color_as(Get_flags(), 'StatusLine'),
|
|
Color_as(Get_file_name(), 'StatusLine'),
|
|
Color_as(get_git_status(), 'diffChanged'),
|
|
Color_as(get_file_info(), 'StatusLineNC')
|
|
)
|
|
end
|
|
|
|
vim.o.statusline = '%!v:lua.RenderStatusLine()'
|