aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
Commit message (Collapse)AuthorAge
* fix(diagnostic): preserve fields from LSP diagnostics via user_data (#15735)masterGregory Anders2021-09-21
| | | * preserve fields from LSP diagnostics via adding a user_data table to the diagnostic, which can hold arbitrary data in addition to the lsp diagnostic information.
* fix(lsp): update lsp-handler signature in call_hierarchy (#15738)Mathias Fußenegger2021-09-21
| | | | | | | | This fixes the handler signature and also prevents n+1 requests firing if there are multiple clients. (The first `prepareCallHierarchy` handler is called once per client, each invocation used `buf_request` to make more requests using *all* clients)
* fix(diagnostic): clamp line numbers in display layer (#15729)Gregory Anders2021-09-20
| | | | | | Some parts of LSP need to use cached diagnostics as sent from the LSP server unmodified. Rather than fixing invalid line numbers when diagnostics are first set, fix them when they are displayed to the user (e.g. in show() or one of the get_next/get_prev family of functions).
* feat(diagnostic): match(), tolist(), fromlist() #15704Gregory Anders2021-09-19
| | | | | | * feat(diagnostic): add vim.diagnostic.match() Provide vim.diagnostic.match() to generate a diagnostic from a string and a Lua pattern. * feat(diagnostic): add tolist() and fromlist()
* fix(diagnostic): only update decorations for loaded buffers (#15715)Gregory Anders2021-09-18
| | | | | When vim.diagnostic.config() is called, the decorations for diagnostics are re-displayed to use the new configuration. This should only be done for loaded buffers.
* feat(lsp): improve vim.lsp.util.apply_text_edits (#15561)hrsh7th2021-09-18
| | | | | - Fix the cursor position after applying TextEdits - Support reversed range of TextEdit - Invoke nvim_buf_set_text one by one
* fix(diagnostic): resolve nil bufnr in show_line_diagnosticsGregory Anders2021-09-18
|
* fix(diagnostic): remove check on nil return valueGregory Anders2021-09-17
| | | | | vim.diagnostic._set_signs doesn't return anything, so checking the return value will always fail.
* refactor(diagnostic): combine config() and set() callsGregory Anders2021-09-17
|
* refactor(diagnostic): group local functions togetherGregory Anders2021-09-17
|
* fix(diagnostic): change default severity_sort orderGregory Anders2021-09-17
| | | | | | | When severity_sort is true, higher severities should be displayed before lower severities (e.g. ERROR is displayed over WARN). Also improved the test case for this.
* fix(diagnostic): support severity_sortGregory Anders2021-09-17
|
* fix(diagnostic): correctly handle folder level diagnosticsGregory Anders2021-09-17
|
* docs(diagnostics): fix typosGregory Anders2021-09-17
|
* fix(diagnostic): fix wrong data type in setqflist()Gregory Anders2021-09-17
|
* fix(diagnostic): don't overwrite existing sign definitionsGregory Anders2021-09-17
|
* fix(diagnostic): don't convert diagnostic table twiceChristian Clason2021-09-17
| | | | | | | | The recursive implementation of vim.lsp.diagnostic.get() applied `diagnostic_vim_to_lsp` twice, and the second time gave wrong results because of the unexpected format. Fixes https://github.com/neovim/neovim/issues/15689
* fix(diagnostic): show_line_diagnostic with empty lnumChristian Clason2021-09-17
| | | | | | | The documentation claims to default to the current line number if the argument `lnum` is nil, but that was never actually done. Fixes https://github.com/neovim/neovim/issues/15690
* fix(diagnostic): nvim_echo takes three args (#15687)Christian Clason2021-09-17
| | | | Fixup for https://github.com/neovim/neovim/pull/15585 Closes https://github.com/neovim/neovim/issues/15686
* fix(diagnostic): remove useless highlight links (#15683)Gregory Anders2021-09-17
| | | | | | | | | | | | | | | | | | These links were actually defined backwards: the highlight groups actually being used for display are the new "Diagnostic*" groups, so linking the old "LspDiagnostics*" groups to these does absolutely nothing, since there is nothing actually being highlighted with the LspDiagnostics* groups. These links were made in an attempt to preserve backward compatibility with existing colorschemes. We could reverse the links to maintain this preservation, but then that disallows us from actually defining default values for the new highlight groups. Instead, just remove the links and be done with the old LspDiagnostics* highlight groups. This is not technically a breaking change: the breaking change already happened in #15585, but this PR just makes that explicit.
* Merge #15585 refactor: move vim.lsp.diagnostic to vim.diagnosticJustin M. Keyes2021-09-16
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## Overview - Move vim.lsp.diagnostic to vim.diagnostic - Refactor client ids to diagnostic namespaces - Update tests - Write/update documentation and function signatures Currently, non-LSP diagnostics in Neovim must hook into the LSP subsystem. This is what e.g. null-ls and nvim-lint do. This is necessary because none of the diagnostic API is exposed separately from the LSP subsystem. This commit addresses this by generalizing the diagnostic subsystem beyond the scope of LSP. The `vim.lsp.diagnostic` module is now simply a specific diagnostic producer and primarily maintains the interface between LSP clients and the broader diagnostic API. The current diagnostic API uses "client ids" which only makes sense in the context of LSP. We replace "client ids" with standard API namespaces generated from `nvim_create_namespace`. This PR is *mostly* backward compatible (so long as plugins are only using the publicly documented API): LSP diagnostics will continue to work as usual, as will pseudo-LSP clients like null-ls and nvim-lint. However, the latter can now use the new interface, which looks something like this: ```lua -- The namespace *must* be given a name. Anonymous namespaces will not work with diagnostics local ns = vim.api.nvim_create_namespace("foo") -- Generate diagnostics local diagnostics = generate_diagnostics() -- Set diagnostics for the current buffer vim.diagnostic.set(ns, diagnostics, bufnr) ``` Some public facing API utility methods were removed and internalized directly in `vim.diagnostic`: * `vim.lsp.util.diagnostics_to_items` ## API Design `vim.diagnostic` contains most of the same API as `vim.lsp.diagnostic` with `client_id` simply replaced with `namespace`, with some differences: * Generally speaking, functions that modify or add diagnostics require a namespace as their first argument, e.g. ```lua vim.diagnostic.set({namespace}, {bufnr}, {diagnostics}[, {opts}]) ``` while functions that read or query diagnostics do not (although in many cases one may be supplied optionally): ```lua vim.diagnostic.get({bufnr}[, {namespace}]) ``` * We use our own severity levels to decouple `vim.diagnostic` from LSP. These are designed similarly to `vim.log.levels` and currently include: ```lua vim.diagnostic.severity.ERROR vim.diagnostic.severity.WARN vim.diagnostic.severity.INFO vim.diagnostic.severity.HINT ``` In practice, these match the LSP diagnostic severity levels exactly, but we should treat this as an interface and not assume that they are the same. The "translation" between the two severity types is handled transparently in `vim.lsp.diagnostic`. * The actual "diagnostic" data structure is: (**EDIT:** Updated 2021-09-09): ```lua { lnum = <number>, col = <number>, end_lnum = <number>, end_col = <number>, severity = <vim.diagnostic.severity>, message = <string> } ``` This differs from the LSP definition of a diagnostic, so we transform them in the handler functions in vim.lsp.diagnostic. ## Configuration The `vim.lsp.with` paradigm still works for configuring how LSP diagnostics are displayed, but this is a specific use-case for the `publishDiagnostics` handler. Configuration with `vim.diagnostic` is instead done with the `vim.diagnostic.config` function: ```lua vim.diagnostic.config({ virtual_text = true, signs = false, underline = true, update_in_insert = true, severity_sort = false, }[, namespace]) ``` (or alternatively passed directly to `set()` or `show()`.) When the `namespace` argument is `nil`, settings are set globally (i.e. for *all* diagnostic namespaces). This is what user's will typically use for their local configuration. Diagnostic producers can also set configuration options for their specific namespace, although this is generally discouraged in order to respect the user's global settings. All of the values in the table passed to `vim.diagnostic.config()` are resolved in the same way that they are in `on_publish_diagnostics`; that is, the value can be a boolean, a table, or a function: ```lua vim.diagnostic.config({ virtual_text = function(namespace, bufnr) -- Only enable virtual text in buffer 3 return bufnr == 3 end, }) ``` ## Misc Notes * `vim.diagnostic` currently depends on `vim.lsp.util` for floating window previews. I think this is okay for now, although ideally we'd want to decouple these completely.
| * fix(lint): remove unused parameters from deprecated functionsGregory Anders2021-09-16
| |
| * refactor: remove UTF to byte col conversionGregory Anders2021-09-16
| |
| * refactor: move vim.lsp.diagnostic to vim.diagnosticGregory Anders2021-09-15
| | | | | | | | | | | | | | | | | | | | | | This generalizes diagnostic handling outside of just the scope of LSP. LSP clients are now a specific case of a diagnostic producer, but the diagnostic subsystem is decoupled from the LSP subsystem (or will be, eventually). More discussion at [1]. [1]: https://github.com/neovim/neovim/pull/15585
* | feat(lsp): improve logging (#15636)Michael Lingelbach2021-09-15
|/ | | | | | | * Simplify rpc encode/decode messages to rpc.send/rcp.receive * Make missing handlers message throw a warning * Clean up formatting style in log * Move all non-RPC loop messages to trace instead of debug * Add format func option to log to allow newlines in per log entry
* fix(lsp): correctly parse LSP snippets #15579hrsh7th2021-09-14
| | | Fixes #15522
* docs #15625Justin M. Keyes2021-09-10
| | | | | | | | | | | fix #12261 fix #15536 fix #15623 fix #15572 ref #14244 ref #15034 close #15555 close #14957
* perf(lua): optimize vim.deep_equal #15236Javier Lopez2021-09-10
| | | | By remembering the keys already compared in repeating a comparison is avoided. Thanks: https://stackoverflow.com/a/32660766
* feat(lsp): support textDocument/prepareRename (#15514)Zi How Poh2021-09-08
|
* chore(lsp): fix formatting in vim.lsp.log (#15596)Michael Lingelbach2021-09-07
|
* feat(lsp): add warning message for large log sizeMichael Lingelbach2021-09-07
|
* feat(lsp): add lsp healthcheckMichael Lingelbach2021-09-07
| | | | | Add healthcheck for language server client, currently only checks logging status.
* fix(lsp): adapt codelens resolve to handler signature change (#15578)Mathias Fußenegger2021-09-06
| | | Follow up to https://github.com/neovim/neovim/pull/15504
* fix(lsp): update workspace/applyEdit handler signature (#15573)Jose Alvarez2021-09-05
|
* Merge pull request #15504 from mjlbach/feat/change-handler-signatureMichael Lingelbach2021-09-05
|\ | | | | feat(lsp)!: change handler signature
| * feat(lsp)!: change handler signatureMichael Lingelbach2021-09-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the handler signature was: function(err, method, params, client_id, bufnr, config) In order to better support external plugins that wish to extend the protocol, there is other information which would be advantageous to forward to the client, such as the original params of the request that generated the callback. In order to do this, we would need to break symmetry of the handlers, to add an additional "params" as the 7th argument. Instead, this PR changes the signature of the handlers to: function(err, result, ctx, config) where ctx (the context) includes params, client_id, and bufnr. This also leaves flexibility for future use-cases. BREAKING_CHANGE: changes the signature of the built-in client handlers, requiring updating handler calls
* | docs(lsp): remove private lsp.diagnostic functions from docs (#15541)Mathias Fußenegger2021-09-01
| | | | | | | | Both `apply_to_diagnostic_items` and `show_diagnostics` are local functions and cannot be called by users.
* | docs(lsp): document codelens.get bufnr parameter (#15540)Mathias Fußenegger2021-09-01
| | | | | | Alternative to https://github.com/neovim/neovim/pull/15224
* | fix(lsp): resolve bufnr in buf_is_attached (#15523)Jose Alvarez2021-08-30
| |
* | fix(lua): preserve argument lists which are not listsBjörn Linse2021-08-29
| |
* | fix(lsp): check if buffer is valid in changetracking (#15505)Jose Alvarez2021-08-28
| |
* | feat(lsp): get_border_size(): support repeating border char list #15474zeertzjq2021-08-27
| |
* | fix(lua): verify buffer in highlight.on_yank (#15482)notomo2021-08-26
| | | | | | | | | | Resolve an issue with deferred clearing of highlight failing if the buffer is deleted before the timeout by checking whether the buffer is valid first.
* | Merge pull request #15466 from vigoux/ts-query-autoThomas Vigouroux2021-08-24
|\ \ | |/ |/| feat(ts): add query module in treesitter keys
| * feat(ts): add query module in treesitter keysThomas Vigouroux2021-08-23
| |
* | fix(lsp): enable additional capabilities (#15470)Michael Lingelbach2021-08-23
|/ | | | | | | Declaration, type-definition, and implementation capabilities were previously disabled if the client received table output from the server capabilities. The workDoneProgress capability is sent for many servers for all supported capabilities as part of this table. Default to setting capability to table instead of false.
* docs: make Lua docstrings consistent #15255Gregory Anders2021-08-22
| | | | | | | | | | | | The official developer documentation in in :h dev-lua-doc specifies to use "--@" for special/magic tokens. However, this format is not consistent with EmmyLua notation (used by some Lua language servers) nor with the C version of the magic docstring tokens which use three comment characters. Further, the code base is currently split between usage of "--@", "---@", and "--- @". In an effort to remain consistent, change all Lua magic tokens to use "---@" and update the developer documentation accordingly.
* Merge pull request #15429 from bfredl/hl_2Björn Linse2021-08-19
|\ | | | | perf(treesitter): avoid string lookup of highlight name in hot loop
| * perf(treesitter): avoid string lookup of highlight name in hot loopBjörn Linse2021-08-19
| | | | | | | | | | These numbers are guaranteed to be stable even if you do "highlight clear" (all attributes disappear, but not the id to name mapping itself)
* | feat(lsp): allow root_dir to be nil (#15430)Mathias Fußenegger2021-08-19
| | | | | | | | | | | | | | | | According to the protocol definition `rootPath`, `rootUri` and `workspaceFolders` are allowed to be null. Some language servers utilize this to provide "single file" support. If all three are null, they don't attempt to index a directory but instead only provide capabilities for a single file.