aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp
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)
* 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): 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
|
* fix(diagnostic): support severity_sortGregory Anders2021-09-17
|
* fix(diagnostic): correctly handle folder level diagnosticsGregory 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): 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: 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
* 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
* | feat(lsp): get_border_size(): support repeating border char list #15474zeertzjq2021-08-27
|/
* 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.
* feat(lsp): jump to diagnostics by position (#14795)Zi How Poh2021-08-19
|
* fix(lsp): properly handle `nil` lines when trimming empty lines (#15325)Andrea Cappuccio2021-08-10
|
* fix(lsp): floating popup should take offset_x into account when positioning ↵Hans Pinckaers2021-08-09
| | | | (#15297)
* docs: Add some references to LSP specification (#15321)max3975742021-08-09
|
* fix(lsp): prevent duplicate lines seperated by newlines (#15284)Folke Lemaitre2021-08-06
|
* refactor: remove remaining references to nvim_buf_set_virtual_textGregory Anders2021-08-03
|
* fix(lsp): Include client name in handler error messages (#15227)Mathias Fußenegger2021-07-31
| | | Makes it easier to tell with language server caused an error.
* feat(lsp): implement vim.lsp.diagnostic.redraw() (#15203)Gregory Anders2021-07-29
| | | | | | | | | | | | | Add a new function to redraw diagnostics from the current diagnostic cache, without receiving a "publishDiagnostics" message from the server. This is already being done in two places in the Lua stdlib, so this function unifies that functionality in addition to providing it to third party plugins. An example use case for this could be a command or key-binding for toggling diagnostics virtual text. The virtual text configuration option can be toggled using `vim.lsp.with` followed by `vim.lsp.diagnostic.redraw()` to immediately redraw the diagnostics with the updated setting.
* feat(lsp): make list handlers configurable (#15199)Gregory Anders2021-07-26
| | | | | | | | | | | | The handlers for textDocument/references, textDocument/documentSymbol, and workspace/symbol open their results in the quickfix list by default and are not configurable. They are also incompatible with `vim.lsp.with` as they do not accept a configuration parameter. Add a `config` parameter to the handler for these three messages which allows them to be configured with `vim.lsp.with`. Additionally, add a new configuration option 'loclist' that, when true, causes these handlers to open their results in the location list rather than the quickfix list.
* lsp: add vim.lsp.diagnostic.set_qflist() function (#14831)Marc Jakobi2021-07-22
| | | | * Add vim.lsp.diagnostic.set_qflist() function * replaces opts.open_loclist with unified opts.open
* fix(lsp): allow diagnostic.clear to accept nil bufnr (#15137)Gregory Anders2021-07-19
| | | | | | | Passing `nil` is equivalent to passing 0, i.e. it simply uses the current buffer number. This fixes a bug when vim.lsp.diagnostic.disable() is called without arguments.
* feat(lsp): allow diagnostics to be disabled for a buffer (#15134)Gregory Anders2021-07-19
| | | | | | | | | | | | | | | Add two new methods to allow diagnostics to be disabled (and re-enabled) in the current buffer. When diagnostics are disabled they are simply not displayed to the user, but they are still sent by the server and processed by the client. Disabling diagnostics can be helpful in a number of scenarios. For example, if one is working on a buffer with an overwhelming amount of diagnostic warnings it can be helpful to simply disable diagnostics without disabling the LSP client entirely. This also allows users more flexibility on when and how they may want diagnostic information to be displayed. For example, some users may not want to display diagnostic information until after the buffer is first written.
* feat(lsp): allow configuring zindex for floating windows (#15086)rayx2021-07-19
|
* feat: aggregate code actions from all clients (#15121)Folke Lemaitre2021-07-18
|
* doc(lsp): various small fixes (#15113)Ido Ariel2021-07-17
| | | | | | - remove incorrect usage of docstrings - fix make_formatting_params return type documentation to 'DocumentFormattingParams' - make progress_handler private - fix links
* fix(lsp): pass bufnr for async formatting (#15084)Michael Lingelbach2021-07-14
| | | | | | the `textDocument/rangeFormatting` nad `textDocument/formatting` did not pass bufnr to apply_text_edits, meaning edits were applied to the user's currently active buffer. This could result in text being applied to the wrong buffer.
* fix(lsp): avoid ipairs on non-sequential tables (#15059)Michael Lingelbach2021-07-11
| | | | | | | | | | | | | | | | | | | | ipairs terminates on the first nil index when iterating over table keys: for i,k in ipairs( {[1] = 'test', [3] = 'test'} ) do print(i, k) end prints: 1 test Instead, use pairs which continues iterating over the entire table: for i,k in pairs( {[1] = 'test', [3] = 'test'} ) do print(i, k) end prints: 1 test 3 test
* fix(lsp): Ensure human readable errors are printedMathias Fussenegger2021-07-11
| | | | | | | | | | `return err_message(tostring(err))` caused errors to be printed as `table: 0x123456789` instead of showing the error code and error message. This also removes some `if err` blocks that never got called because at the end of `handlers.lua` all the handlers are wrapped with logic that adds generic error handling.
* fix(lsp): Ensure users get feedback on references/symbols errors or empty ↵Mathias Fussenegger2021-07-11
| | | | | | | | | results Relates to https://github.com/neovim/neovim/issues/15050 Users should get some indication if there was an error or an empty result.
* fix(lsp): Add separator between codelens in virttext (#15049)Mathias Fußenegger2021-07-10
| | | | | | | | | | | | Before: Lens1Lens2 After: Lens1 | Lens2 Fixes https://github.com/neovim/neovim/issues/15048
* fix(lsp): correctly check for windows in lsp logger (#14954)Oliver Marriott2021-07-10
|
* feat(lsp): Make line diagnostics display prettierMathias Fussenegger2021-07-09
| | | | | | | | | | | | | | | | | | | | | | | | | Adds indentation that matches the number prefix to ensure diagnostic messages spawning multiple lines align. Before: Diagnostics: 1. • Variable not in scope: red :: t0 -> t • Perhaps you meant one of these: ‘rem’ (imported from Prelude), ‘read’ (imported from Prelude), ‘pred’ (imported from Prelude) 2. • Variable not in scope: repeDoubleColon :: [Char] -> t0 • Perhaps you meant ‘replaceDoubleColon’ (line 32) After: Diagnostics: 1. • Variable not in scope: red :: t0 -> t • Perhaps you meant one of these: ‘rem’ (imported from Prelude), ‘read’ (imported from Prelude), ‘pred’ (imported from Prelude) 2. • Variable not in scope: repeDoubleColon :: [Char] -> t0 • Perhaps you meant ‘replaceDoubleColon’ (line 32)