mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
doc(lsp): various small fixes (#15113)
- remove incorrect usage of docstrings - fix make_formatting_params return type documentation to 'DocumentFormattingParams' - make progress_handler private - fix links
This commit is contained in:
parent
682247b52e
commit
d8f5f4d090
@ -1630,23 +1630,29 @@ save({lenses}, {bufnr}, {client_id}) *vim.lsp.codelens.save()*
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
Lua module: vim.lsp.handlers *lsp-handlers*
|
Lua module: vim.lsp.handlers *lsp-handlers*
|
||||||
|
|
||||||
*vim.lsp.handlers.progress_handler()*
|
*vim.lsp.handlers.hover()*
|
||||||
progress_handler({_}, {_}, {params}, {client_id})
|
hover({_}, {method}, {result}, {_}, {_}, {config})
|
||||||
See also: ~
|
|lsp-handler| for the method "textDocument/hover" >
|
||||||
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_executeCommand
|
|
||||||
|
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
|
||||||
|
vim.lsp.handlers.hover, {
|
||||||
|
-- Use a sharp border with `FloatBorder` highlights
|
||||||
|
border = "single"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
<
|
||||||
|
|
||||||
*vim.lsp.handlers.signature_help()*
|
|
||||||
signature_help({_}, {method}, {result}, {client_id}, {bufnr}, {config})
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
{config} table Configuration table.
|
{config} table Configuration table.
|
||||||
• border: (default=nil)
|
• border: (default=nil)
|
||||||
• Add borders to the floating window
|
• Add borders to the floating window
|
||||||
• See |vim.api.nvim_open_win()|
|
• See |vim.api.nvim_open_win()|
|
||||||
|
|
||||||
See also: ~
|
*vim.lsp.handlers.signature_help()*
|
||||||
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_declaration@seehttps://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition@seehttps://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_typeDefinition@seehttps://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_implementation|lsp-handler| for the method "textDocument/signatureHelp"
|
signature_help({_}, {method}, {result}, {client_id}, {bufnr}, {config})
|
||||||
The active parameter is highlighted with
|
|lsp-handler| for the method "textDocument/signatureHelp". The
|
||||||
|hl-LspSignatureActiveParameter|>
|
active parameter is highlighted with
|
||||||
|
|hl-LspSignatureActiveParameter|. >
|
||||||
|
|
||||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
|
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
|
||||||
vim.lsp.handlers.signature_help, {
|
vim.lsp.handlers.signature_help, {
|
||||||
@ -1656,6 +1662,12 @@ signature_help({_}, {method}, {result}, {client_id}, {bufnr}, {config})
|
|||||||
)
|
)
|
||||||
<
|
<
|
||||||
|
|
||||||
|
Parameters: ~
|
||||||
|
{config} table Configuration table.
|
||||||
|
• border: (default=nil)
|
||||||
|
• Add borders to the floating window
|
||||||
|
• See |vim.api.nvim_open_win()|
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
Lua module: vim.lsp.util *lsp-util*
|
Lua module: vim.lsp.util *lsp-util*
|
||||||
@ -1915,14 +1927,14 @@ make_floating_popup_options({width}, {height}, {opts})
|
|||||||
|
|
||||||
*vim.lsp.util.make_formatting_params()*
|
*vim.lsp.util.make_formatting_params()*
|
||||||
make_formatting_params({options})
|
make_formatting_params({options})
|
||||||
Creates a `FormattingOptions` object for the current buffer
|
Creates a `DocumentFormattingParams` object for the current
|
||||||
and cursor position.
|
buffer and cursor position.
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
{options} Table with valid `FormattingOptions` entries
|
{options} Table with valid `FormattingOptions` entries
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
`FormattingOptions object
|
`DocumentFormattingParams` object
|
||||||
|
|
||||||
See also: ~
|
See also: ~
|
||||||
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_formatting
|
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_formatting
|
||||||
|
@ -17,13 +17,12 @@ local function err_message(...)
|
|||||||
api.nvim_command("redraw")
|
api.nvim_command("redraw")
|
||||||
end
|
end
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_executeCommand
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_executeCommand
|
||||||
M['workspace/executeCommand'] = function()
|
M['workspace/executeCommand'] = function()
|
||||||
-- Error handling is done implicitly by wrapping all handlers; see end of this file
|
-- Error handling is done implicitly by wrapping all handlers; see end of this file
|
||||||
end
|
end
|
||||||
|
|
||||||
-- @msg of type ProgressParams
|
--@private
|
||||||
-- Basically a token of type number/string
|
|
||||||
local function progress_handler(_, _, params, client_id)
|
local function progress_handler(_, _, params, client_id)
|
||||||
local client = vim.lsp.get_client_by_id(client_id)
|
local client = vim.lsp.get_client_by_id(client_id)
|
||||||
local client_name = client and client.name or string.format("id=%d", client_id)
|
local client_name = client and client.name or string.format("id=%d", client_id)
|
||||||
@ -59,10 +58,10 @@ local function progress_handler(_, _, params, client_id)
|
|||||||
vim.api.nvim_command("doautocmd <nomodeline> User LspProgressUpdate")
|
vim.api.nvim_command("doautocmd <nomodeline> User LspProgressUpdate")
|
||||||
end
|
end
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#progress
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#progress
|
||||||
M['$/progress'] = progress_handler
|
M['$/progress'] = progress_handler
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window_workDoneProgress_create
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window_workDoneProgress_create
|
||||||
M['window/workDoneProgress/create'] = function(_, _, params, client_id)
|
M['window/workDoneProgress/create'] = function(_, _, params, client_id)
|
||||||
local client = vim.lsp.get_client_by_id(client_id)
|
local client = vim.lsp.get_client_by_id(client_id)
|
||||||
local token = params.token -- string or number
|
local token = params.token -- string or number
|
||||||
@ -74,7 +73,7 @@ M['window/workDoneProgress/create'] = function(_, _, params, client_id)
|
|||||||
return vim.NIL
|
return vim.NIL
|
||||||
end
|
end
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window_showMessageRequest
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window_showMessageRequest
|
||||||
M['window/showMessageRequest'] = function(_, _, params)
|
M['window/showMessageRequest'] = function(_, _, params)
|
||||||
|
|
||||||
local actions = params.actions
|
local actions = params.actions
|
||||||
@ -95,7 +94,7 @@ M['window/showMessageRequest'] = function(_, _, params)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#client_registerCapability
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#client_registerCapability
|
||||||
M['client/registerCapability'] = function(_, _, _, client_id)
|
M['client/registerCapability'] = function(_, _, _, client_id)
|
||||||
local warning_tpl = "The language server %s triggers a registerCapability "..
|
local warning_tpl = "The language server %s triggers a registerCapability "..
|
||||||
"handler despite dynamicRegistration set to false. "..
|
"handler despite dynamicRegistration set to false. "..
|
||||||
@ -107,7 +106,7 @@ M['client/registerCapability'] = function(_, _, _, client_id)
|
|||||||
return vim.NIL
|
return vim.NIL
|
||||||
end
|
end
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_codeAction
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_codeAction
|
||||||
M['textDocument/codeAction'] = function(_, _, actions)
|
M['textDocument/codeAction'] = function(_, _, actions)
|
||||||
if actions == nil or vim.tbl_isempty(actions) then
|
if actions == nil or vim.tbl_isempty(actions) then
|
||||||
print("No code actions available")
|
print("No code actions available")
|
||||||
@ -141,7 +140,7 @@ M['textDocument/codeAction'] = function(_, _, actions)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_applyEdit
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_applyEdit
|
||||||
M['workspace/applyEdit'] = function(_, _, workspace_edit)
|
M['workspace/applyEdit'] = function(_, _, workspace_edit)
|
||||||
if not workspace_edit then return end
|
if not workspace_edit then return end
|
||||||
-- TODO(ashkan) Do something more with label?
|
-- TODO(ashkan) Do something more with label?
|
||||||
@ -155,7 +154,7 @@ M['workspace/applyEdit'] = function(_, _, workspace_edit)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_configuration
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_configuration
|
||||||
M['workspace/configuration'] = function(_, _, params, client_id)
|
M['workspace/configuration'] = function(_, _, params, client_id)
|
||||||
local client = vim.lsp.get_client_by_id(client_id)
|
local client = vim.lsp.get_client_by_id(client_id)
|
||||||
if not client then
|
if not client then
|
||||||
@ -207,34 +206,34 @@ local function response_to_qflist(map_result, entity)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references
|
||||||
M['textDocument/references'] = response_to_qflist(util.locations_to_items, 'references')
|
M['textDocument/references'] = response_to_qflist(util.locations_to_items, 'references')
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentSymbol
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentSymbol
|
||||||
M['textDocument/documentSymbol'] = response_to_qflist(util.symbols_to_items, 'document symbols')
|
M['textDocument/documentSymbol'] = response_to_qflist(util.symbols_to_items, 'document symbols')
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_symbol
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_symbol
|
||||||
M['workspace/symbol'] = response_to_qflist(util.symbols_to_items, 'symbols')
|
M['workspace/symbol'] = response_to_qflist(util.symbols_to_items, 'symbols')
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rename
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rename
|
||||||
M['textDocument/rename'] = function(_, _, result)
|
M['textDocument/rename'] = function(_, _, result)
|
||||||
if not result then return end
|
if not result then return end
|
||||||
util.apply_workspace_edit(result)
|
util.apply_workspace_edit(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rangeFormatting
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rangeFormatting
|
||||||
M['textDocument/rangeFormatting'] = function(_, _, result, _, bufnr)
|
M['textDocument/rangeFormatting'] = function(_, _, result, _, bufnr)
|
||||||
if not result then return end
|
if not result then return end
|
||||||
util.apply_text_edits(result, bufnr)
|
util.apply_text_edits(result, bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_formatting
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_formatting
|
||||||
M['textDocument/formatting'] = function(_, _, result, _, bufnr)
|
M['textDocument/formatting'] = function(_, _, result, _, bufnr)
|
||||||
if not result then return end
|
if not result then return end
|
||||||
util.apply_text_edits(result, bufnr)
|
util.apply_text_edits(result, bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion
|
||||||
M['textDocument/completion'] = function(_, _, result)
|
M['textDocument/completion'] = function(_, _, result)
|
||||||
if vim.tbl_isempty(result or {}) then return end
|
if vim.tbl_isempty(result or {}) then return end
|
||||||
local row, col = unpack(api.nvim_win_get_cursor(0))
|
local row, col = unpack(api.nvim_win_get_cursor(0))
|
||||||
@ -276,7 +275,7 @@ function M.hover(_, method, result, _, _, config)
|
|||||||
return util.open_floating_preview(markdown_lines, "markdown", config)
|
return util.open_floating_preview(markdown_lines, "markdown", config)
|
||||||
end
|
end
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_hover
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_hover
|
||||||
M['textDocument/hover'] = M.hover
|
M['textDocument/hover'] = M.hover
|
||||||
|
|
||||||
--@private
|
--@private
|
||||||
@ -306,17 +305,17 @@ local function location_handler(_, method, result)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_declaration
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_declaration
|
||||||
M['textDocument/declaration'] = location_handler
|
M['textDocument/declaration'] = location_handler
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition
|
||||||
M['textDocument/definition'] = location_handler
|
M['textDocument/definition'] = location_handler
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_typeDefinition
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_typeDefinition
|
||||||
M['textDocument/typeDefinition'] = location_handler
|
M['textDocument/typeDefinition'] = location_handler
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_implementation
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_implementation
|
||||||
M['textDocument/implementation'] = location_handler
|
M['textDocument/implementation'] = location_handler
|
||||||
|
|
||||||
--- |lsp-handler| for the method "textDocument/signatureHelp"
|
--- |lsp-handler| for the method "textDocument/signatureHelp".
|
||||||
--- The active parameter is highlighted with |hl-LspSignatureActiveParameter|
|
--- The active parameter is highlighted with |hl-LspSignatureActiveParameter|.
|
||||||
--- <pre>
|
--- <pre>
|
||||||
--- vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
|
--- vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
|
||||||
--- vim.lsp.handlers.signature_help, {
|
--- vim.lsp.handlers.signature_help, {
|
||||||
@ -358,10 +357,10 @@ function M.signature_help(_, method, result, client_id, bufnr, config)
|
|||||||
return fbuf, fwin
|
return fbuf, fwin
|
||||||
end
|
end
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_signatureHelp
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_signatureHelp
|
||||||
M['textDocument/signatureHelp'] = M.signature_help
|
M['textDocument/signatureHelp'] = M.signature_help
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentHighlight
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentHighlight
|
||||||
M['textDocument/documentHighlight'] = function(_, _, result, _, bufnr, _)
|
M['textDocument/documentHighlight'] = function(_, _, result, _, bufnr, _)
|
||||||
if not result then return end
|
if not result then return end
|
||||||
util.buf_highlight_references(bufnr, result)
|
util.buf_highlight_references(bufnr, result)
|
||||||
@ -394,13 +393,13 @@ local make_call_hierarchy_handler = function(direction)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#callHierarchy/incomingCalls
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#callHierarchy_incomingCalls
|
||||||
M['callHierarchy/incomingCalls'] = make_call_hierarchy_handler('from')
|
M['callHierarchy/incomingCalls'] = make_call_hierarchy_handler('from')
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#callHierarchy/outgoingCalls
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#callHierarchy_outgoingCalls
|
||||||
M['callHierarchy/outgoingCalls'] = make_call_hierarchy_handler('to')
|
M['callHierarchy/outgoingCalls'] = make_call_hierarchy_handler('to')
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window/logMessage
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window_logMessage
|
||||||
M['window/logMessage'] = function(_, _, result, client_id)
|
M['window/logMessage'] = function(_, _, result, client_id)
|
||||||
local message_type = result.type
|
local message_type = result.type
|
||||||
local message = result.message
|
local message = result.message
|
||||||
@ -421,7 +420,7 @@ M['window/logMessage'] = function(_, _, result, client_id)
|
|||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window/showMessage
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window_showMessage
|
||||||
M['window/showMessage'] = function(_, _, result, client_id)
|
M['window/showMessage'] = function(_, _, result, client_id)
|
||||||
local message_type = result.type
|
local message_type = result.type
|
||||||
local message = result.message
|
local message = result.message
|
||||||
|
@ -1868,10 +1868,10 @@ function M.get_effective_tabstop(bufnr)
|
|||||||
return (sts > 0 and sts) or (sts < 0 and bo.shiftwidth) or bo.tabstop
|
return (sts > 0 and sts) or (sts < 0 and bo.shiftwidth) or bo.tabstop
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Creates a `FormattingOptions` object for the current buffer and cursor position.
|
--- Creates a `DocumentFormattingParams` object for the current buffer and cursor position.
|
||||||
---
|
---
|
||||||
--@param options Table with valid `FormattingOptions` entries
|
--@param options Table with valid `FormattingOptions` entries
|
||||||
--@returns `FormattingOptions object
|
--@returns `DocumentFormattingParams` object
|
||||||
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_formatting
|
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_formatting
|
||||||
function M.make_formatting_params(options)
|
function M.make_formatting_params(options)
|
||||||
validate { options = {options, 't', true} }
|
validate { options = {options, 't', true} }
|
||||||
|
Loading…
Reference in New Issue
Block a user