Files
nvim-hardline/lua/hardline/parts/lsp.lua
Olivier Roques 3f8e61a4e4 Refactor
2020-12-26 00:25:31 +01:00

22 lines
492 B
Lua

local lsp, vim = vim.lsp, vim
local function get_diagnostic(prefix, severity)
if vim.tbl_isempty(lsp.buf_get_clients(0)) then return '' end
local count = lsp.diagnostic.get_count(0, severity)
if count < 1 then return '' end
return string.format('%s:%d', prefix, count)
end
local function get_error()
return get_diagnostic('E', 'Error')
end
local function get_warning()
return get_diagnostic('W', 'Warning')
end
return {
get_error = get_error,
get_warning = get_warning,
}