aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp.lua
Commit message (Collapse)AuthorAge
...
* fix(lsp): send buffer contents joined on fileformat-specific linebreak (#16334)Dmytro Meleshko2021-11-21
|
* chore(lsp): clean up initialization process (#16369)Michael Lingelbach2021-11-21
| | | | | * send vim.NIL instead of not sending workspaceFolders * read fallback rootPath and rootUri from workspaceFolders * update documentation
* docs: mark tagfunc.lua methods as privateGregory Anders2021-11-18
|
* feat(lsp): add tagfunc (#16103)Michael Lingelbach2021-11-18
|
* fix(lsp): ensure buffers are re-attached on rename (#16266)Mathias Fußenegger2021-11-14
| | | | | | | | | If a LSP server sent a workspace edit containing a rename the buffers file name changed without the server receiving a close notification for the old buffer and without the client properly re-attaching on the new file. This affected `Move` code-actions in nvim-jdtls, but also `vim.lsp.buf.rename` on a class level.
* fix(lsp): rewrite incremental sync (#16252)Michael Lingelbach2021-11-09
| | | | | | * use codeunits/points instead of byte ranges when applicable * take into account different file formats when computing range and sending text (dos, unix, and mac supported) * add tests of incremental sync
* docs(lsp): correct usage examples of formatexpr (#16216)Michael Lingelbach2021-11-02
|
* feat(lsp): add per-client commands (#16101)Michael Lingelbach2021-11-01
|
* fix(lsp): don't update active_clients on exit_timeout (#16192)David Hotham2021-10-31
|
* feat(lsp): add formatexpr (#16186)Michael Lingelbach2021-10-31
| | | | Co-authored-by: Meck <yesmeck@gmail.com> Co-authored-by: TJ DeVries <devries.timothyj@gmail.com>
* fix(lsp): add placeholder cancel function (#16189)Michael Lingelbach2021-10-31
| | | | | | | | | | Fixes a bug introduced by https://github.com/neovim/neovim/pull/15949 When no supported clients for a given method are available, buf_request returns early with a nil value. If buf_request_sync is called on a buffer with no clients that support a given method, the returned `cancel` method (which is nil), is invoked, resulting in an error. Solution: return an empty function handle
* feat(lsp): track pending+cancel requests on client object #15949jdrouhard2021-10-29
|
* feat(lsp): add exit_timeout flag (#16070)Michael Lingelbach2021-10-21
| | | | | | | * This flag allows customizing the time before sending kill -15 to the server. If set to false, neovim exits immediately after sending request('shutdown'). Otherwise, polls until all servers have shutdown, and then kills remaining servers via kill -15 at exit_timeout duration. Defaults to 500 ms.
* fix(lsp): avoid duplicates in client attached buffers (#16099)Michael Lingelbach2021-10-20
| | | | | | | closes https://github.com/neovim/neovim/issues/16058 * add client.attached_buffers * only update client.attached_buffers in on_attach * use table instead of list for attached_buffers to avoid duplication
* fix(gen_vimdoc.py): spacing around inline elements #16092Gregory Anders2021-10-19
| | | | | The spacing fix drew attention to a couple of places that were using incorrect formatting such as the key listing for `nvim_open_win`, so those were fixed too.
* fix(lsp): maintain client_ids table structure when filtering (#15991)Jose Alvarez2021-10-11
|
* fix(lsp): do not invoke handlers for unsupported methods (#15926)Michael Lingelbach2021-10-10
| | | | | | | Closes https://github.com/neovim/neovim/issues/15174 Instead of invoking handlers with unsupported methods, pre-compute which clients support a given method and only notify the user if no clients support the given method.
* fix(lsp): add textDocument/prepareRename to capability map (#15961)francisco souza2021-10-08
| | | | | | | | | | This is a simple fix for #15899, as it should at least stop calling `prepareRename` on servers that don't support renaming. I imagine a better fix would be to inspect the actual value for, but that requires some plumbing changes on how capabilities are evaluated before sending requests out. Co-authored-by: francisco souza <fsouza@users.noreply.github.com>
* feat(lsp): utilize textEdit.range for startbyte in omnifunc (#15957)Mathias Fußenegger2021-10-08
| | | Closes https://github.com/neovim/neovim/issues/15784
* feat(lsp): use cjson for lsp rpc (#15759)Michael Lingelbach2021-09-26
|
* feat(lsp): add a registry for client side code action commandsMathias Fussenegger2021-09-20
| | | | | This builds on https://github.com/neovim/neovim/pull/14112 and closes https://github.com/neovim/neovim/issues/12326
* feat(lsp): include original request params in handler ctxMathias Fussenegger2021-09-20
| | | | | | | | | | | This is mostly motivated by https://github.com/neovim/neovim/issues/12326 Client side commands might need to access the original request parameters. Currently this is already possible by using closures with `vim.lsp.buf_request`, but the global handlers so far couldn't access the request parameters.
* 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.
| * 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
* 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
* | fix(lsp): resolve bufnr in buf_is_attached (#15523)Jose Alvarez2021-08-30
| |
* | fix(lsp): check if buffer is valid in changetracking (#15505)Jose Alvarez2021-08-28
|/
* 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): 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.
* docs(lsp): prevent internal comments from showing as vim.lsp.init docsMathias Fussenegger2021-08-16
|
* 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.
* lsp(start_client): Allow passing custom workspaceFolders to the LSP (#15132)sim2021-07-20
| | | | | | | | | | | | | | Some language servers *cough*rust-analyzer*cough* need an empty/custom workspaceFolders for certain usecases. For example, rust-analyzer needs an empty workspaceFolders table for standalone file support (See https://github.com/rust-analyzer/rust-analyzer/pull/8955). This can also be useful for other languages that need to commonly open a certain directory (like flutter or lua), which would help prevent spinning up a new language server altogether. In case no workspaceFolders are passed, we fallback to what we had before.
* feat(lsp): Add codelens supportMathias Fussenegger2021-06-14
|
* fix(lsp): check mode in omnifunc callbackJose Alvarez2021-06-01
|
* Increase default LSP sync timeout to 1000msKarim Abou Zeid2021-05-02
|
* Add client.request_sync docKarim Abou Zeid2021-05-02
|
* doc clarificationKarim Abou Zeid2021-05-02
|
* Add formatting_seq_sync, change formatting and formatting_syncKarim Abou Zeid2021-05-01
|
* Merge pull request #14429 from ckipp01/forceMichael Lingelbach2021-04-23
|\ | | | | [LSP] - Don't automatically force shutdown on second restart.
| * Don't automatically force shutdown on second restart.ckipp012021-04-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is maybe a bit of a niche case, but I hit on this often as I'm developing a server, and therefore continually restarting it to get the latest changes of the server. Previously, I could only do this once since if you send in a request to restart/shut down the server, it will register it as a `tried_graceful_shutdown = true` meaning that the next restart would force it to be killed instead of another graceful exit. Instead, this changes the name a bit and now it will only mark `graceful_shutdown_failed = true` _if_ it actually fails to gracefully shutdown. This change allows for a user to restart multiple times in a situation like mine where nothing is going wrong, but I just want to restart continually as I'm developing without having to close and reopen.
* | Revert "lsp: fix blocking in closing of clients"Michael Lingelbach2021-04-23
|/ | | | | | | | This reverts commit 2e6c09838f88803f31d229002715628639631897. * Fixes #14428 * This commit caused neovim to close while open handles to the uv timer to kill active language servers were still open
* Merge pull request #14180 from oberblastmeister/lsp_exit_perfMichael Lingelbach2021-04-19
|\ | | | | fix slow closing of lsp clients when exiting vim
| * lsp: fix blocking in closing of clientsBrian Shu2021-04-19
| |
* | lsp: add lsp.buf_request_all for invoking asynchronous callbacksBrian Shu2021-04-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | fixed nil issue changed poll to 10 changed wording added docs to once comma english
* | lsp: Add a flag to debounce didChange notificationsMathias Fussenegger2021-04-13
| | | | | | | | Would help with cases as reported in https://github.com/neovim/neovim/issues/14087
* | Merge pull request #14264 from mjlbach/feature/handle_reloading_bufferMichael Lingelbach2021-04-01
|\ \ | | | | | | lsp: add on_reload callback for buffer edits outside of neovim
| * | lsp: add on_reload callback for buffer edits outside of neovimMichael Lingelbach2021-03-31
| | |
* | | Merge pull request #14262 from mjlbach/feature/lsp_did_save_autocommandMichael Lingelbach2021-04-01
|\ \ \ | | | | | | | | lsp: clear did_save handler autocommand on each attach