diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/builtin.txt | 11 | ||||
-rw-r--r-- | runtime/doc/lsp.txt | 8 | ||||
-rw-r--r-- | runtime/doc/news.txt | 5 | ||||
-rw-r--r-- | runtime/doc/syntax.txt | 8 | ||||
-rw-r--r-- | runtime/doc/treesitter.txt | 1 | ||||
-rw-r--r-- | runtime/doc/usr_41.txt | 16 | ||||
-rw-r--r-- | runtime/lua/vim/lsp.lua | 66 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/protocol.lua | 174 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 9 | ||||
-rw-r--r-- | runtime/lua/vim/treesitter/languagetree.lua | 11 |
10 files changed, 61 insertions, 248 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 5e918a19f4..0e04e9035b 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -223,6 +223,7 @@ getreg([{regname} [, 1 [, {list}]]]) String or List contents of a register getreginfo([{regname}]) Dict information about a register getregtype([{regname}]) String type of a register +getscriptinfo() List list of sourced scripts gettabinfo([{expr}]) List list of tab pages gettabvar({nr}, {varname} [, {def}]) any variable {varname} in tab {nr} or {def} @@ -3576,6 +3577,16 @@ getregtype([{regname}]) *getregtype()* Can also be used as a |method|: > GetRegname()->getregtype() +getscriptinfo() *getscriptinfo()* + Returns a |List| with information about all the sourced Vim + scripts in the order they were sourced. + + Each item in the returned List is a |Dict| with the following + items: + autoload always set to FALSE. + name vim script file name. + sid script ID |<SID>|. + gettabinfo([{tabnr}]) *gettabinfo()* If {tabnr} is not specified, then information about all the tab pages is returned as a |List|. Each List item is a diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index d13dc4a782..ca65251a9f 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -676,7 +676,7 @@ buf_request_all({bufnr}, {method}, {params}, {callback}) finished. Unlike `buf_request`, this will collect all the responses from each server instead of handling them. A map of client_id:request_result will be provided to the - callback + callback. Return: ~ fun() cancel A function that will cancel all requests @@ -697,9 +697,9 @@ buf_request_sync({bufnr}, {method}, {params}, {timeout_ms}) result. Defaults to 1000 Return: ~ - table<integer, any>|nil result, string|nil err Map of - client_id:request_result. On timeout, cancel or error, returns `(nil, - err)` where `err` is a string describing the failure reason. + (table) result Map of client_id:request_result. + (string|nil) err On timeout, cancel, or error, `err` is a string + describing the failure reason, and `result` is nil. client() *vim.lsp.client* LSP client object. You can get an active client object via diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 7df96874ea..78cd05b7d5 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -237,7 +237,10 @@ The following deprecated functions or APIs were removed. changes need to be contributed there first.) See https://github.com/neovim/neovim/pull/20674. -- 'hkmap', 'hkmapp' and 'aleph' options were removed. Use 'keymap' option instead. +• 'hkmap', 'hkmapp' and 'aleph' options were removed. Use 'keymap' option instead. + +• |LanguageTree:parse()| no longer returns changed regions. Please use the + `on_changedtree` callbacks instead. ============================================================================== DEPRECATIONS *news-deprecations* diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index b22d673eb9..9051375da2 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -5278,6 +5278,14 @@ NormalNC Normal text in non-current windows. Pmenu Popup menu: Normal item. *hl-PmenuSel* PmenuSel Popup menu: Selected item. + *hl-PmenuKind* +PmenuKind Popup menu: Normal item "kind". + *hl-PmenuKindSel* +PmenuKindSel Popup menu: Selected item "kind". + *hl-PmenuExtra* +PmenuExtra Popup menu: Normal item "extra text". + *hl-PmenuExtraSel* +PmenuExtraSel Popup menu: Selected item "extra text". *hl-PmenuSbar* PmenuSbar Popup menu: Scrollbar. *hl-PmenuThumb* diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 8a0145127c..ddca307e74 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -1111,7 +1111,6 @@ LanguageTree:parse({self}) *LanguageTree:parse()* Return: ~ TSTree[] - (table|nil) Change list LanguageTree:register_cbs({self}, {cbs}) *LanguageTree:register_cbs()* Registers callbacks for the |LanguageTree|. diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index ed16f837cf..17a34b1236 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -1056,6 +1056,14 @@ Prompt Buffer: *promptbuffer-functions* prompt_setinterrupt() set interrupt callback for a buffer prompt_setprompt() set the prompt text for a buffer +Registers: *register-functions* + getreg() get contents of a register + getreginfo() get information about a register + getregtype() get type of a register + setreg() set contents and type of a register + reg_executing() return the name of the register being executed + reg_recording() return the name of the register being recorded + Context Stack: *ctx-functions* ctxget() return context at given index from top ctxpop() pop and restore top context @@ -1072,6 +1080,7 @@ Various: *various-functions* did_filetype() check if a FileType autocommand was used eventhandler() check if invoked by an event handler getpid() get process ID of Vim + getscriptinfo() get list of sourced vim scripts libcall() call a function in an external library libcallnr() idem, returning a number @@ -1079,13 +1088,6 @@ Various: *various-functions* undofile() get the name of the undo file undotree() return the state of the undo tree - getreg() get contents of a register - getreginfo() get information about a register - getregtype() get type of a register - setreg() set contents and type of a register - reg_executing() return the name of the register being executed - reg_recording() return the name of the register being recorded - shiftwidth() effective value of 'shiftwidth' wordcount() get byte/word/char count of buffer diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index c85d38a50e..39665a3d4f 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: invisible local default_handlers = require('vim.lsp.handlers') local log = require('vim.lsp.log') local lsp_rpc = require('vim.lsp.rpc') @@ -369,7 +370,7 @@ do --- @field offset_encoding "utf-8"|"utf-16"|"utf-32" --- --- @class CTBufferState - --- @field uri string uri of the buffer + --- @field name string name of the buffer --- @field lines string[] snapshot of buffer lines from last didChange --- @field lines_tmp string[] --- @field pending_changes table[] List of debounced changes in incremental sync mode @@ -488,12 +489,8 @@ do if buf_state then buf_state.refs = buf_state.refs + 1 else - local uri = vim.uri_from_bufnr(bufnr) - if not uv.fs_stat(api.nvim_buf_get_name(bufnr)) then - uri = uri:gsub('^file://', 'buffer://') - end buf_state = { - uri = uri, + name = api.nvim_buf_get_name(bufnr), lines = {}, lines_tmp = {}, pending_changes = {}, @@ -508,26 +505,12 @@ do end ---@private - ---@param client table - ---@param bufnr integer - ---@return string uri - function changetracking._get_uri(client, bufnr) + function changetracking._get_and_set_name(client, bufnr, name) local state = state_by_group[get_group(client)] or {} local buf_state = (state.buffers or {})[bufnr] - return assert(buf_state.uri, 'Must have an URI set') - end - - ---@private - ---@param client table - ---@param bufnr integer - ---@param uri string - ---@return string uri - function changetracking._get_and_set_uri(client, bufnr, uri) - local state = state_by_group[get_group(client)] or {} - local buf_state = (state.buffers or {})[bufnr] - local old_uri = buf_state.uri - buf_state.uri = uri - return old_uri + local old_name = buf_state.name + buf_state.name = name + return old_name end ---@private @@ -614,7 +597,7 @@ do { text = buf_get_full_text(bufnr) }, } end - local uri = buf_state.uri + local uri = vim.uri_from_bufnr(bufnr) for _, client in pairs(state.clients) do if not client.is_stopped() and lsp.buf_is_attached(bufnr, client.id) then client.notify('textDocument/didChange', { @@ -727,14 +710,11 @@ local function text_document_did_open_handler(bufnr, client) return end local filetype = nvim_buf_get_option(bufnr, 'filetype') - local uri = vim.uri_from_bufnr(bufnr) - if not uv.fs_stat(api.nvim_buf_get_name(bufnr)) then - uri = uri:gsub('^file://', 'buffer://') - end + local params = { textDocument = { version = 0, - uri = uri, + uri = vim.uri_from_bufnr(bufnr), languageId = client.config.get_language_id(bufnr, filetype), text = buf_get_full_text(bufnr), }, @@ -1058,7 +1038,7 @@ function lsp.start_client(config) --- Returns the default handler if the user hasn't set a custom one. --- ---@param method (string) LSP method name - ---@return function|nil The handler for the given method, if defined, or the default from |vim.lsp.handlers| + ---@return lsp-handler|nil The handler for the given method, if defined, or the default from |vim.lsp.handlers| local function resolve_handler(method) return handlers[method] or default_handlers[method] end @@ -1611,11 +1591,11 @@ local function text_document_did_save_handler(bufnr) local text = once(buf_get_full_text) for_each_buffer_client(bufnr, function(client) local name = api.nvim_buf_get_name(bufnr) - local old_uri = changetracking._get_and_set_uri(client, bufnr, uri) - if old_uri and name ~= old_uri then + local old_name = changetracking._get_and_set_name(client, bufnr, name) + if old_name and name ~= old_name then client.notify('textDocument/didClose', { textDocument = { - uri = old_uri, + uri = vim.uri_from_fname(old_name), }, }) client.notify('textDocument/didOpen', { @@ -1720,12 +1700,8 @@ function lsp.buf_attach_client(bufnr, client_id) end) end, on_detach = function() + local params = { textDocument = { uri = uri } } for_each_buffer_client(bufnr, function(client, _) - local params = { - textDocument = { - uri = changetracking._get_uri(client, bufnr), - }, - } changetracking.reset_buf(client, bufnr) if vim.tbl_get(client.server_capabilities, 'textDocumentSync', 'openClose') then client.notify('textDocument/didClose', params) @@ -1962,7 +1938,7 @@ api.nvim_create_autocmd('VimLeavePre', { ---@param bufnr (integer) Buffer handle, or 0 for current. ---@param method (string) LSP method name ---@param params table|nil Parameters to send to the server ----@param handler function|nil See |lsp-handler| +---@param handler lsp-handler|nil See |lsp-handler| --- If nil, follows resolution strategy defined in |lsp-handler-configuration| --- ---@return table<integer, integer>, fun() 2-tuple: @@ -2022,9 +1998,10 @@ end ---@param bufnr (integer) Buffer handle, or 0 for current. ---@param method (string) LSP method name ---@param params (table|nil) Parameters to send to the server ----@param callback (function) The callback to call when all requests are finished. +---@param callback fun(request_results: table<integer, {error: lsp.ResponseError, result: any}>) (function) +--- The callback to call when all requests are finished. --- Unlike `buf_request`, this will collect all the responses from each server instead of handling them. ---- A map of client_id:request_result will be provided to the callback +--- A map of client_id:request_result will be provided to the callback. --- ---@return fun() cancel A function that will cancel all requests function lsp.buf_request_all(bufnr, method, params, callback) @@ -2067,9 +2044,8 @@ end ---@param timeout_ms (integer|nil) Maximum time in milliseconds to wait for a --- result. Defaults to 1000 --- ----@return table<integer, any>|nil result, string|nil err Map of client_id:request_result. ---- On timeout, cancel or error, returns `(nil, err)` where `err` is a string describing ---- the failure reason. +---@return table<integer, {err: lsp.ResponseError, result: any}>|nil (table) result Map of client_id:request_result. +---@return string|nil err On timeout, cancel, or error, `err` is a string describing the failure reason, and `result` is nil. function lsp.buf_request_sync(bufnr, method, params, timeout_ms) local request_results diff --git a/runtime/lua/vim/lsp/protocol.lua b/runtime/lua/vim/lsp/protocol.lua index 27dd68645a..1686e22c48 100644 --- a/runtime/lua/vim/lsp/protocol.lua +++ b/runtime/lua/vim/lsp/protocol.lua @@ -854,7 +854,6 @@ function protocol.make_client_capabilities() } end -local if_nil = vim.F.if_nil --- 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 @@ -892,178 +891,5 @@ function protocol.resolve_capabilities(server_capabilities) return server_capabilities end ----@private ---- Creates a normalized object describing LSP server capabilities. --- @deprecated access resolved_capabilities instead ----@param server_capabilities table Table of capabilities supported by the server ----@return table Normalized table of capabilities -function protocol._resolve_capabilities_compat(server_capabilities) - local general_properties = {} - local text_document_sync_properties - do - local TextDocumentSyncKind = protocol.TextDocumentSyncKind - local textDocumentSync = server_capabilities.textDocumentSync - if textDocumentSync == nil then - -- Defaults if omitted. - text_document_sync_properties = { - text_document_open_close = false, - text_document_did_change = TextDocumentSyncKind.None, - -- text_document_did_change = false; - text_document_will_save = false, - text_document_will_save_wait_until = false, - text_document_save = false, - text_document_save_include_text = false, - } - elseif type(textDocumentSync) == 'number' then - -- Backwards compatibility - if not TextDocumentSyncKind[textDocumentSync] then - return nil, 'Invalid server TextDocumentSyncKind for textDocumentSync' - end - text_document_sync_properties = { - text_document_open_close = true, - text_document_did_change = textDocumentSync, - text_document_will_save = false, - text_document_will_save_wait_until = false, - text_document_save = true, - text_document_save_include_text = false, - } - elseif type(textDocumentSync) == 'table' then - text_document_sync_properties = { - text_document_open_close = if_nil(textDocumentSync.openClose, false), - text_document_did_change = if_nil(textDocumentSync.change, TextDocumentSyncKind.None), - text_document_will_save = if_nil(textDocumentSync.willSave, true), - text_document_will_save_wait_until = if_nil(textDocumentSync.willSaveWaitUntil, true), - text_document_save = if_nil(textDocumentSync.save, false), - text_document_save_include_text = if_nil( - type(textDocumentSync.save) == 'table' and textDocumentSync.save.includeText, - false - ), - } - else - return nil, string.format('Invalid type for textDocumentSync: %q', type(textDocumentSync)) - end - end - general_properties.completion = server_capabilities.completionProvider ~= nil - general_properties.hover = server_capabilities.hoverProvider or false - general_properties.goto_definition = server_capabilities.definitionProvider or false - general_properties.find_references = server_capabilities.referencesProvider or false - general_properties.document_highlight = server_capabilities.documentHighlightProvider or false - general_properties.document_symbol = server_capabilities.documentSymbolProvider or false - general_properties.workspace_symbol = server_capabilities.workspaceSymbolProvider or false - general_properties.document_formatting = server_capabilities.documentFormattingProvider or false - general_properties.document_range_formatting = server_capabilities.documentRangeFormattingProvider - or false - general_properties.call_hierarchy = server_capabilities.callHierarchyProvider or false - general_properties.execute_command = server_capabilities.executeCommandProvider ~= nil - - if server_capabilities.renameProvider == nil then - general_properties.rename = false - elseif type(server_capabilities.renameProvider) == 'boolean' then - general_properties.rename = server_capabilities.renameProvider - else - general_properties.rename = true - end - - if server_capabilities.codeLensProvider == nil then - general_properties.code_lens = false - general_properties.code_lens_resolve = false - elseif type(server_capabilities.codeLensProvider) == 'table' then - general_properties.code_lens = true - general_properties.code_lens_resolve = server_capabilities.codeLensProvider.resolveProvider - or false - else - error('The server sent invalid codeLensProvider') - end - - if server_capabilities.codeActionProvider == nil then - general_properties.code_action = false - elseif - type(server_capabilities.codeActionProvider) == 'boolean' - or type(server_capabilities.codeActionProvider) == 'table' - then - general_properties.code_action = server_capabilities.codeActionProvider - else - error('The server sent invalid codeActionProvider') - end - - if server_capabilities.declarationProvider == nil then - general_properties.declaration = false - elseif type(server_capabilities.declarationProvider) == 'boolean' then - general_properties.declaration = server_capabilities.declarationProvider - elseif type(server_capabilities.declarationProvider) == 'table' then - general_properties.declaration = server_capabilities.declarationProvider - else - error('The server sent invalid declarationProvider') - end - - if server_capabilities.typeDefinitionProvider == nil then - general_properties.type_definition = false - elseif type(server_capabilities.typeDefinitionProvider) == 'boolean' then - general_properties.type_definition = server_capabilities.typeDefinitionProvider - elseif type(server_capabilities.typeDefinitionProvider) == 'table' then - general_properties.type_definition = server_capabilities.typeDefinitionProvider - else - error('The server sent invalid typeDefinitionProvider') - end - - if server_capabilities.implementationProvider == nil then - general_properties.implementation = false - elseif type(server_capabilities.implementationProvider) == 'boolean' then - general_properties.implementation = server_capabilities.implementationProvider - elseif type(server_capabilities.implementationProvider) == 'table' then - general_properties.implementation = server_capabilities.implementationProvider - else - error('The server sent invalid implementationProvider') - end - - local workspace = server_capabilities.workspace - local workspace_properties = {} - if workspace == nil or workspace.workspaceFolders == nil then - -- Defaults if omitted. - workspace_properties = { - workspace_folder_properties = { - supported = false, - changeNotifications = false, - }, - } - elseif type(workspace.workspaceFolders) == 'table' then - workspace_properties = { - workspace_folder_properties = { - supported = if_nil(workspace.workspaceFolders.supported, false), - changeNotifications = if_nil(workspace.workspaceFolders.changeNotifications, false), - }, - } - else - error('The server sent invalid workspace') - end - - local signature_help_properties - if server_capabilities.signatureHelpProvider == nil then - signature_help_properties = { - signature_help = false, - signature_help_trigger_characters = {}, - } - elseif type(server_capabilities.signatureHelpProvider) == 'table' then - signature_help_properties = { - signature_help = true, - -- The characters that trigger signature help automatically. - signature_help_trigger_characters = server_capabilities.signatureHelpProvider.triggerCharacters - or {}, - } - else - error('The server sent invalid signatureHelpProvider') - end - - local capabilities = vim.tbl_extend( - 'error', - text_document_sync_properties, - signature_help_properties, - workspace_properties, - general_properties - ) - - return capabilities -end - return protocol -- vim:sw=2 ts=2 et diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index c9613dc7a7..342fad33c2 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -2032,12 +2032,7 @@ end ---@returns `TextDocumentIdentifier` ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentIdentifier function M.make_text_document_params(bufnr) - bufnr = bufnr or 0 - local uri = vim.uri_from_bufnr(bufnr) - if not uv.fs_stat(api.nvim_buf_get_name(bufnr)) then - uri = uri:gsub('^file://', 'buffer://') - end - return { uri = uri } + return { uri = vim.uri_from_bufnr(bufnr or 0) } end --- Create the workspace params @@ -2070,7 +2065,7 @@ function M.make_formatting_params(options) insertSpaces = vim.bo.expandtab, }) return { - textDocument = M.make_text_document_params(0), + textDocument = { uri = vim.uri_from_bufnr(0) }, options = options, } end diff --git a/runtime/lua/vim/treesitter/languagetree.lua b/runtime/lua/vim/treesitter/languagetree.lua index 6869fae92c..bdfe281a5b 100644 --- a/runtime/lua/vim/treesitter/languagetree.lua +++ b/runtime/lua/vim/treesitter/languagetree.lua @@ -228,7 +228,6 @@ end --- determine if any child languages should be created. --- ---@return TSTree[] ----@return table|nil Change list function LanguageTree:parse() if self:is_valid() then self:_log('valid') @@ -302,18 +301,12 @@ function LanguageTree:parse() }) self:for_each_child(function(child) - local _, child_changes = child:parse() - - -- Propagate any child changes so they are included in the - -- the change list for the callback. - if child_changes then - vim.list_extend(changes, child_changes) - end + child:parse() end) self._valid = true - return self._trees, changes + return self._trees end --- Invokes the callback for each |LanguageTree| and its children recursively |