aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/inlay_hint.lua
Commit message (Collapse)AuthorAge
* fix(lua): enable unnecessary-assert diagnosticLewis Russell2026-09-28
| | | | AI-assisted
* fix(lua): add missing param annotations (#41911)Lewis Russell2026-09-15
|
* build: replace LuaLS with EmmyLuaLewis Russell2026-09-07
| | | | | | | | | | | | | | | Problem: LuaLS struggles with the generics used in Nvim's runtime, requiring broad diagnostic suppressions. Indexing is also slow. Solution: Use EmmyLua for type checks in the build and CI. It offers more sophisticated type checking, substantially better support for generics, and much better flow analysis. Correct the affected annotations. Use `@internal`, supported directly by EmmyLua, instead of `@nodoc` for shared internal declarations, and support it in the help parser. AI-assisted
* refactor(lsp): unify LspNotify, decor provider for capabilities #40691jdrouhard2026-07-15
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: Every LSP capability that sends a request on a document change to update its state was using its own buffer-local autocmd to do so. That means there is a separate autocmd per buffer per active capability/feature, and the actual code inside the autocmd callback was virtually identical. The same problem occurred for capabilities that had components to draw on the screen that had their own decoration providers. Solution: Introduce a central `LspNotify` autocmd and decoration provider in the capability module itself. New base class methods `on_close` and `on_change` that take a client_id have been provided, for `didClose` and `didOpen`/`didChange` notifications respectively. New base class method `on_win` that takes topline and botline has been provided to add extmarks or perform other work when lines of a buffer are being drawn. The autocmd callback loops through each active capability instance for the buffer and calls a corresponding method with the triggering client_id if it is currently attached to the buffer that triggered the autocmd. The decoration provider just calls on_win for all active capabilities on the buffer. This slightly tweaks folding range to make use of these new client-id specific callbacks.
* refactor(lsp): use LspNotify for codelens #40604jdrouhard2026-07-07
| | | | | | | | | | | | | | | | | | | | | Problem: The codelens LSP module was using its own raw buffer events and its own debounce mechanism for refreshing code lens in attached buffers. Solution: Switch the module to using the LspNotify autocmd events. LspNotify fires just after document versions are synced with the server and provides a built in debounce mechanism for changes. Additionally, this fixes some bugs with the previous implementation: 1. The workspace/codeLens/refresh handler re-requested codelens for all buffers but when the response came back, it forced an extra redraw after clearing the work the handler had just done. 2. Document synchronization was reworked to be more resilient to multiple clients providing codelens for a single buffer. The latest document version is now separately tracked per client (and per client's lenses per row) instead of for the buffer as a whole. This allows the on_win() function to properly redraw all codelens even when different clients' responses for a particular document version come back at different times.
* feat(lsp): convert inlay_hint to capability framework #40569jdrouhard2026-07-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Inlay hints used separate global and per-buffer bufstates tables and bespoke global autocmds for managing the inlay hint state across buffers and clients, duplicating the lifecycle logic already provided by the Capability framework. This caused inconsistencies in how client state was handled and inlay hint state lifecycle was managed compared to other LSP features. Solution: Replace the ad-hoc bufstate tracking and global autocmds in vim.lsp.inlay_hint with a proper InlayHint subclass of Capability. This also refactors the way inlay hint state is managed and fixes bugs I found while doing this: 1. For each line with inlay hints, the list of the hints along with whether they have been applied is stored in a current result on the client state. This allows the on_win decorator to clear all inlay hints for an old document version once, and then re-add the new version's hints line-by-line as they are drawn to the screen, modeling the semantic tokens module. 2. It fixes problems with mixing results from multiple clients attached to the buffer by fully moving each client's state to its own table. Previously, only the most recent document version used to populate a line's inlay hints was stored, but there was no distinction for which client the hints may have come from. (Fixes #36318) 3. It fixes the workspace/inlayHint/refresh server->client notification behavior. Previously it would only re-request inlay hints for buffers currently displayed in a window but would not invalidate them in non-displayed buffers (or provide any mechanism for those buffers to re-request at a later time). Model semantic token module here again by invalidating all buffers, and adding a BufWinEnter autocmd to refresh hints. 4. Add a mechanism to cancel in-flight requests if a new request for a newer document version is made before the last one returned 5. Handle stale results by simply dropping them.
* refactor: introduce nvim_on internally #39883Justin M. Keyes2026-05-20
| | | | | | | | | Problem: `nvim_create_autocmd` is too verbose and its `callback` requires extra "nesting". Solution: Introduce `nvim_on`. Start using it internally. Then we can get a feel for how it should look before making it public.
* refactor(lsp): remove some private utility functionsYi Ming2026-05-16
| | | | | | | | | Problem: `make_position_params`/`get_line_byte_from_position`/`make_line_range_params` are private functions and their functionality can be replaced by `vim.pos` now. Solution: Remove them, use `vim.pos` instead.
* refactor(lsp): remove implicit rpc error tostring #38707Yi Ming2026-04-02
| | | | | | | | | | | | | | | | | | Problem: LSP error responses implicitly rely on a custom `__tostring` function (`vim.lsp.rpc.format_rpc_error`) for formatting. This causes errors that are not created via `vim.lsp.rpc.error` to behave inconsistently with those that are. Furthermore, we usually use `log.error` to print these errors, which uses `vim.inspect` under the hood, so the custom `__tostring` provides little benefit. This increases the difficulty of refactoring the code, as it tightly couples RPC error handling with the LSP. Solution: Convert every potential `__tostring` call to an explicit one. Since we don't describe this behavior in the documentation, this should not be a breaking change.
* fix(lsp): unify LSP error logging prefixes #38354Yi Ming2026-03-20
| | | | | | | Problem The format of LSP log messages is inconsistent; some include underscores, while others are not logged at all. Solution Standardize log recording and unify the log message prefixes with the module names.
* docs: use "ev" convention in event-handlersJustin M. Keyes2026-03-12
| | | | | | | | | Problem: In autocmd examples, using "args" as the event-object name is vague and may be confused with a user-command. Solution: Use "ev" as the conventional event-object name.
* fix(lsp): correct iteration through attached buffers (#36517)Maria Solano2025-11-10
|
* fix(lsp): deprecate `vim.lsp.get_buffers_by_client_id` (#36449)Maria Solano2025-11-10
|
* fix(lsp): deprecate `vim.lsp.protocol.Methods` (#35998)Maria Solano2025-10-04
|
* refactor(lua): consistent use of local aliasesChristian Clason2025-08-28
|
* fix(lsp): treat nil inlay hint result as empty array (#35458)Maria José Solano2025-08-24
| | | | | | | `gopls` seems to send a nil result when there are no inlay hints for the buffer. [The protocol](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_inlayHint) allows for the server to send an array or nil, and it isn't clear what nil should represent. I think it's reasonable to treat it as an empty array though.
* refactor(lsp): drop vim.lsp.util._refresh() #33903Yi Ming2025-07-12
| | | | | | | | | | | | | | | Problem: - util._refresh() is only used by `inlay_hint.lua` and `document_color.lua`, and both have their own wrapper functions; - util._refresh() provides unified parameters, but this layer of wrapping is almost meaningless because - document color does not need the range parameter; - inlay hint requires a range parameter, but it is not complicated Therefore, it can be considered redundant. ref https://github.com/neovim/neovim/pull/32887#discussion_r1996413602 Solution: Remove it.
* fix: type fixesLewis Russell2025-06-06
| | | | Type fixes caught by emmylua
* refactor(docs): remove unnecessary `@private`/`@nodoc` annotations (#33951)Maria José Solano2025-05-10
| | | | | * refactor(docs): remove `@private` annotations from local functions * refactor(docs): remove unnecessary `@nodoc` annotations
* fix(vim.lsp.inlay_hint): requesting inlay_hints even when disabled #32999Bartłomiej Maryńczak2025-03-30
| | | | | | | | Problem: Nvim needlessly requests inlay_hints even if they are disabled for a given buffer. Solution: Add the missing `enabled` check in `on_refresh`. Rest of the code has this check already so that's the only needed one to fix this.
* fix(lsp): reset the applied hints on `refresh` request #32446Yi Ming2025-02-23
|
* refactor: use nvim.foo.bar format for autocommand groupsMaria José Solano2025-01-14
|
* refactor: use nvim.foo.bar format for namespacesMaria José Solano2025-01-14
|
* refactor: add vim._resolve_bufnrLewis Russell2024-12-07
|
* feat(lsp): deprecate non-method client functionsLewis Russell2024-11-20
| | | | | | | | | | | | | | Deprecated: - `client.request()` -> `client:request()` - `client.request_sync()` -> `client:request_sync()` - `client.notify()` -> `client:notify()` - `client.cancel_request()` -> `client:cancel_request()` - `client.stop()` -> `client:stop()` - `client.is_stopped()` `client:is_stopped()` - `client.supports_method()` -> `client:supports_method()` - `client.on_attach()` -> `client:on_attach()` Fixed docgen to link class fields to the full function doc.
* fix(api): only flush nvim__redraw when necessary #31250luukvbaal2024-11-18
| | | | | | | | Problem: Not possible to only set a "redraw later" type with nvim__redraw, which seems to be desired for the treesitter highlighter. Solution: Do not update the screen when "flush" is explicitly set to false and only redraw later types are present. In that case, do not call ui_flush() either.
* feat(lsp)!: remove client-server handlers from vim.lsp.handlersLewis Russell2024-11-01
| | | | | | | | | | - Partition the handlers in vim.lsp.handlers as: - client to server response handlers (RCS) - server to client request handlers (RSC) - server to client notification handlers (NSC) Note use string indexes instead of protocol.methods for improved typing in LuaLS (tip: use hover on RCS, RSC or NSC).
* refactor(lsp): drop str_byteindex/str_utfindex wrappers #30915Tristan Knight2024-10-26
| | | | | * deprecate old signatures * move to new str_byteindex/str_utfindex signature * use single-underscore name (double-underscore is reserved for Lua itself)
* perf(validate): use lighter versionLewis Russell2024-10-17
| | | | | - Also fix `vim.validate()` for PUC Lua when showing errors for values that aren't string or number.
* fix(lsp): check buffer is loaded and valid #30330glepnir2024-09-11
| | | | | Problem: buffer mabye not valid when callback handler invoke. Soliton: check buffer is valid and loaded in handler.
* fix(lsp): handle out-of-bounds character positions #30288Tristan Knight2024-09-08
| | | | | | | | | | | Problem: str_byteindex_enc could return an error if the index was longer than the lline length. This was handled in each of the calls to it individually Solution: * Fix the call at the source level so that if the index is higher than the line length, line length is returned as per LSP specification * Remove pcalls on str_byteindex_enc calls. No longer needed now that str_byteindex_enc has a bounds check.
* fix(lsp): inlay hints are rendered in the correct order (#29707)Amit Singh2024-07-17
| | | | | | | | | | | Problem: When there are multiple inlay hints present at the same position, they should be rendered in the order they are received in the response from LSP as per the LSP spec. Currently, this is not respected. Solution: Gather all hints for a given position, and then set it in a single extmark call instead of multiple set_extmark calls. This leads to fewer extmark calls and correct inlay hints being rendered.
* docs: misc (#29229)dundargoc2024-06-15
| | | | | | Co-authored-by: Ilia Choly <ilia.choly@gmail.com> Co-authored-by: Jose Pedro Oliveira <jose.p.oliveira.oss@gmail.com> Co-authored-by: Maria José Solano <majosolano99@gmail.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* fix(lsp): revert buf_versions deprecation/replacement (#29217)Mathias Fußenegger2024-06-07
| | | | | | | | | * Revert "fix(lsp): account for changedtick version gap on modified reset (#29170)" This reverts commit 2e6d295f799c27372e5c0c44727fa613c81717fd. * Revert "refactor(lsp): replace util.buf_versions with changedtick (#28943)" This reverts commit 5c33815448e11b514678f39cecc74e68131d4628.
* refactor(lua): use tuple syntax everywhere #29111Ilia Choly2024-06-04
|
* refactor(lsp): replace util.buf_versions with changedtick (#28943)Mathias Fußenegger2024-05-30
| | | | | | | `lsp.util.buf_versions` was already derived from changedtick (`on_lines` from `buf_attach` synced the version) As far as I can tell there is no need to keep track of the state in a separate table.
* docs: newsJustin M. Keyes2024-05-15
| | | | Set dev_xx.txt help files to use "flow" layout.
* docs: misc (#28609)dundargoc2024-05-15
| | | | | | | | | | | | Closes https://github.com/neovim/neovim/issues/28484. Closes https://github.com/neovim/neovim/issues/28719. Co-authored-by: Chris <crwebb85@gmail.com> Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: Jake B <16889000+jakethedev@users.noreply.github.com> Co-authored-by: Jonathan Raines <jonathan.s.raines@gmail.com> Co-authored-by: Yi Ming <ofseed@foxmail.com> Co-authored-by: Zane Dufour <zane@znd4.me> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* refactor(lua): remove deprecated features #28725Justin M. Keyes2024-05-13
|
* fix(lsp): enable() does not activate inlay hints on open buffers #28629Yi Ming2024-05-07
| | | | | | | | | | | Problem: inlay_hint `enable(<no args>)` does not activate inlay hints on open buffers. If a buffer does not have a corresponding `bufstate` in `bufstates`, then `enable` all buffers will not take effect on it. Solution: Make the effective range determined by the loaded buffers. Fix #28624
* fix(lsp): replace bug-prone ternary operation #28627Yi Ming2024-05-03
| | | ref #28624
* Merge #28101 nvim__redrawJustin M. Keyes2024-05-02
|\
| * feat(api): add nvim__redraw for more granular redrawingLuuk van Baal2024-05-02
| | | | | | | | | | | | | | | | | | | | | | Experimental and subject to future changes. Add a way to redraw certain elements that are not redrawn while Nvim is waiting for input, or currently have no API to do so. This API covers all that can be done with the :redraw* commands, in addition to the following new features: - Immediately move the cursor to a (non-current) window. - Target a specific window or buffer to mark for redraw. - Mark a buffer range for redraw (replaces nvim__buf_redraw_range()). - Redraw the 'statuscolumn'.
* | feat(lsp): inlay_hint.is_enabled({filter}) #28523Yi Ming2024-05-02
|/ | | vim.diagnostic.enable and vim.diagnostic.is_enabled() use the same pattern.
* feat(lsp): vim.lsp.inlay_hint.enable(nil) applies to all buffers #28543Yi Ming2024-05-02
| | | | | | | | | | | | | | | | | | Problem: Inlay hints `enable()` does not fully implement the `:help dev-lua` guidelines: Interface conventions ~ - When accepting a buffer id, etc., 0 means "current buffer", nil means "all buffers". Likewise for window id, tabpage id, etc. - Examples: |vim.lsp.codelens.clear()| |vim.diagnostic.enable()| Solution: Implement globally enabling inlay hints. * refactor(lsp): do not rely on `enable` to create autocmds * refactor(lsp): make `bufstates` a defaulttable * refactor(lsp): make `bufstate` inherit values from `globalstate` * feat(lsp): `vim.lsp.inlay_hints` now take effect on all buffers by default * test(lsp): add basic tests for enable inlay hints for all buffers * test(lsp): add test cases cover more than one buffer
* refactor(lsp): rename foos_by_bar to bar_foos #28505Yi Ming2024-04-26
|
* fix(lsp): avoid assertion when `client_hints` do not exist (#28461)Yi Ming2024-04-22
|
* fix(lsp): correct deprecation message #28403Maria José Solano2024-04-18
|
* feat(lua): enable(enable:boolean, filter:table) #28374Justin M. Keyes2024-04-18
| | | | | | | | | | | | | Problem: We need to establish a pattern for `enable()`. Solution: - First `enable()` parameter is always `enable:boolean`. - Update `vim.diagnostic.enable()` - Update `vim.lsp.inlay_hint.enable()`. - It was not released yet, so no deprecation is needed. But to help HEAD users, it will show an informative error. - vim.deprecate(): - Improve message when the "removal version" is a *current or older* version.
* docs: improve/add documentation of Lua typesLewis Russell2024-03-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Added `@inlinedoc` so single use Lua types can be inlined into the functions docs. E.g. ```lua --- @class myopts --- @inlinedoc --- --- Documentation for some field --- @field somefield integer --- @param opts myOpts function foo(opts) end ``` Will be rendered as ``` foo(opts) Parameters: - {opts} (table) Object with the fields: - somefield (integer) Documentation for some field ``` - Marked many classes with with `@nodoc` or `(private)`. We can eventually introduce these when we want to.