Skip to content

Commit 8e06dd9

Browse files
authored
Add the ability to disable diagnostics (#50)
* Add the ability to disable diagnostics * Fix trailing space return
1 parent e70aa60 commit 8e06dd9

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

lua/lsp-status.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local default_config = {
22
kind_labels = {},
33
current_function = true,
4+
diagnostics = true,
45
indicator_separator = ' ',
56
indicator_errors = '',
67
indicator_warnings = '',

lua/lsp-status/statusline.lua

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,38 @@ end
3838
local function get_lsp_statusline(bufnr)
3939
bufnr = bufnr or 0
4040
if #vim.lsp.buf_get_clients(bufnr) == 0 then return '' end
41-
local buf_diagnostics = diagnostics(bufnr)
41+
local buf_diagnostics = (config.diagnostics) and diagnostics(bufnr) or nil
4242
local buf_messages = messages()
4343
local only_hint = true
4444
local some_diagnostics = false
4545
local status_parts = {}
46-
if buf_diagnostics.errors and buf_diagnostics.errors > 0 then
47-
table.insert(status_parts,
48-
config.indicator_errors .. config.indicator_separator .. buf_diagnostics.errors)
49-
only_hint = false
50-
some_diagnostics = true
51-
end
46+
if buf_diagnostics then
47+
if buf_diagnostics.errors and buf_diagnostics.errors > 0 then
48+
table.insert(status_parts,
49+
config.indicator_errors .. config.indicator_separator .. buf_diagnostics.errors)
50+
only_hint = false
51+
some_diagnostics = true
52+
end
5253

53-
if buf_diagnostics.warnings and buf_diagnostics.warnings > 0 then
54-
table.insert(status_parts, config.indicator_warnings .. config.indicator_separator ..
55-
buf_diagnostics.warnings)
56-
only_hint = false
57-
some_diagnostics = true
58-
end
54+
if buf_diagnostics.warnings and buf_diagnostics.warnings > 0 then
55+
table.insert(status_parts, config.indicator_warnings .. config.indicator_separator ..
56+
buf_diagnostics.warnings)
57+
only_hint = false
58+
some_diagnostics = true
59+
end
5960

60-
if buf_diagnostics.info and buf_diagnostics.info > 0 then
61-
table.insert(status_parts,
62-
config.indicator_info .. config.indicator_separator .. buf_diagnostics.info)
63-
only_hint = false
64-
some_diagnostics = true
65-
end
61+
if buf_diagnostics.info and buf_diagnostics.info > 0 then
62+
table.insert(status_parts,
63+
config.indicator_info .. config.indicator_separator .. buf_diagnostics.info)
64+
only_hint = false
65+
some_diagnostics = true
66+
end
6667

67-
if buf_diagnostics.hints and buf_diagnostics.hints > 0 then
68-
table.insert(status_parts,
69-
config.indicator_hint .. config.indicator_separator .. buf_diagnostics.hints)
70-
some_diagnostics = true
68+
if buf_diagnostics.hints and buf_diagnostics.hints > 0 then
69+
table.insert(status_parts,
70+
config.indicator_hint .. config.indicator_separator .. buf_diagnostics.hints)
71+
some_diagnostics = true
72+
end
7173
end
7274

7375
local msgs = {}
@@ -112,6 +114,7 @@ local function get_lsp_statusline(bufnr)
112114
end
113115

114116
if base_status ~= '' then return symbol .. base_status .. ' ' end
117+
if not config.diagnostics then return symbol end
115118
return symbol .. config.indicator_ok .. ' '
116119
end
117120

0 commit comments

Comments
 (0)