|
38 | 38 | local function get_lsp_statusline(bufnr)
|
39 | 39 | bufnr = bufnr or 0
|
40 | 40 | 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 |
42 | 42 | local buf_messages = messages()
|
43 | 43 | local only_hint = true
|
44 | 44 | local some_diagnostics = false
|
45 | 45 | 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 |
52 | 53 |
|
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 |
59 | 60 |
|
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 |
66 | 67 |
|
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 |
71 | 73 | end
|
72 | 74 |
|
73 | 75 | local msgs = {}
|
@@ -112,6 +114,7 @@ local function get_lsp_statusline(bufnr)
|
112 | 114 | end
|
113 | 115 |
|
114 | 116 | if base_status ~= '' then return symbol .. base_status .. ' ' end
|
| 117 | + if not config.diagnostics then return symbol end |
115 | 118 | return symbol .. config.indicator_ok .. ' '
|
116 | 119 | end
|
117 | 120 |
|
|
0 commit comments