Skip to content

Commit 5d4ea53

Browse files
committed
begin using emmylua_ls
1 parent 2d11b98 commit 5d4ea53

File tree

7 files changed

+25
-19
lines changed

7 files changed

+25
-19
lines changed

.luarc.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
},
66
"workspace": {
77
"library": [
8-
"runtime/lua",
98
"${3rd}/busted/library",
10-
"${3rd}/luv/library"
9+
"luv"
1110
],
1211
"ignoreDir": [
1312
"test",

Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,10 @@ appimage-%:
182182
bash scripts/genappimage.sh $*
183183

184184
.PHONY: test clean distclean nvim libnvim cmake deps install appimage checkprefix benchmark $(FORMAT) $(LINT) $(TEST)
185+
186+
.PHONY: emmylua-check
187+
emmylua-check: luv
188+
emmylua_check --config=$(PWD)/.luarc.json runtime/lua
189+
190+
luv:
191+
git clone https://github.com/LuaCATS/luv

runtime/lua/vim/lsp/buf.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ local function get_locations(method, opts)
177177
---@type vim.quickfix.entry[]
178178
local all_items = {}
179179

180-
---@param result nil|lsp.Location|lsp.Location[]
180+
---@param result lsp.Location|lsp.Location[]?
181181
---@param client vim.lsp.Client
182182
local function on_response(_, result, client)
183183
local locations = {}
@@ -315,7 +315,7 @@ local function process_signature_help_results(results)
315315
)
316316
api.nvim_command('redraw')
317317
else
318-
local result = r.result --- @type lsp.SignatureHelp
318+
local result = r.result
319319
if result and result.signatures and result.signatures[1] then
320320
for _, sig in ipairs(result.signatures) do
321321
sig.activeParameter = sig.activeParameter or result.activeParameter

runtime/lua/vim/lsp/client.lua

+9-9
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ local validate = vim.validate
175175
---
176176
--- Response from the server sent on `initialize` describing the server's
177177
--- capabilities.
178-
--- @field server_capabilities lsp.ServerCapabilities?
178+
--- @field server_capabilities lsp.ServerCapabilities
179179
---
180180
--- Response from the server sent on `initialize` describing information about
181181
--- the server.
@@ -229,13 +229,13 @@ local validate = vim.validate
229229
--- @field private _before_init_cb? vim.lsp.client.before_init_cb
230230
--- @field private _on_attach_cbs vim.lsp.client.on_attach_cb[]
231231
--- @field private _on_init_cbs vim.lsp.client.on_init_cb[]
232-
--- @field private _on_exit_cbs vim.lsp.client.on_exit_cb[]
232+
--- @field package _on_exit_cbs vim.lsp.client.on_exit_cb[]
233233
--- @field private _on_error_cb? fun(code: integer, err: string)
234234
local Client = {}
235235
Client.__index = Client
236236

237237
--- @param obj table<string,any>
238-
--- @param cls table<string,function>
238+
--- @param cls table<string,function?>
239239
--- @param name string
240240
local function method_wrapper(obj, cls, name)
241241
local meth = assert(cls[name])
@@ -339,7 +339,7 @@ local function validate_config(config)
339339
)
340340
end
341341

342-
--- @param trace string
342+
--- @param trace string?
343343
--- @return 'off'|'messages'|'verbose'
344344
local function get_trace(trace)
345345
local valid_traces = {
@@ -445,16 +445,16 @@ function Client.create(config)
445445
--- @type vim.lsp.rpc.Dispatchers
446446
local dispatchers = {
447447
notification = function(...)
448-
return self:_notification(...)
448+
self:_notification(...)
449449
end,
450450
server_request = function(...)
451451
return self:_server_request(...)
452452
end,
453453
on_error = function(...)
454-
return self:_on_error(...)
454+
self:_on_error(...)
455455
end,
456456
on_exit = function(...)
457-
return self:_on_exit(...)
457+
self:_on_exit(...)
458458
end,
459459
}
460460

@@ -602,7 +602,7 @@ end
602602

603603
--- @private
604604
--- @param id integer
605-
--- @param req_type 'pending'|'complete'|'cancel'|
605+
--- @param req_type 'pending'|'complete'|'cancel'
606606
--- @param bufnr? integer (only required for req_type='pending')
607607
--- @param method? string (only required for req_type='pending')
608608
function Client:_process_request(id, req_type, bufnr, method)
@@ -838,7 +838,7 @@ end
838838
--- @param registrations lsp.Registration[]
839839
function Client:_register_dynamic(registrations)
840840
-- remove duplicates
841-
self:_unregister_dynamic(registrations)
841+
self:_unregister_dynamic(registrations --[[@as lsp.Unregistration[] ]])
842842
for _, reg in ipairs(registrations) do
843843
local method = reg.method
844844
if not self.registrations[method] then

runtime/lua/vim/lsp/completion.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ local lsp = vim.lsp
3838
local protocol = lsp.protocol
3939
local ms = protocol.Methods
4040

41-
local rtt_ms = 50
41+
local rtt_ms = 50.0
4242
local ns_to_ms = 0.000001
4343

4444
--- @alias vim.lsp.CompletionResult lsp.CompletionList | lsp.CompletionItem[]
@@ -110,7 +110,7 @@ end
110110
local function exp_avg(window, warmup)
111111
local count = 0
112112
local sum = 0
113-
local value = 0
113+
local value = 0.0
114114

115115
return function(sample)
116116
if count < warmup then
@@ -384,7 +384,7 @@ local function adjust_start_col(lnum, line, items, encoding)
384384
end
385385
end
386386

387-
--- @private
387+
--- @package
388388
--- @param line string line content
389389
--- @param lnum integer 0-indexed line number
390390
--- @param cursor_col integer

runtime/lua/vim/lsp/semantic_tokens.lua

+3-2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ local function modifiers_from_number(x, modifiers_table)
8888
return modifiers
8989
end
9090

91+
--- @async
9192
--- Converts a raw token list to a list of highlight ranges used by the on_win callback
9293
---
9394
---@param data integer[]
@@ -159,7 +160,7 @@ end
159160

160161
--- Construct a new STHighlighter for the buffer
161162
---
162-
---@private
163+
---@package
163164
---@param bufnr integer
164165
---@return STHighlighter
165166
function STHighlighter.new(bufnr)
@@ -325,7 +326,7 @@ end
325326
---
326327
--- Finally, a redraw command is issued to force nvim to redraw the screen to
327328
--- pick up changed highlight tokens.
328-
---
329+
---@async
329330
---@param response lsp.SemanticTokens|lsp.SemanticTokensDelta
330331
---@private
331332
function STHighlighter:process_response(response, client, version)

runtime/lua/vim/lsp/util.lua

-1
Original file line numberDiff line numberDiff line change
@@ -2200,7 +2200,6 @@ end
22002200
---@field only_visible? boolean Whether to only refresh for the visible regions of the buffer (default: false)
22012201
---@field client_id? integer Client ID to refresh (default: all clients)
22022202

2203-
---@private
22042203
--- Request updated LSP information for a buffer.
22052204
---
22062205
---@param method string LSP method to call

0 commit comments

Comments
 (0)