Skip to content

Commit af54cfc

Browse files
committed
Run lua-format
1 parent 44ee0e7 commit af54cfc

File tree

4 files changed

+44
-80
lines changed

4 files changed

+44
-80
lines changed

lua/lsp-status/extensions/clangd.lua

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,24 @@ local util = require('lsp-status/util')
33
local messages = {}
44

55
---@private
6-
local function init(_messages, _)
7-
messages = _messages
8-
end
6+
local function init(_messages, _) messages = _messages end
97

108
---@private
11-
local function ensure_init(id)
12-
util.ensure_init(messages, id, 'clangd')
13-
end
9+
local function ensure_init(id) util.ensure_init(messages, id, 'clangd') end
1410

1511
local handlers = {
1612
['textDocument/clangd.fileStatus'] = function(_, _, statusMessage, client_id)
1713
ensure_init(client_id)
18-
messages[client_id].status = { uri = statusMessage.uri, content = statusMessage.state }
19-
end,
14+
messages[client_id].status = {uri = statusMessage.uri, content = statusMessage.state}
2015
vim.g.lsp_status_redraw = true
16+
end
2117
}
2218

2319
--- Return the handler {LSP Method: handler} table for `clangd`'s `fileStatus` extension
24-
--@returns Table of extension method handlers, to be added to your `clangd` config
25-
local function setup()
26-
return handlers
27-
end
28-
29-
local M = {
30-
_init = init,
31-
setup = setup
32-
}
20+
-- @returns Table of extension method handlers, to be added to your `clangd` config
21+
local function setup() return handlers end
22+
23+
local M = {_init = init, setup = setup}
3324

3425
M = vim.tbl_extend('error', M, handlers)
3526

lua/lsp-status/extensions/pyls_ms.lua

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,21 @@ local statusline = require('lsp-status/statusline')
33

44
local messages = {}
55
---@private
6-
local function init(_messages, _)
7-
messages = _messages
8-
end
6+
local function init(_messages, _) messages = _messages end
97

108
---@private
11-
local function ensure_init(id)
12-
util.ensure_init(messages, id, 'pyls_ms')
13-
end
9+
local function ensure_init(id) util.ensure_init(messages, id, 'pyls_ms') end
1410

15-
local handlers = {
11+
local handlers = {
1612
['python/setStatusBarMessage'] = function(_, _, message, client_id)
1713
ensure_init(client_id)
18-
messages[client_id].static_message = { content = message[1] }
14+
messages[client_id].static_message = {content = message[1]}
1915
vim.g.lsp_status_redraw = true
2016
end,
2117
['python/beginProgress'] = function(_, _, _, client_id)
2218
ensure_init(client_id)
2319
if not messages[client_id].progress[1] then
24-
messages[client_id].progress[1] = { spinner = 1, title = 'MPLS' }
20+
messages[client_id].progress[1] = {spinner = 1, title = 'MPLS'}
2521
end
2622
end,
2723
['python/reportProgress'] = function(_, _, message, client_id)
@@ -31,21 +27,16 @@ local handlers = {
3127
end,
3228
['python/endProgress'] = function(_, _, _, client_id)
3329
messages[client_id].progress[1] = nil
34-
end,
3530
vim.g.lsp_status_redraw = true
31+
end
3632
}
3733

3834
--- Return the handler {LSP Method: handler} table for `MPLS`'s progress and statusbar message
3935
--- extensions
40-
--@returns Table of extension method handlers, to be added to your `pyls_ms` config
41-
local function setup()
42-
return handlers
43-
end
36+
-- @returns Table of extension method handlers, to be added to your `pyls_ms` config
37+
local function setup() return handlers end
4438

45-
local M = {
46-
_init = init,
47-
setup = setup
48-
}
39+
local M = {_init = init, setup = setup}
4940

5041
M = vim.tbl_extend('error', M, handlers)
5142

lua/lsp-status/statusline.lua

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ local icons
88

99
local diagnostics = require('lsp-status/diagnostics')
1010
local messages = require('lsp-status/messaging').messages
11-
local aliases = {
12-
pyls_ms = 'MPLS',
13-
}
11+
local aliases = {pyls_ms = 'MPLS'}
1412

1513
local function make_statusline_component(diagnostics_key)
1614
return function(bufh)
@@ -27,7 +25,7 @@ local function init(_, _config)
2725
errors = config.indicator_errors,
2826
warnings = config.indicator_warnings,
2927
hints = config.indicator_hint,
30-
info = config.indicator_info,
28+
info = config.indicator_info
3129
}
3230

3331
_errors = make_statusline_component('errors')
@@ -38,35 +36,36 @@ end
3836

3937
local function get_lsp_statusline(bufnr)
4038
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
4540
local buf_diagnostics = diagnostics(bufnr)
4641
local buf_messages = messages()
4742
local only_hint = true
4843
local some_diagnostics = false
4944
local status_parts = {}
5045
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)
5248
only_hint = false
5349
some_diagnostics = true
5450
end
5551

5652
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)
5855
only_hint = false
5956
some_diagnostics = true
6057
end
6158

6259
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)
6462
only_hint = false
6563
some_diagnostics = true
6664
end
6765

6866
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)
7069
some_diagnostics = true
7170
end
7271

@@ -77,26 +76,21 @@ local function get_lsp_statusline(bufnr)
7776
local contents
7877
if msg.progress then
7978
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
8380

84-
if msg.percentage then
85-
contents = contents .. ' (' .. msg.percentage .. ')'
86-
end
81+
if msg.percentage then contents = contents .. ' (' .. msg.percentage .. ')' end
8782

8883
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
9086
end
9187
elseif msg.status then
9288
contents = msg.content
9389
if msg.uri then
9490
local filename = vim.uri_to_fname(msg.uri)
9591
filename = vim.fn.fnamemodify(filename, ':~:.')
9692
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
10094

10195
contents = '(' .. filename .. ') ' .. contents
10296
end
@@ -116,26 +110,16 @@ local function get_lsp_statusline(bufnr)
116110
end
117111
end
118112

119-
if base_status ~= '' then
120-
return symbol .. base_status .. ' '
121-
end
122-
113+
if base_status ~= '' then return symbol .. base_status .. ' ' end
123114
return symbol .. config.indicator_ok .. ' '
124115
end
125116

126117
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}
133119
end
134120

135121
-- 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
139123

140124
local M = {
141125
_init = init,

lua/lsp-status/timer.lua

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
--- Timer instance
22
local timer = nil
3-
--- This flag is used to redraw one more time after the las LSP update.
3+
--- This flag is used to redraw one more time after the last LSP update.
44
-- NOTE: This is achieved by setting the redraw_flag to true if
5-
-- vim.b.lsp_status_redraw is true and there has been an update. Next time if
6-
-- vim.b.lsp_status_redraw is false (no update) it will still redraw the
5+
-- vim.g.lsp_status_redraw is true and there has been an update. Next time if
6+
-- vim.g.lsp_status_redraw is false (no update) it will still redraw the
77
-- statusline and this flag will be set to false.
88
local redraw_flag = false
99

@@ -15,13 +15,13 @@ local function init(_, _config) config = vim.tbl_extend('force', config, _config
1515
-- so it should call in the vim.schedule_wrap()
1616
local function timer_callback()
1717
-- Check if need to redraw
18-
local update_flag = vim.b.lsp_status_redraw
18+
local update_flag = vim.g.lsp_status_redraw
1919
if update_flag or redraw_flag then
20-
vim.b.lsp_status_redraw = false
20+
vim.g.lsp_status_redraw = false
2121
-- Schedule the command when it's safe to call it
2222
local new_state = require('lsp-status/statusline').get_lsp_statusline()
23-
if new_state ~= vim.b.lsp_status_statusline then
24-
vim.b.lsp_status_statusline = new_state
23+
if new_state ~= vim.g.lsp_status_statusline then
24+
vim.g.lsp_status_statusline = new_state
2525
vim.api.nvim_command('redrawstatus!')
2626
-- If this was an lsp update (update_flag is true) redraw also next time
2727
-- by setting redraw_flag
@@ -40,9 +40,7 @@ end
4040
-- stopped
4141
local function register_timer()
4242
-- Guard the for an already defined timer
43-
if timer ~= nil then
44-
return
45-
end
43+
if timer ~= nil then return end
4644
timer = vim.loop.new_timer()
4745
-- Execute the timer every update_interval milliseconds
4846
timer:start(0, config.update_interval, vim.schedule_wrap(timer_callback))

0 commit comments

Comments
 (0)