@@ -8,9 +8,7 @@ local icons
8
8
9
9
local diagnostics = require (' lsp-status/diagnostics' )
10
10
local messages = require (' lsp-status/messaging' ).messages
11
- local aliases = {
12
- pyls_ms = ' MPLS' ,
13
- }
11
+ local aliases = {pyls_ms = ' MPLS' }
14
12
15
13
local function make_statusline_component (diagnostics_key )
16
14
return function (bufh )
@@ -27,7 +25,7 @@ local function init(_, _config)
27
25
errors = config .indicator_errors ,
28
26
warnings = config .indicator_warnings ,
29
27
hints = config .indicator_hint ,
30
- info = config .indicator_info ,
28
+ info = config .indicator_info
31
29
}
32
30
33
31
_errors = make_statusline_component (' errors' )
38
36
39
37
local function get_lsp_statusline (bufnr )
40
38
bufnr = bufnr or 0
41
- if # vim .lsp .buf_get_clients (bufnr ) == 0 then
42
- return ' '
43
- end
44
-
39
+ if # vim .lsp .buf_get_clients (bufnr ) == 0 then return ' ' end
45
40
local buf_diagnostics = diagnostics (bufnr )
46
41
local buf_messages = messages ()
47
42
local only_hint = true
48
43
local some_diagnostics = false
49
44
local status_parts = {}
50
45
if buf_diagnostics .errors and buf_diagnostics .errors > 0 then
51
- table.insert (status_parts , config .indicator_errors .. config .indicator_separator .. buf_diagnostics .errors )
46
+ table.insert (status_parts ,
47
+ config .indicator_errors .. config .indicator_separator .. buf_diagnostics .errors )
52
48
only_hint = false
53
49
some_diagnostics = true
54
50
end
55
51
56
52
if buf_diagnostics .warnings and buf_diagnostics .warnings > 0 then
57
- table.insert (status_parts , config .indicator_warnings .. config .indicator_separator .. buf_diagnostics .warnings )
53
+ table.insert (status_parts , config .indicator_warnings .. config .indicator_separator ..
54
+ buf_diagnostics .warnings )
58
55
only_hint = false
59
56
some_diagnostics = true
60
57
end
61
58
62
59
if buf_diagnostics .info and buf_diagnostics .info > 0 then
63
- table.insert (status_parts , config .indicator_info .. config .indicator_separator .. buf_diagnostics .info )
60
+ table.insert (status_parts ,
61
+ config .indicator_info .. config .indicator_separator .. buf_diagnostics .info )
64
62
only_hint = false
65
63
some_diagnostics = true
66
64
end
67
65
68
66
if buf_diagnostics .hints and buf_diagnostics .hints > 0 then
69
- table.insert (status_parts , config .indicator_hint .. config .indicator_separator .. buf_diagnostics .hints )
67
+ table.insert (status_parts ,
68
+ config .indicator_hint .. config .indicator_separator .. buf_diagnostics .hints )
70
69
some_diagnostics = true
71
70
end
72
71
@@ -77,26 +76,21 @@ local function get_lsp_statusline(bufnr)
77
76
local contents
78
77
if msg .progress then
79
78
contents = msg .title
80
- if msg .message then
81
- contents = contents .. ' ' .. msg .message
82
- end
79
+ if msg .message then contents = contents .. ' ' .. msg .message end
83
80
84
- if msg .percentage then
85
- contents = contents .. ' (' .. msg .percentage .. ' )'
86
- end
81
+ if msg .percentage then contents = contents .. ' (' .. msg .percentage .. ' )' end
87
82
88
83
if msg .spinner then
89
- contents = config .spinner_frames [(msg .spinner % # config .spinner_frames ) + 1 ] .. ' ' .. contents
84
+ contents = config .spinner_frames [(msg .spinner % # config .spinner_frames ) + 1 ] .. ' ' ..
85
+ contents
90
86
end
91
87
elseif msg .status then
92
88
contents = msg .content
93
89
if msg .uri then
94
90
local filename = vim .uri_to_fname (msg .uri )
95
91
filename = vim .fn .fnamemodify (filename , ' :~:.' )
96
92
local space = math.min (60 , math.floor (0.6 * vim .fn .winwidth (0 )))
97
- if # filename > space then
98
- filename = vim .fn .pathshorten (filename )
99
- end
93
+ if # filename > space then filename = vim .fn .pathshorten (filename ) end
100
94
101
95
contents = ' (' .. filename .. ' ) ' .. contents
102
96
end
@@ -116,26 +110,16 @@ local function get_lsp_statusline(bufnr)
116
110
end
117
111
end
118
112
119
- if base_status ~= ' ' then
120
- return symbol .. base_status .. ' '
121
- end
122
-
113
+ if base_status ~= ' ' then return symbol .. base_status .. ' ' end
123
114
return symbol .. config .indicator_ok .. ' '
124
115
end
125
116
126
117
local function get_component_functions ()
127
- return {
128
- errors = _errors ,
129
- warnings = _warnings ,
130
- hints = _hints ,
131
- info = _info ,
132
- }
118
+ return {errors = _errors , warnings = _warnings , hints = _hints , info = _info }
133
119
end
134
120
135
121
-- Status line component for nvim-lsp
136
- local function lsp_status ()
137
- return vim .b .lsp_status_statusline or ' '
138
- end
122
+ local function lsp_status () return vim .g .lsp_status_statusline or ' ' end
139
123
140
124
local M = {
141
125
_init = init ,
0 commit comments