mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
fix: resolve all remaining LuaLS diagnostics
This commit is contained in:
committed by
Lewis Russell
parent
83479b95ab
commit
6aa42e8f92
@ -450,10 +450,10 @@ local function range_from_selection(bufnr, mode)
|
||||
-- A user can start visual selection at the end and move backwards
|
||||
-- Normalize the range to start < end
|
||||
if start_row == end_row and end_col < start_col then
|
||||
end_col, start_col = start_col, end_col
|
||||
end_col, start_col = start_col, end_col --- @type integer, integer
|
||||
elseif end_row < start_row then
|
||||
start_row, end_row = end_row, start_row
|
||||
start_col, end_col = end_col, start_col
|
||||
start_row, end_row = end_row, start_row --- @type integer, integer
|
||||
start_col, end_col = end_col, start_col --- @type integer, integer
|
||||
end
|
||||
if mode == 'V' then
|
||||
start_col = 1
|
||||
@ -553,25 +553,30 @@ function M.format(opts)
|
||||
|
||||
--- @param client vim.lsp.Client
|
||||
--- @param params lsp.DocumentFormattingParams
|
||||
--- @return lsp.DocumentFormattingParams
|
||||
--- @return lsp.DocumentFormattingParams|lsp.DocumentRangeFormattingParams|lsp.DocumentRangesFormattingParams
|
||||
local function set_range(client, params)
|
||||
local to_lsp_range = function(r) ---@return lsp.DocumentRangeFormattingParams|lsp.DocumentRangesFormattingParams
|
||||
--- @param r {start:[integer,integer],end:[integer, integer]}
|
||||
local function to_lsp_range(r)
|
||||
return util.make_given_range_params(r.start, r['end'], bufnr, client.offset_encoding).range
|
||||
end
|
||||
|
||||
local ret = params --[[@as lsp.DocumentFormattingParams|lsp.DocumentRangeFormattingParams|lsp.DocumentRangesFormattingParams]]
|
||||
if passed_multiple_ranges then
|
||||
params.ranges = vim.tbl_map(to_lsp_range, range)
|
||||
ret = params --[[@as lsp.DocumentRangesFormattingParams]]
|
||||
--- @cast range {start:[integer,integer],end:[integer, integer]}
|
||||
ret.ranges = vim.tbl_map(to_lsp_range, range)
|
||||
elseif range then
|
||||
params.range = to_lsp_range(range)
|
||||
ret = params --[[@as lsp.DocumentRangeFormattingParams]]
|
||||
ret.range = to_lsp_range(range)
|
||||
end
|
||||
return params
|
||||
return ret
|
||||
end
|
||||
|
||||
if opts.async then
|
||||
--- @param idx integer
|
||||
--- @param client vim.lsp.Client
|
||||
--- @param idx? integer
|
||||
--- @param client? vim.lsp.Client
|
||||
local function do_format(idx, client)
|
||||
if not client then
|
||||
if not idx or not client then
|
||||
return
|
||||
end
|
||||
local params = set_range(client, util.make_formatting_params(opts.formatting_options))
|
||||
@ -650,16 +655,16 @@ function M.rename(new_name, opts)
|
||||
)[1]
|
||||
end
|
||||
|
||||
--- @param idx integer
|
||||
--- @param idx? integer
|
||||
--- @param client? vim.lsp.Client
|
||||
local function try_use_client(idx, client)
|
||||
if not client then
|
||||
if not idx or not client then
|
||||
return
|
||||
end
|
||||
|
||||
--- @param name string
|
||||
local function rename(name)
|
||||
local params = util.make_position_params(win, client.offset_encoding)
|
||||
local params = util.make_position_params(win, client.offset_encoding) --[[@as lsp.RenameParams]]
|
||||
params.newName = name
|
||||
local handler = client.handlers[ms.textDocument_rename]
|
||||
or lsp.handlers[ms.textDocument_rename]
|
||||
@ -1229,6 +1234,7 @@ function M.code_action(opts)
|
||||
for _, client in ipairs(clients) do
|
||||
---@type lsp.CodeActionParams
|
||||
local params
|
||||
|
||||
if opts.range then
|
||||
assert(type(opts.range) == 'table', 'code_action range must be a table')
|
||||
local start = assert(opts.range.start, 'range must have a `start` property')
|
||||
@ -1241,6 +1247,9 @@ function M.code_action(opts)
|
||||
else
|
||||
params = util.make_range_params(win, client.offset_encoding)
|
||||
end
|
||||
|
||||
--- @cast params lsp.CodeActionParams
|
||||
|
||||
if context.diagnostics then
|
||||
params.context = context
|
||||
else
|
||||
|
Reference in New Issue
Block a user