Add lsp module
This commit is contained in:
@@ -16,6 +16,8 @@ M.options = {
|
||||
{class = 'high', item = require('hardline.parts.git').get_item},
|
||||
{class = 'med', item = require('hardline.parts.filename').get_item},
|
||||
{class = 'med', item ='%='},
|
||||
{class = 'warning', item = require('hardline.parts.lsp').get_warning},
|
||||
{class = 'error', item = require('hardline.parts.lsp').get_error},
|
||||
{class = 'high', item = require('hardline.parts.filetype').get_item},
|
||||
{class = 'mode', item = require('hardline.parts.line').get_item},
|
||||
},
|
||||
|
||||
@@ -14,7 +14,7 @@ local function get_line()
|
||||
end
|
||||
|
||||
local function get_column()
|
||||
local nb_columns = vim.fn.col('$')
|
||||
local nb_columns = vim.fn.col('$') - 1
|
||||
local column = vim.fn.col('.')
|
||||
local max_dots = get_dots(nb_columns, 999)
|
||||
local dots = get_dots(column, 999)
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
local M = {}
|
||||
|
||||
function M.get_item()
|
||||
return table.concat({
|
||||
})
|
||||
local function get_diagnostic(prefix, severity)
|
||||
if vim.tbl_isempty(vim.lsp.buf_get_clients(0)) then return '' end
|
||||
local count = vim.lsp.diagnostic.get_count(0, severity)
|
||||
if count < 1 then return '' end
|
||||
return table.concat({' ', string.format('%s:%d', prefix, count), ' '})
|
||||
end
|
||||
|
||||
return M
|
||||
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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user