diff options
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/autoload/provider/clipboard.vim | 3 | ||||
| -rw-r--r-- | runtime/doc/api.txt | 4 | ||||
| -rw-r--r-- | runtime/doc/deprecated.txt | 5 | ||||
| -rw-r--r-- | runtime/doc/intro.txt | 1 | ||||
| -rw-r--r-- | runtime/doc/lsp.txt | 42 | ||||
| -rw-r--r-- | runtime/doc/motion.txt | 6 | ||||
| -rw-r--r-- | runtime/doc/news.txt | 20 | ||||
| -rw-r--r-- | runtime/doc/options.txt | 18 | ||||
| -rw-r--r-- | runtime/doc/term.txt | 42 | ||||
| -rw-r--r-- | runtime/doc/vim_diff.txt | 8 | ||||
| -rw-r--r-- | runtime/lua/vim/lsp.lua | 45 | ||||
| -rw-r--r-- | runtime/lua/vim/lsp/buf.lua | 11 | ||||
| -rw-r--r-- | runtime/lua/vim/lsp/health.lua | 2 | ||||
| -rw-r--r-- | runtime/lua/vim/lsp/util.lua | 10 |
14 files changed, 117 insertions, 100 deletions
diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index 6d238ddb55..6ba28dcbfc 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -25,7 +25,8 @@ function! s:selection.on_exit(jobid, data, event) abort if self.owner == a:jobid let self.owner = 0 endif - if a:data != 0 + " Don't print if exit code is >= 128 ( exit is 128+SIGNUM if by signal (e.g. 143 on SIGTERM)) + if a:data > 0 && a:data < 128 echohl WarningMsg echomsg 'clipboard: error invoking '.get(self.argv, 0, '?').': '.join(self.stderr) echohl None diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index a20ba9a348..b33d251786 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -2989,7 +2989,9 @@ nvim_win_text_height({window}, {*opts}) *nvim_win_text_height()* omitted include the whole line. Return: ~ - The number of screen lines that the range of text occupy. + Dictionary containing text height information, with these keys: + • all: The total number of screen lines occupied by the range. + • fill: The number of diff filler or virtual lines among them. See also: ~ • |virtcol()| for text width. diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt index 6317789d22..81dd1e64bf 100644 --- a/runtime/doc/deprecated.txt +++ b/runtime/doc/deprecated.txt @@ -129,7 +129,7 @@ LSP FUNCTIONS - *vim.lsp.util.diagnostics_to_items()* Use |vim.diagnostic.toqflist()| instead. - *vim.lsp.util.set_qflist()* Use |setqflist()| instead. - *vim.lsp.util.set_loclist()* Use |setloclist()| instead. -- *vim.lsp.buf_get_clients()* Use |vim.lsp.get_active_clients()| with +- *vim.lsp.buf_get_clients()* Use |vim.lsp.get_clients()| with {buffer=bufnr} instead. - *vim.lsp.buf.formatting()* Use |vim.lsp.buf.format()| with {async=true} instead. @@ -139,7 +139,8 @@ LSP FUNCTIONS or |vim.lsp.buf.format()| instead. - *vim.lsp.util.get_progress_messages()* Use |vim.lsp.status()| or access `progress` of |vim.lsp.client| -- *vim.lsp.for_each_buffer_client()* Use |vim.lsp.get_active_clients()| +- *vim.lsp.get_active_clients()* Use |vim.lsp.get_clients()| +- *vim.lsp.for_each_buffer_client()* Use |vim.lsp.get_clients()| TREESITTER FUNCTIONS - *vim.treesitter.language.require_language()* Use |vim.treesitter.language.add()| diff --git a/runtime/doc/intro.txt b/runtime/doc/intro.txt index ab380184fc..b496dc5240 100644 --- a/runtime/doc/intro.txt +++ b/runtime/doc/intro.txt @@ -372,6 +372,7 @@ notation meaning equivalent decimal value(s) ~ <C-…> control-key *control* *ctrl* *<C-* <M-…> alt-key or meta-key *META* *ALT* *<M-* <A-…> same as <M-…> *<A-* +<T-…> meta-key when it's not alt *<T-* <D-…> command-key or "super" key *<D-* ----------------------------------------------------------------------- ~ diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index 5de3e98b5a..fa109dbc26 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -38,7 +38,7 @@ Follow these steps to get LSP features: }) < 3. Check that the server attached to the buffer: > - :lua =vim.lsp.get_active_clients() + :lua =vim.lsp.get_clients() 4. Configure keymaps and autocmds to use LSP features. See |lsp-config|. @@ -105,7 +105,7 @@ calls behind capability checks: To learn what capabilities are available you can run the following command in a buffer with a started LSP client: >vim - :lua =vim.lsp.get_active_clients()[1].server_capabilities + :lua =vim.lsp.get_clients()[1].server_capabilities Full list of features provided by default can be found in |lsp-buf|. @@ -114,7 +114,7 @@ FAQ *lsp-faq* - Q: How to force-reload LSP? - A: Stop all clients, then reload the buffer. >vim - :lua vim.lsp.stop_client(vim.lsp.get_active_clients()) + :lua vim.lsp.stop_client(vim.lsp.get_clients()) :edit - Q: Why isn't completion working? @@ -690,7 +690,7 @@ buf_request_sync({bufnr}, {method}, {params}, {timeout_ms}) client() *vim.lsp.client* LSP client object. You can get an active client object via - |vim.lsp.get_client_by_id()| or |vim.lsp.get_active_clients()|. + |vim.lsp.get_client_by_id()| or |vim.lsp.get_clients()|. • Methods: • request(method, params, [handler], bufnr) Sends a request to the @@ -773,22 +773,6 @@ formatexpr({opts}) *vim.lsp.formatexpr()* • timeout_ms (default 500ms). The timeout period for the formatting request. -get_active_clients({filter}) *vim.lsp.get_active_clients()* - Get active clients. - - Parameters: ~ - • {filter} (table|nil) A table with key-value pairs used to filter the - returned clients. The available keys are: - • id (number): Only return clients with the given id - • bufnr (number): Only return clients attached to this - buffer - • name (string): Only return clients with the given name - • method (string): Only return clients supporting the given - method - - Return: ~ - lsp.Client []: List of |vim.lsp.client| objects - *vim.lsp.get_buffers_by_client_id()* get_buffers_by_client_id({client_id}) Returns list of buffers attached to client_id. @@ -809,6 +793,22 @@ get_client_by_id({client_id}) *vim.lsp.get_client_by_id()* Return: ~ (nil|lsp.Client) client rpc object +get_clients({filter}) *vim.lsp.get_clients()* + Get active clients. + + Parameters: ~ + • {filter} (table|nil) A table with key-value pairs used to filter the + returned clients. The available keys are: + • id (number): Only return clients with the given id + • bufnr (number): Only return clients attached to this + buffer + • name (string): Only return clients with the given name + • method (string): Only return clients supporting the given + method + + Return: ~ + lsp.Client []: List of |vim.lsp.client| objects + get_log_path() *vim.lsp.get_log_path()* Gets the path of the logfile used by the LSP client. @@ -1040,7 +1040,7 @@ stop_client({client_id}, {force}) *vim.lsp.stop_client()* You can also use the `stop()` function on a |vim.lsp.client| object. To stop all clients: >lua - vim.lsp.stop_client(vim.lsp.get_active_clients()) + vim.lsp.stop_client(vim.lsp.get_clients()) < By default asks the server to shutdown, unless stop was requested already diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt index d7a0205ebd..9ce22c9b78 100644 --- a/runtime/doc/motion.txt +++ b/runtime/doc/motion.txt @@ -1026,6 +1026,12 @@ CTRL-O Go to [count] Older cursor position in jump list CTRL-I Go to [count] newer cursor position in jump list (not a motion command). + NOTE: In the GUI and in a terminal supporting + |tui-modifyOtherKeys| or |tui-csiu|, CTRL-I can be + mapped separately from <Tab>, on the condition that + both keys are mapped, otherwise the mapping applies to + both. + *:ju* *:jumps* :ju[mps] Print the jump list (not a motion command). diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index e16bcafac2..6294a8b505 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -51,6 +51,16 @@ The following changes may require adaptations in user config or plugins. • `vim.json.null` is redundant with `vim.NIL`. • `vim.json.array_mt` (and related) is redundant with `vim.empty_dict()`. +• Removed some Vim 5.0<= option compatibilities: + • |'backspace'| no longer supports number values. Instead: + • for `backspace=0` set `backspace=` (empty) + • for `backspace=1` set `backspace=indent,eol` + • for `backspace=2` set `backspace=indent,eol,start` (default behavior in Nvim) + • for `backspace=3` set `backspace=indent,eol,nostop` + • paths in |'backupdir'|, |'path'| and |'cdpath'| can no longer be separated with + spaces (but paths themselves may contain spaces now). + • |'directory'| will no longer remove a `>` at the start of the option. + ============================================================================== NEW FEATURES *news-features* @@ -99,11 +109,14 @@ The following new APIs and features were added. • |vim.system()| for running system commands. -• Added |nvim_win_text_height()| to get the number of screen lines occupied by - a range of text in a given window. +• Added |nvim_win_text_height()| to compute the number of screen lines occupied + by a range of text in a given window. • |nvim_set_keymap()| and |nvim_del_keymap()| now support abbreviations. +• Builtin TUI can now recognize "super" (|<D-|) and "meta" (|<T-|) modifiers in a + terminal emulator that supports |tui-csiu|. + • Implemented LSP inlay hints: |vim.lsp.inlay_hint()| https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_inlayHint @@ -191,7 +204,8 @@ release. • vim.lsp functions: - |vim.lsp.util.get_progress_messages()| Use |vim.lsp.status()| instead. - - |vim.lsp.for_each_buffer_client()| Use |vim.lsp.get_active_clients()| instead. + - |vim.lsp.get_active_clients()| Use |vim.lsp.get_clients()| instead. + - |vim.lsp.for_each_buffer_client()| Use |vim.lsp.get_clients()| instead. • `vim.loop` has been renamed to `vim.uv`. diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index da634966f9..4b9797408c 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -762,13 +762,6 @@ A jump table for the options with a short description can be found at |Q_op|. When the value is empty, Vi compatible backspacing is used, none of the ways mentioned for the items above are possible. - For backwards compatibility with version 5.4 and earlier: - value effect ~ - 0 same as ":set backspace=" (Vi compatible) - 1 same as ":set backspace=indent,eol" - 2 same as ":set backspace=indent,eol,start" - 3 same as ":set backspace=indent,eol,nostop" - *'backup'* *'bk'* *'nobackup'* *'nobk'* 'backup' 'bk' boolean (default off) global @@ -880,8 +873,7 @@ A jump table for the options with a short description can be found at |Q_op|. - Careful with '\' characters, type one before a space, type two to get one in the option (see |option-backslash|), for example: > :set bdir=c:\\tmp,\ dir\\,with\\,commas,\\\ dir\ with\ spaces -< - For backwards compatibility with Vim version 3.0 a '>' at the start - of the option is removed. +< See also 'backup' and 'writebackup' options. If you want to hide your backup files on Unix, consider this value: > :set backupdir=./.backup,~/.backup,.,/tmp @@ -2083,9 +2075,7 @@ A jump table for the options with a short description can be found at |Q_op|. - Careful with '\' characters, type one before a space, type two to get one in the option (see |option-backslash|), for example: > :set dir=c:\\tmp,\ dir\\,with\\,commas,\\\ dir\ with\ spaces -< - For backwards compatibility with Vim version 3.0 a '>' at the start - of the option is removed. - +< Editing the same file twice will result in a warning. Using "/tmp" on is discouraged: if the system crashes you lose the swap file. And others on the computer may be able to see the files. @@ -4490,10 +4480,6 @@ A jump table for the options with a short description can be found at |Q_op|. option may be relative or absolute. - Use commas to separate directory names: > :set path=.,/usr/local/include,/usr/include -< - Spaces can also be used to separate directory names (for backwards - compatibility with version 3.0). To have a space in a directory - name, precede it with an extra backslash, and escape the space: > - :set path=.,/dir/with\\\ space < - To include a comma in a directory name precede it with an extra backslash: > :set path=.,/dir/with\\,comma diff --git a/runtime/doc/term.txt b/runtime/doc/term.txt index 847b4b6112..ee8a4d8732 100644 --- a/runtime/doc/term.txt +++ b/runtime/doc/term.txt @@ -108,10 +108,22 @@ and right scroll margins as well. If Nvim detects that the terminal is Xterm, it will make use of this ability to speed up scrolling that is not the full width of the terminal. - *tui-input* + *tui-input* +Historically, terminal emulators could not distinguish between certain control +key modifiers and other keys. For example, <C-I> and <Tab> are represented in +the same way, as are <Esc> and <C-[>, <CR> and <C-M>, and <NL> and <C-J>. + +Modern terminal emulators are able to distinguish between these pairs of keys +by encoding control modifiers differently. There are two common but distinct +ways of doing this, known as "modifyOtherKeys" and "CSI u". Nvim supports both +encoding methods and at startup will tell the terminal emulator that it +understands these key encodings. If your terminal emulator supports it then +this will allow you to map the key pairs listed above separately. |<Tab>| + Nvim uses libtermkey to convert terminal escape sequences to key codes. |terminfo| is used first, and CSI sequences not in |terminfo| (including -extended keys a.k.a. modifyOtherKeys or "CSI u") can also be parsed. +extended keys a.k.a. "modifyOtherKeys" or "CSI u") can also be parsed. + For example, when running Nvim in tmux, this makes Nvim leave Insert mode and go to the window below: > tmux send-keys 'Escape' [ 2 7 u 'C-W' j @@ -124,42 +136,22 @@ For example, this sequence is recognized by Nvim as <C-kEnter>: > and can be used differently from <C-CR> in mappings. *tui-modifyOtherKeys* *tui-csiu* -Historically, terminal emulators could not distinguish between certain control -key modifiers and other keys. For example, <C-I> and <Tab> are represented the -same way, as are <Esc> and <C-[>, <CR> and <C-M>, and <NL> and <C-J>. This -meant that Nvim also could not map these keys separately. - -Modern terminal emulators are able to distinguish between these pairs of keys -by encoding control modifiers differently. There are two common but distinct -ways of doing this, known as "modifyOtherKeys" and "CSI u". Nvim supports both -encoding methods and at startup will tell the terminal emulator that it -understands these key encodings. If your terminal emulator supports it then -this will allow you to map the key pairs listed above separately. - -At startup Nvim will query your terminal to see if it supports the CSI u +At startup Nvim will query your terminal to see if it supports the "CSI u" encoding by writing the sequence > - CSI ? u CSI c - If your terminal emulator responds with > - CSI ? <flags> u - -this means your terminal supports the CSI u encoding and Nvim will tell your +this means your terminal supports the "CSI u" encoding and Nvim will tell your terminal to enable it by writing the sequence > - CSI > 1 u - -If your terminal does not support CSI u then Nvim will instead enable the +If your terminal does not support "CSI u" then Nvim will instead enable the "modifyOtherKeys" encoding by writing the sequence > - CSI > 4 ; 2 m When Nvim exits cleanly it will send the corresponding sequence to disable the special key encoding. If Nvim does not exit cleanly then your terminal emulator could be in a bad state. If this happens, simply run "reset". - *tui-colors* Nvim uses 256 colours by default, ignoring |terminfo| for most terminal types, including "linux" (whose virtual terminals have had 256-colour support since diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index f7d0330744..8e87c7ee6c 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -623,10 +623,17 @@ Highlight groups: Options: *'aleph'* *'al'* antialias + 'backspace' no longer supports number values. Instead: + - for `backspace=0` set `backspace=` (empty) + - for `backspace=1` set `backspace=indent,eol` + - for `backspace=2` set `backspace=indent,eol,start` (default behavior in Nvim) + - for `backspace=3` set `backspace=indent,eol,nostop` *'balloondelay'* *'bdlay'* *'ballooneval'* *'beval'* *'noballooneval'* *'nobeval'* *'balloonexpr'* *'bexpr'* + 'backupdir': paths can no longer be separated with spaces. bioskey (MS-DOS) + 'cdpath': paths can no longer be separated with spaces. conskey (MS-DOS) *'cp'* *'nocompatible'* *'nocp'* *'compatible'* (Nvim is always "nocompatible".) 'cpoptions' (gjkHw<*- and all POSIX flags were removed) @@ -691,6 +698,7 @@ Options: Use |g8| or |ga|. See |mbyte-combining|. *'maxmem'* Nvim delegates memory-management to the OS. *'maxmemtot'* Nvim delegates memory-management to the OS. + |'path'|: paths can no longer be separated with spaces. printoptions *'printdevice'* *'printencoding'* diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index e9a1423d2d..97aab45f2c 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -612,7 +612,7 @@ do ---@private function changetracking.send_changes(bufnr, firstline, lastline, new_lastline) local groups = {} ---@type table<string,CTGroup> - for _, client in pairs(lsp.get_active_clients({ bufnr = bufnr })) do + for _, client in pairs(lsp.get_clients({ bufnr = bufnr })) do local group = get_group(client) groups[group_key(group)] = group end @@ -734,7 +734,7 @@ end -- FIXME: DOC: Shouldn't need to use a dummy function -- --- LSP client object. You can get an active client object via ---- |vim.lsp.get_client_by_id()| or |vim.lsp.get_active_clients()|. +--- |vim.lsp.get_client_by_id()| or |vim.lsp.get_clients()|. --- --- - Methods: --- @@ -880,7 +880,7 @@ function lsp.start(config, opts) if bufnr == nil or bufnr == 0 then bufnr = api.nvim_get_current_buf() end - for _, clients in ipairs({ uninitialized_clients, lsp.get_active_clients() }) do + for _, clients in ipairs({ uninitialized_clients, lsp.get_clients() }) do for _, client in pairs(clients) do if reuse_client(client, config) then lsp.buf_attach_client(bufnr, client.id) @@ -903,7 +903,7 @@ end function lsp.status() local percentage = nil local messages = {} - for _, client in ipairs(vim.lsp.get_active_clients()) do + for _, client in ipairs(vim.lsp.get_clients()) do for progress in client.progress do local value = progress.value if type(value) == 'table' and value.kind then @@ -1755,7 +1755,7 @@ local function text_document_did_save_handler(bufnr) bufnr = resolve_bufnr(bufnr) local uri = vim.uri_from_bufnr(bufnr) local text = once(buf_get_full_text) - for _, client in ipairs(lsp.get_active_clients({ bufnr = bufnr })) do + for _, client in ipairs(lsp.get_clients({ bufnr = bufnr })) do local name = api.nvim_buf_get_name(bufnr) local old_name = changetracking._get_and_set_name(client, bufnr, name) if old_name and name ~= old_name then @@ -1823,7 +1823,7 @@ function lsp.buf_attach_client(bufnr, client_id) buffer = bufnr, desc = 'vim.lsp: textDocument/willSave', callback = function(ctx) - for _, client in ipairs(lsp.get_active_clients({ bufnr = ctx.buf })) do + for _, client in ipairs(lsp.get_clients({ bufnr = ctx.buf })) do local params = { textDocument = { uri = uri, @@ -1858,7 +1858,7 @@ function lsp.buf_attach_client(bufnr, client_id) on_lines = text_document_did_change_handler, on_reload = function() local params = { textDocument = { uri = uri } } - for _, client in ipairs(lsp.get_active_clients({ bufnr = bufnr })) do + for _, client in ipairs(lsp.get_clients({ bufnr = bufnr })) do changetracking.reset_buf(client, bufnr) if vim.tbl_get(client.server_capabilities, 'textDocumentSync', 'openClose') then client.notify('textDocument/didClose', params) @@ -1868,7 +1868,7 @@ function lsp.buf_attach_client(bufnr, client_id) end, on_detach = function() local params = { textDocument = { uri = uri } } - for _, client in ipairs(lsp.get_active_clients({ bufnr = bufnr })) do + for _, client in ipairs(lsp.get_clients({ bufnr = bufnr })) do changetracking.reset_buf(client, bufnr) if vim.tbl_get(client.server_capabilities, 'textDocumentSync', 'openClose') then client.notify('textDocument/didClose', params) @@ -1985,7 +1985,7 @@ end --- You can also use the `stop()` function on a |vim.lsp.client| object. --- To stop all clients: --- <pre>lua ---- vim.lsp.stop_client(vim.lsp.get_active_clients()) +--- vim.lsp.stop_client(vim.lsp.get_clients()) --- </pre> --- --- By default asks the server to shutdown, unless stop was requested @@ -2006,7 +2006,7 @@ function lsp.stop_client(client_id, force) end end ----@class vim.lsp.get_active_clients.filter +---@class vim.lsp.get_clients.filter ---@field id integer|nil Match clients by id ---@field bufnr integer|nil match clients attached to the given buffer ---@field name string|nil match clients by name @@ -2014,7 +2014,7 @@ end --- Get active clients. --- ----@param filter vim.lsp.get_active_clients.filter|nil (table|nil) A table with +---@param filter vim.lsp.get_clients.filter|nil (table|nil) A table with --- key-value pairs used to filter the returned clients. --- The available keys are: --- - id (number): Only return clients with the given id @@ -2022,7 +2022,7 @@ end --- - name (string): Only return clients with the given name --- - method (string): Only return clients supporting the given method ---@return lsp.Client[]: List of |vim.lsp.client| objects -function lsp.get_active_clients(filter) +function lsp.get_clients(filter) validate({ filter = { filter, 't', true } }) filter = filter or {} @@ -2045,6 +2045,13 @@ function lsp.get_active_clients(filter) return clients end +---@private +---@deprecated +function lsp.get_active_clients(filter) + -- TODO: add vim.deprecate call after 0.10 is out for removal in 0.12 + return lsp.get_clients(filter) +end + api.nvim_create_autocmd('VimLeavePre', { desc = 'vim.lsp: exit handler', callback = function() @@ -2125,7 +2132,7 @@ function lsp.buf_request(bufnr, method, params, handler) bufnr = resolve_bufnr(bufnr) local method_supported = false - local clients = lsp.get_active_clients({ bufnr = bufnr }) + local clients = lsp.get_clients({ bufnr = bufnr }) local client_request_ids = {} for _, client in ipairs(clients) do if client.supports_method(method, { bufnr = bufnr }) then @@ -2173,7 +2180,7 @@ function lsp.buf_request_all(bufnr, method, params, handler) local expected_result_count = 0 local set_expected_result_count = once(function() - for _, client in ipairs(lsp.get_active_clients({ bufnr = bufnr })) do + for _, client in ipairs(lsp.get_clients({ bufnr = bufnr })) do if client.supports_method(method, { bufnr = bufnr }) then expected_result_count = expected_result_count + 1 end @@ -2240,7 +2247,7 @@ function lsp.buf_notify(bufnr, method, params) method = { method, 's' }, }) local resp = false - for _, client in ipairs(lsp.get_active_clients({ bufnr = bufnr })) do + for _, client in ipairs(lsp.get_clients({ bufnr = bufnr })) do if client.rpc.notify(method, params) then resp = true end @@ -2367,7 +2374,7 @@ function lsp.formatexpr(opts) return 0 end local bufnr = api.nvim_get_current_buf() - for _, client in pairs(lsp.get_active_clients({ bufnr = bufnr })) do + for _, client in pairs(lsp.get_clients({ bufnr = bufnr })) do if client.supports_method('textDocument/rangeFormatting') then local params = util.make_formatting_params() local end_line = vim.fn.getline(end_lnum) --[[@as string]] @@ -2424,10 +2431,10 @@ end --- ---@param bufnr (integer|nil): Buffer handle, or 0 for current ---@return table result is table of (client_id, client) pairs ----@deprecated Use |vim.lsp.get_active_clients()| instead. +---@deprecated Use |vim.lsp.get_clients()| instead. function lsp.buf_get_clients(bufnr) local result = {} - for _, client in ipairs(lsp.get_active_clients({ bufnr = resolve_bufnr(bufnr) })) do + for _, client in ipairs(lsp.get_clients({ bufnr = resolve_bufnr(bufnr) })) do result[client.id] = client end return result @@ -2478,7 +2485,7 @@ end --- vim.print(client) --- end) --- </pre> ----@deprecated use lsp.get_active_clients({ bufnr = bufnr }) with regular loop +---@deprecated use lsp.get_clients({ bufnr = bufnr }) with regular loop function lsp.for_each_buffer_client(bufnr, fn) return for_each_buffer_client(bufnr, fn) end diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index b238b5c221..2140d3ae37 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -197,7 +197,6 @@ end function M.format(options) options = options or {} local bufnr = options.bufnr or api.nvim_get_current_buf() - local mode = api.nvim_get_mode().mode local range = options.range if not range and mode == 'v' or mode == 'V' then @@ -205,7 +204,7 @@ function M.format(options) end local method = range and 'textDocument/rangeFormatting' or 'textDocument/formatting' - local clients = vim.lsp.get_active_clients({ + local clients = vim.lsp.get_clients({ id = options.id, bufnr = bufnr, name = options.name, @@ -271,7 +270,7 @@ end function M.rename(new_name, options) options = options or {} local bufnr = options.bufnr or api.nvim_get_current_buf() - local clients = vim.lsp.get_active_clients({ + local clients = vim.lsp.get_clients({ bufnr = bufnr, name = options.name, -- Clients must at least support rename, prepareRename is optional @@ -468,7 +467,7 @@ end --- function M.list_workspace_folders() local workspace_folders = {} - for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do + for _, client in pairs(vim.lsp.get_clients({ bufnr = 0 })) do for _, folder in pairs(client.workspace_folders or {}) do table.insert(workspace_folders, folder.name) end @@ -493,7 +492,7 @@ function M.add_workspace_folder(workspace_folder) { { uri = vim.uri_from_fname(workspace_folder), name = workspace_folder } }, {} ) - for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do + for _, client in pairs(vim.lsp.get_clients({ bufnr = 0 })) do local found = false for _, folder in pairs(client.workspace_folders or {}) do if folder.name == workspace_folder then @@ -526,7 +525,7 @@ function M.remove_workspace_folder(workspace_folder) { {} }, { { uri = vim.uri_from_fname(workspace_folder), name = workspace_folder } } ) - for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do + for _, client in pairs(vim.lsp.get_clients({ bufnr = 0 })) do for idx, folder in pairs(client.workspace_folders or {}) do if folder.name == workspace_folder then vim.lsp.buf_notify(0, 'workspace/didChangeWorkspaceFolders', params) diff --git a/runtime/lua/vim/lsp/health.lua b/runtime/lua/vim/lsp/health.lua index 8817bb71de..023b1c26be 100644 --- a/runtime/lua/vim/lsp/health.lua +++ b/runtime/lua/vim/lsp/health.lua @@ -28,7 +28,7 @@ function M.check() local report_fn = (log_size / 1000000 > 100 and report_warn or report_info) report_fn(string.format('Log size: %d KB', log_size / 1000)) - local clients = vim.lsp.get_active_clients() + local clients = vim.lsp.get_clients() vim.health.start('vim.lsp: Active Clients') if next(clients) then for _, client in pairs(clients) do diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 8d6f88bb2c..59b9916f64 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -360,7 +360,7 @@ function M.get_progress_messages() local new_messages = {} local progress_remove = {} - for _, client in ipairs(vim.lsp.get_active_clients()) do + for _, client in ipairs(vim.lsp.get_clients()) do local groups = {} for progress in client.progress do local value = progress.value @@ -1347,7 +1347,7 @@ function M.stylize_markdown(bufnr, contents, opts) -- table of fence types to {ft, begin, end} -- when ft is nil, we get the ft from the regex match local matchers = { - block = { nil, '```+([a-zA-Z0-9_]*)', '```+' }, + block = { nil, '```+%s*([a-zA-Z0-9_]*)', '```+' }, pre = { nil, '<pre>([a-z0-9]*)', '</pre>' }, code = { '', '<code>', '</code>' }, text = { 'text', '<text>', '</text>' }, @@ -1841,7 +1841,7 @@ function M.locations_to_items(locations, offset_encoding) 'locations_to_items must be called with valid offset encoding', vim.log.levels.WARN ) - offset_encoding = vim.lsp.get_active_clients({ bufnr = 0 })[1].offset_encoding + offset_encoding = vim.lsp.get_clients({ bufnr = 0 })[1].offset_encoding end local items = {} @@ -2036,7 +2036,7 @@ function M._get_offset_encoding(bufnr) local offset_encoding - for _, client in pairs(vim.lsp.get_active_clients({ bufnr = bufnr })) do + for _, client in pairs(vim.lsp.get_clients({ bufnr = bufnr })) do if client.offset_encoding == nil then vim.notify_once( string.format( @@ -2183,7 +2183,7 @@ function M.character_offset(buf, row, col, offset_encoding) 'character_offset must be called with valid offset encoding', vim.log.levels.WARN ) - offset_encoding = vim.lsp.get_active_clients({ bufnr = buf })[1].offset_encoding + offset_encoding = vim.lsp.get_clients({ bufnr = buf })[1].offset_encoding end -- If the col is past the EOL, use the line length. if col > #line then |