aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/_meta.lua4
-rw-r--r--runtime/lua/vim/diagnostic.lua43
-rw-r--r--runtime/lua/vim/lsp.lua9
-rw-r--r--runtime/lua/vim/lsp/buf.lua79
-rw-r--r--runtime/lua/vim/lsp/diagnostic.lua52
-rw-r--r--runtime/lua/vim/lsp/protocol.lua144
-rw-r--r--runtime/lua/vim/lsp/util.lua2
7 files changed, 124 insertions, 209 deletions
diff --git a/runtime/lua/vim/_meta.lua b/runtime/lua/vim/_meta.lua
index 280222e28a..522e26caa7 100644
--- a/runtime/lua/vim/_meta.lua
+++ b/runtime/lua/vim/_meta.lua
@@ -16,10 +16,6 @@ for _, v in pairs(a.nvim_get_all_options_info()) do
if v.shortname ~= "" then options_info[v.shortname] = v end
end
-local is_global_option = function(info) return info.scope == "global" end
-local is_buffer_option = function(info) return info.scope == "buf" end
-local is_window_option = function(info) return info.scope == "win" end
-
local get_scoped_options = function(scope)
local result = {}
for name, option_info in pairs(options_info) do
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index 708ee1727a..59cb9f8c5b 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -520,8 +520,8 @@ local function diagnostic_move_pos(opts, pos)
local float_opts = type(float) == "table" and float or {}
vim.schedule(function()
M.open_float(
- vim.api.nvim_win_get_buf(win_id),
vim.tbl_extend("keep", float_opts, {
+ bufnr = vim.api.nvim_win_get_buf(win_id),
scope = "cursor",
focus = false,
})
@@ -658,7 +658,10 @@ function M.set(namespace, bufnr, diagnostics, opts)
vim.api.nvim_buf_call(bufnr, function()
vim.api.nvim_command(
- string.format("doautocmd <nomodeline> DiagnosticChanged %s", vim.api.nvim_buf_get_name(bufnr))
+ string.format(
+ "doautocmd <nomodeline> DiagnosticChanged %s",
+ vim.fn.fnameescape(vim.api.nvim_buf_get_name(bufnr))
+ )
)
end)
end
@@ -1132,12 +1135,15 @@ end
--- Show diagnostics in a floating window.
---
----@param bufnr number|nil Buffer number. Defaults to the current buffer.
---@param opts table|nil Configuration table with the same keys as
--- |vim.lsp.util.open_floating_preview()| in addition to the following:
+--- - bufnr: (number) Buffer number to show diagnostics from.
+--- Defaults to the current buffer.
--- - namespace: (number) Limit diagnostics to the given namespace
--- - scope: (string, default "line") Show diagnostics from the whole buffer ("buffer"),
--- the current cursor line ("line"), or the current cursor position ("cursor").
+--- Shorthand versions are also accepted ("c" for "cursor", "l" for "line", "b"
+--- for "buffer").
--- - pos: (number or table) If {scope} is "line" or "cursor", use this position rather
--- than the cursor position. If a number, interpreted as a line number;
--- otherwise, a (row, col) tuple.
@@ -1166,15 +1172,21 @@ end
--- highlight.
--- Overrides the setting from |vim.diagnostic.config()|.
---@return tuple ({float_bufnr}, {win_id})
-function M.open_float(bufnr, opts)
- vim.validate {
- bufnr = { bufnr, 'n', true },
- opts = { opts, 't', true },
- }
+function M.open_float(opts, ...)
+ -- Support old (bufnr, opts) signature
+ local bufnr
+ if opts == nil or type(opts) == "number" then
+ bufnr = opts
+ opts = ...
+ else
+ vim.validate {
+ opts = { opts, 't', true },
+ }
+ end
opts = opts or {}
- bufnr = get_bufnr(bufnr)
- local scope = opts.scope or "line"
+ bufnr = get_bufnr(bufnr or opts.bufnr)
+ local scope = ({l = "line", c = "cursor", b = "buffer"})[opts.scope] or opts.scope or "line"
local lnum, col
if scope == "line" or scope == "cursor" then
if not opts.pos then
@@ -1332,9 +1344,14 @@ function M.reset(namespace, bufnr)
end
end
- vim.api.nvim_command(
- string.format("doautocmd <nomodeline> DiagnosticChanged %s", vim.api.nvim_buf_get_name(bufnr))
- )
+ vim.api.nvim_buf_call(bufnr, function()
+ vim.api.nvim_command(
+ string.format(
+ "doautocmd <nomodeline> DiagnosticChanged %s",
+ vim.fn.fnameescape(vim.api.nvim_buf_get_name(bufnr))
+ )
+ )
+ end)
end
--- Add all diagnostics to the quickfix list.
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 61a700bd15..95bc4635b0 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -489,7 +489,8 @@ local function text_document_did_open_handler(bufnr, client)
-- Protect against a race where the buffer disappears
-- between `did_open_handler` and the scheduled function firing.
if vim.api.nvim_buf_is_valid(bufnr) then
- vim.lsp.diagnostic.redraw(bufnr, client.id)
+ local namespace = vim.lsp.diagnostic.get_namespace(client.id)
+ vim.diagnostic.show(namespace, bufnr)
end
end)
end
@@ -559,6 +560,12 @@ end
---
--- - {handlers} (table): The handlers used by the client as described in |lsp-handler|.
---
+--- - {requests} (table): The current pending requests in flight
+--- to the server. Entries are key-value pairs with the key
+--- being the request ID while the value is a table with `type`,
+--- `bufnr`, and `method` key-value pairs. `type` is either "pending"
+--- for an active request, or "cancel" for a cancel request.
+---
--- - {config} (table): copy of the table that was passed by the user
--- to |vim.lsp.start_client()|.
---
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
index f02ebfb9dc..8e3ed9b002 100644
--- a/runtime/lua/vim/lsp/buf.lua
+++ b/runtime/lua/vim/lsp/buf.lua
@@ -116,31 +116,30 @@ end
--- asks the user to select one.
--
---@returns The client that the user selected or nil
-local function select_client(method)
- local clients = vim.tbl_values(vim.lsp.buf_get_clients());
- clients = vim.tbl_filter(function (client)
+local function select_client(method, on_choice)
+ validate {
+ on_choice = { on_choice, 'function', false },
+ }
+ local clients = vim.tbl_values(vim.lsp.buf_get_clients())
+ clients = vim.tbl_filter(function(client)
return client.supports_method(method)
end, clients)
-- better UX when choices are always in the same order (between restarts)
- table.sort(clients, function (a, b) return a.name < b.name end)
+ table.sort(clients, function(a, b)
+ return a.name < b.name
+ end)
if #clients > 1 then
- local choices = {}
- for k,v in pairs(clients) do
- table.insert(choices, string.format("%d %s", k, v.name))
- end
- local user_choice = vim.fn.confirm(
- "Select a language server:",
- table.concat(choices, "\n"),
- 0,
- "Question"
- )
- if user_choice == 0 then return nil end
- return clients[user_choice]
+ vim.ui.select(clients, {
+ prompt = 'Select a language server:',
+ format_item = function(client)
+ return client.name
+ end,
+ }, on_choice)
elseif #clients < 1 then
- return nil
+ on_choice(nil)
else
- return clients[1]
+ on_choice(clients[1])
end
end
@@ -152,11 +151,15 @@ end
--
---@see https://microsoft.github.io/language-server-protocol/specification#textDocument_formatting
function M.formatting(options)
- local client = select_client("textDocument/formatting")
- if client == nil then return end
-
local params = util.make_formatting_params(options)
- return client.request("textDocument/formatting", params, nil, vim.api.nvim_get_current_buf())
+ local bufnr = vim.api.nvim_get_current_buf()
+ select_client('textDocument/formatting', function(client)
+ if client == nil then
+ return
+ end
+
+ return client.request('textDocument/formatting', params, nil, bufnr)
+ end)
end
--- Performs |vim.lsp.buf.formatting()| synchronously.
@@ -172,17 +175,20 @@ end
---@param timeout_ms (number) Request timeout
---@see |vim.lsp.buf.formatting_seq_sync|
function M.formatting_sync(options, timeout_ms)
- local client = select_client("textDocument/formatting")
- if client == nil then return end
-
local params = util.make_formatting_params(options)
local bufnr = vim.api.nvim_get_current_buf()
- local result, err = client.request_sync("textDocument/formatting", params, timeout_ms, bufnr)
- if result and result.result then
- util.apply_text_edits(result.result, bufnr)
- elseif err then
- vim.notify("vim.lsp.buf.formatting_sync: " .. err, vim.log.levels.WARN)
- end
+ select_client('textDocument/formatting', function(client)
+ if client == nil then
+ return
+ end
+
+ local result, err = client.request_sync('textDocument/formatting', params, timeout_ms, bufnr)
+ if result and result.result then
+ util.apply_text_edits(result.result, bufnr)
+ elseif err then
+ vim.notify('vim.lsp.buf.formatting_sync: ' .. err, vim.log.levels.WARN)
+ end
+ end)
end
--- Formats the current buffer by sequentially requesting formatting from attached clients.
@@ -238,12 +244,15 @@ end
---@param end_pos ({number, number}, optional) mark-indexed position.
---Defaults to the end of the last visual selection.
function M.range_formatting(options, start_pos, end_pos)
- local client = select_client("textDocument/rangeFormatting")
- if client == nil then return end
-
local params = util.make_given_range_params(start_pos, end_pos)
params.options = util.make_formatting_params(options).options
- return client.request("textDocument/rangeFormatting", params)
+ select_client('textDocument/rangeFormatting', function(client)
+ if client == nil then
+ return
+ end
+
+ return client.request('textDocument/rangeFormatting', params)
+ end)
end
--- Renames all references to the symbol under the cursor.
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua
index 075da41b23..8850d25233 100644
--- a/runtime/lua/vim/lsp/diagnostic.lua
+++ b/runtime/lua/vim/lsp/diagnostic.lua
@@ -153,19 +153,6 @@ function M.get_namespace(client_id)
return _client_namespaces[client_id]
end
---- Save diagnostics to the current buffer.
----
---- Handles saving diagnostics from multiple clients in the same buffer.
----@param diagnostics Diagnostic[]
----@param bufnr number
----@param client_id number
----@private
-function M.save(diagnostics, bufnr, client_id)
- local namespace = M.get_namespace(client_id)
- vim.diagnostic.set(namespace, bufnr, diagnostic_lsp_to_vim(diagnostics, bufnr, client_id))
-end
--- }}}
-
--- |lsp-handler| for the method "textDocument/publishDiagnostics"
---
--- See |vim.diagnostic.config()| for configuration options. Handler-specific
@@ -245,6 +232,23 @@ end
-- Deprecated Functions {{{
+
+--- Save diagnostics to the current buffer.
+---
+---@deprecated Prefer |vim.diagnostic.set()|
+---
+--- Handles saving diagnostics from multiple clients in the same buffer.
+---@param diagnostics Diagnostic[]
+---@param bufnr number
+---@param client_id number
+---@private
+function M.save(diagnostics, bufnr, client_id)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.save is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
+ local namespace = M.get_namespace(client_id)
+ vim.diagnostic.set(namespace, bufnr, diagnostic_lsp_to_vim(diagnostics, bufnr, client_id))
+end
+-- }}}
+
--- Get all diagnostics for clients
---
---@deprecated Prefer |vim.diagnostic.get()|
@@ -253,6 +257,7 @@ end
--- If nil, diagnostics of all clients are included.
---@return table with diagnostics grouped by bufnr (bufnr: Diagnostic[])
function M.get_all(client_id)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.get_all is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
local result = {}
local namespace
if client_id then
@@ -274,6 +279,7 @@ end
--- Else, return just the diagnostics associated with the client_id.
---@param predicate function|nil Optional function for filtering diagnostics
function M.get(bufnr, client_id, predicate)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.get is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
predicate = predicate or function() return true end
if client_id == nil then
local all_diagnostics = {}
@@ -335,6 +341,7 @@ end
---@param severity DiagnosticSeverity
---@param client_id number the client id
function M.get_count(bufnr, severity, client_id)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.get_count is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
severity = severity_lsp_to_vim(severity)
local opts = { severity = severity }
if client_id ~= nil then
@@ -351,6 +358,7 @@ end
---@param opts table See |vim.lsp.diagnostic.goto_next()|
---@return table Previous diagnostic
function M.get_prev(opts)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.get_prev is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
if opts then
if opts.severity then
opts.severity = severity_lsp_to_vim(opts.severity)
@@ -368,6 +376,7 @@ end
---@param opts table See |vim.lsp.diagnostic.goto_next()|
---@return table Previous diagnostic position
function M.get_prev_pos(opts)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.get_prev_pos is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
if opts then
if opts.severity then
opts.severity = severity_lsp_to_vim(opts.severity)
@@ -384,6 +393,7 @@ end
---
---@param opts table See |vim.lsp.diagnostic.goto_next()|
function M.goto_prev(opts)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.goto_prev is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
if opts then
if opts.severity then
opts.severity = severity_lsp_to_vim(opts.severity)
@@ -401,6 +411,7 @@ end
---@param opts table See |vim.lsp.diagnostic.goto_next()|
---@return table Next diagnostic
function M.get_next(opts)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.get_next is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
if opts then
if opts.severity then
opts.severity = severity_lsp_to_vim(opts.severity)
@@ -418,6 +429,7 @@ end
---@param opts table See |vim.lsp.diagnostic.goto_next()|
---@return table Next diagnostic position
function M.get_next_pos(opts)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.get_next_pos is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
if opts then
if opts.severity then
opts.severity = severity_lsp_to_vim(opts.severity)
@@ -432,6 +444,7 @@ end
---
---@deprecated Prefer |vim.diagnostic.goto_next()|
function M.goto_next(opts)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.goto_next is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
if opts then
if opts.severity then
opts.severity = severity_lsp_to_vim(opts.severity)
@@ -455,6 +468,7 @@ end
--- - severity_limit (DiagnosticSeverity):
--- - Limit severity of diagnostics found. E.g. "Warning" means { "Error", "Warning" } will be valid.
function M.set_signs(diagnostics, bufnr, client_id, _, opts)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.set_signs is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
local namespace = M.get_namespace(client_id)
if opts and not opts.severity and opts.severity_limit then
opts.severity = {min=severity_lsp_to_vim(opts.severity_limit)}
@@ -475,6 +489,7 @@ end
--- - severity_limit (DiagnosticSeverity):
--- - Limit severity of diagnostics found. E.g. "Warning" means { "Error", "Warning" } will be valid.
function M.set_underline(diagnostics, bufnr, client_id, _, opts)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.set_underline is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
local namespace = M.get_namespace(client_id)
if opts and not opts.severity and opts.severity_limit then
opts.severity = {min=severity_lsp_to_vim(opts.severity_limit)}
@@ -496,6 +511,7 @@ end
--- - severity_limit (DiagnosticSeverity):
--- - Limit severity of diagnostics found. E.g. "Warning" means { "Error", "Warning" } will be valid.
function M.set_virtual_text(diagnostics, bufnr, client_id, _, opts)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.set_virtual_text is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
local namespace = M.get_namespace(client_id)
if opts and not opts.severity and opts.severity_limit then
opts.severity = {min=severity_lsp_to_vim(opts.severity_limit)}
@@ -514,6 +530,7 @@ end
---@return an array of [text, hl_group] arrays. This can be passed directly to
--- the {virt_text} option of |nvim_buf_set_extmark()|.
function M.get_virtual_text_chunks_for_line(bufnr, _, line_diags, opts)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.get_virtual_text_chunks_for_line is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
return vim.diagnostic._get_virt_text_chunks(diagnostic_lsp_to_vim(line_diags, bufnr), opts)
end
@@ -531,6 +548,7 @@ end
---@param position table|nil The (0,0)-indexed position
---@return table {popup_bufnr, win_id}
function M.show_position_diagnostics(opts, buf_nr, position)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.show_position_diagnostics is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
opts = opts or {}
opts.scope = "cursor"
opts.pos = position
@@ -554,6 +572,7 @@ end
---@param client_id number|nil the client id
---@return table {popup_bufnr, win_id}
function M.show_line_diagnostics(opts, buf_nr, line_nr, client_id)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.show_line_diagnostics is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
opts = opts or {}
opts.scope = "line"
opts.pos = line_nr
@@ -565,7 +584,7 @@ end
--- Redraw diagnostics for the given buffer and client
---
----@deprecated Prefer |vim.diagnostic.redraw()|
+---@deprecated Prefer |vim.diagnostic.show()|
---
--- This calls the "textDocument/publishDiagnostics" handler manually using
--- the cached diagnostics already received from the server. This can be useful
@@ -577,6 +596,7 @@ end
--- client. The default is to redraw diagnostics for all attached
--- clients.
function M.redraw(bufnr, client_id)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.redraw is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
bufnr = get_bufnr(bufnr)
if not client_id then
return vim.lsp.for_each_buffer_client(bufnr, function(client)
@@ -604,6 +624,7 @@ end
--- - {workspace}: (boolean, default true)
--- - Set the list with workspace diagnostics
function M.set_qflist(opts)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.set_qflist is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
opts = opts or {}
if opts.severity then
opts.severity = severity_lsp_to_vim(opts.severity)
@@ -635,6 +656,7 @@ end
--- - {workspace}: (boolean, default false)
--- - Set the list with workspace diagnostics
function M.set_loclist(opts)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.set_loclist is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
opts = opts or {}
if opts.severity then
opts.severity = severity_lsp_to_vim(opts.severity)
@@ -662,6 +684,7 @@ end
-- send diagnostic information and the client will still process it. The
-- diagnostics are simply not displayed to the user.
function M.disable(bufnr, client_id)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.disable is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
if not client_id then
return vim.lsp.for_each_buffer_client(bufnr, function(client)
M.disable(bufnr, client.id)
@@ -682,6 +705,7 @@ end
--- client. The default is to enable diagnostics for all attached
--- clients.
function M.enable(bufnr, client_id)
+ vim.api.nvim_echo({{'vim.lsp.diagnostic.enable is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
if not client_id then
return vim.lsp.for_each_buffer_client(bufnr, function(client)
M.enable(bufnr, client.id)
diff --git a/runtime/lua/vim/lsp/protocol.lua b/runtime/lua/vim/lsp/protocol.lua
index b3aa8b934f..86c9e2fd58 100644
--- a/runtime/lua/vim/lsp/protocol.lua
+++ b/runtime/lua/vim/lsp/protocol.lua
@@ -776,149 +776,9 @@ function protocol.make_client_capabilities()
}
end
---[=[
-export interface DocumentFilter {
- --A language id, like `typescript`.
- language?: string;
- --A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
- scheme?: string;
- --A glob pattern, like `*.{ts,js}`.
- --
- --Glob patterns can have the following syntax:
- --- `*` to match one or more characters in a path segment
- --- `?` to match on one character in a path segment
- --- `**` to match any number of path segments, including none
- --- `{}` to group conditions (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files)
- --- `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)
- --- `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)
- pattern?: string;
-}
---]=]
-
---[[
---Static registration options to be returned in the initialize request.
-interface StaticRegistrationOptions {
- --The id used to register the request. The id can be used to deregister
- --the request again. See also Registration#id.
- id?: string;
-}
-
-export interface DocumentFilter {
- --A language id, like `typescript`.
- language?: string;
- --A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
- scheme?: string;
- --A glob pattern, like `*.{ts,js}`.
- --
- --Glob patterns can have the following syntax:
- --- `*` to match one or more characters in a path segment
- --- `?` to match on one character in a path segment
- --- `**` to match any number of path segments, including none
- --- `{}` to group conditions (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files)
- --- `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)
- --- `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)
- pattern?: string;
-}
-export type DocumentSelector = DocumentFilter[];
-export interface TextDocumentRegistrationOptions {
- --A document selector to identify the scope of the registration. If set to null
- --the document selector provided on the client side will be used.
- documentSelector: DocumentSelector | null;
-}
-
---Code Action options.
-export interface CodeActionOptions {
- --CodeActionKinds that this server may return.
- --
- --The list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server
- --may list out every specific kind they provide.
- codeActionKinds?: CodeActionKind[];
-}
-
-interface ServerCapabilities {
- --Defines how text documents are synced. Is either a detailed structure defining each notification or
- --for backwards compatibility the TextDocumentSyncKind number. If omitted it defaults to `TextDocumentSyncKind.None`.
- textDocumentSync?: TextDocumentSyncOptions | number;
- --The server provides hover support.
- hoverProvider?: boolean;
- --The server provides completion support.
- completionProvider?: CompletionOptions;
- --The server provides signature help support.
- signatureHelpProvider?: SignatureHelpOptions;
- --The server provides goto definition support.
- definitionProvider?: boolean;
- --The server provides Goto Type Definition support.
- --
- --Since 3.6.0
- typeDefinitionProvider?: boolean | (TextDocumentRegistrationOptions & StaticRegistrationOptions);
- --The server provides Goto Implementation support.
- --
- --Since 3.6.0
- implementationProvider?: boolean | (TextDocumentRegistrationOptions & StaticRegistrationOptions);
- --The server provides find references support.
- referencesProvider?: boolean;
- --The server provides document highlight support.
- documentHighlightProvider?: boolean;
- --The server provides document symbol support.
- documentSymbolProvider?: boolean;
- --The server provides workspace symbol support.
- workspaceSymbolProvider?: boolean;
- --The server provides code actions. The `CodeActionOptions` return type is only
- --valid if the client signals code action literal support via the property
- --`textDocument.codeAction.codeActionLiteralSupport`.
- codeActionProvider?: boolean | CodeActionOptions;
- --The server provides code lens.
- codeLensProvider?: CodeLensOptions;
- --The server provides document formatting.
- documentFormattingProvider?: boolean;
- --The server provides document range formatting.
- documentRangeFormattingProvider?: boolean;
- --The server provides document formatting on typing.
- documentOnTypeFormattingProvider?: DocumentOnTypeFormattingOptions;
- --The server provides rename support. RenameOptions may only be
- --specified if the client states that it supports
- --`prepareSupport` in its initial `initialize` request.
- renameProvider?: boolean | RenameOptions;
- --The server provides document link support.
- documentLinkProvider?: DocumentLinkOptions;
- --The server provides color provider support.
- --
- --Since 3.6.0
- colorProvider?: boolean | ColorProviderOptions | (ColorProviderOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions);
- --The server provides folding provider support.
- --
- --Since 3.10.0
- foldingRangeProvider?: boolean | FoldingRangeProviderOptions | (FoldingRangeProviderOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions);
- --The server provides go to declaration support.
- --
- --Since 3.14.0
- declarationProvider?: boolean | (TextDocumentRegistrationOptions & StaticRegistrationOptions);
- --The server provides execute command support.
- executeCommandProvider?: ExecuteCommandOptions;
- --Workspace specific server capabilities
- workspace?: {
- --The server supports workspace folder.
- --
- --Since 3.6.0
- workspaceFolders?: {
- * The server has support for workspace folders
- supported?: boolean;
- * Whether the server wants to receive workspace folder
- * change notifications.
- *
- * If a strings is provided the string is treated as a ID
- * under which the notification is registered on the client
- * side. The ID can be used to unregister for these events
- * using the `client/unregisterCapability` request.
- changeNotifications?: string | boolean;
- }
- }
- --Experimental server capabilities.
- experimental?: any;
-}
---]]
-
--- Creates a normalized object describing LSP server capabilities.
+---@param server_capabilities table Table of capabilities supported by the server
+---@return table Normalized table of capabilities
function protocol.resolve_capabilities(server_capabilities)
local general_properties = {}
local text_document_sync_properties
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 059e66c53a..a3a91a34f7 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -1531,6 +1531,7 @@ end
---
---@param items (table) list of items
function M.set_loclist(items, win_id)
+ vim.api.nvim_echo({{'vim.lsp.util.set_loclist is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
vim.fn.setloclist(win_id or 0, {}, ' ', {
title = 'Language Server';
items = items;
@@ -1544,6 +1545,7 @@ end
---
---@param items (table) list of items
function M.set_qflist(items)
+ vim.api.nvim_echo({{'vim.lsp.util.set_qflist is deprecated. See :h deprecated', 'WarningMsg'}}, true, {})
vim.fn.setqflist({}, ' ', {
title = 'Language Server';
items = items;