aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
Commit message (Collapse)AuthorAge
* fix(lua): enable param-type-mismatch diagnosticLewis Russell2026-09-28
| | | | | | | | | Problem: Argument type mismatches are excluded from EmmyLua checks. Solution: Correct runtime annotations and calls, document local checker workarounds, and enable the diagnostic. AI-assisted
* fix(lua): enable assignment type checking in runtime codeLewis Russell2026-09-25
| | | | | | | | | | | Enable EmmyLua's assign-type-mismatch diagnostic after correcting the runtime annotations and assignments it flags. Correct option, tuple, and return types, and use separate locals when a value changes representation. Add guards and narrow casts where needed so the runtime passes the stricter check. Regenerate the affected docs. AI-assisted
* fix(lua): enable nil-safety diagnostics in runtime codeLewis Russell2026-09-25
| | | | | | | | | | | | Enable EmmyLua's need-check-nil diagnostic and resolve nullable values through more precise types, explicit invariants, and guards for missing runtime state. Keep analyzer-specific workarounds local and update the affected API documentation. Exclude the bundled re.lua from analysis so its nil-check warnings do not fail CI. AI-assisted
* fix(lua): add missing param annotations (#41911)Lewis Russell2026-09-15
|
* fix(lsp): snippet is not expanded when resolve races the user #41774glepnir2026-09-11
| | | | | | | | | | | Problem: on_complete_done() defers clear_word() and the snippet expansion until completionItem/resolve answers, and drops both when 'changedtick' moved meanwhile. Typing right after accepting leaves the plain word in the buffer. Solution: Expand before requesting, and anchor the resolved edits with an extmark instead of gating them on 'changedtick'.
* build: enable more EmmyLua checksLewis Russell2026-09-09
| | | | | | | | | | Enable checks for unused code, deprecated calls, return types, and annotations. Fix the warnings and replace the deprecated highlight function. Keep exceptions where old APIs are still needed or the checker gets it wrong. AI-assisted
* fix(lsp): show_document() reports a failed buffer load #41731Volodymyr Chernetskyi2026-09-07
| | | | | | | | | | | | | | Problem: vim.lsp.util.show_document() can fail to load the target buffer, most visibly with E325 when another process owns the file's swapfile and the user declines to open it. The Vim error escapes show_document() and surfaces inside whichever LSP handler called it, instead of being reported as a failure to show the document. Solution: Load the buffer up front with vim.fn.bufload(), before any of that state is touched, and report the error instead of raising. AI-assisted
* 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
* feat(fs): vim.fs.normalize{plain:boolean} #41127Olivia Kinnear2026-08-05
| | | | | | `opts.plain=true` does not expand tildes in addition to environment variables, unlike `opts.expand_env=false`. `opts.expand_env=false` is soft-deprecated.
* fix(lsp): incorrect rendering of markdown codeblock #40861Justin M. Keyes2026-07-20
| | | | | | | | | | | | Problem: LSP hover erroneously drops blank lines before a 4-space-indented codeblock, which is not valid Markdown. This causes incorrect parsing and wrong display. Solution: Fix `split_lines` so that it doesn't drop the blank line just before a 4-space-indented codeblock. fix https://github.com/neovim/neovim/issues/40860
* fix(lsp): preview window converted to normal window is auto-closed (#40770)Rocco Vaccone2026-07-19
| | | | | | | | | | | | | Problem: A floating preview window (hover, signature help) converted to a normal window (e.g. with CTRL-W_H or nvim_win_set_config()) is still closed by the open_floating_preview() autocommands, and a later preview may focus or close it as if it were still a float. Solution: When the preview window is no longer floating, remove its auto-close autocommands and stop tracking it as the buffer's floating preview. Closes #36659
* refactor(api): omit optional paramJustin M. Keyes2026-07-13
|
* feat(api): add nvim_win_resize()XiaowenHu962026-07-05
| | | | | | | | | | | | | | | Ref #6645 Problem: When a window is resized it takes space from the window right/below first, and only falls back to the window left/above when there is no more room. Sometimes a user wants the space to come from a specific direction. Solution: Add nvim_win_resize(win, width, height, {anchor}) which resizes a window with a choosable anchor edge, letting a window grow leftwards or upwards by taking space from the window to the left or above first. The default anchor reproduces nvim_win_set_width()/nvim_win_set_height().
* Merge #40087 from ofseed/pos-util-follow-upJustin M. Keyes2026-06-14
|\ | | | | feat(pos): create a cursor position by using the current of a window
| * feat(pos): create a cursor position by using the current of a windowYi Ming2026-06-08
| | | | | | | | | | | | | | | | | | | | Problem: `vim.pos.cursor(vim.api.nvim_get_current_buf(win), vim.api.nvim_win_get_cursor(win))` is too verbose to create a cursor position of a window, but it is a common use case. Solution: Overload `vim.pos.cursor()`, so that it accepts `win` as an argument when `pos` is omitted.
* | fix(lsp): trailing blank line when edit inserts past end of buffer #40133Aaron Tinio2026-06-10
|/ | | | | | | | | | | | | | | | Problem: A text edit positioned entirely past the last buffer line, with newText ending in a newline, leaves a stray blank line: the past-the-end path appends the trailing empty fragment produced by vim.split() and does not set has_eol_text_edit, so the end-of-buffer cleanup is skipped. Formatting servers emit such edits whenever formatting moves text to the end of a document. Regression from ec94014cd1 (#20137), which split the past-the-end fast path off the clamp path that sets the flag. Solution: Set has_eol_text_edit in the past-the-end path, like the adjacent path that clamps end_row.
* fix(pos): `get_lines()` return empty table when file opening failsYi Ming2026-06-02
| | | | | | | | | | | | Problem: `get_lines()` may returns empty table when file opening fails, so every existing caller use `get_line() or ''` to avoid nil result. This also does not match the annotated return type of `get_line()`, which is `string` instead of `string?`. Solution: Make `get_line()` return empty string when file opening fails.
* fix(lsp): calc correct screen_width when opts.relative == 'editor' (#39977)acehinnnqru2026-05-24
|
* fix(lsp): validate that `workspace_edit` isn't `nil` (#39947)Maria Solano2026-05-21
|
* 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(pos,range): extract `vim.pos._util`Yi Ming2026-05-20
| | | | | | | | | | | Problem: - To share logic, creating a `vim.Range` currently creates two `vim.Pos` values as intermediates, which causes unnecessary table allocations. - `pos.lua` and `range.lua` contain some overlapping logic. Solution: Add `vim.pos._util`, a module for handling positions represented directly by `row` and `col`.
* feat(lsp)!: deprecate `vim.lsp.util.character_offset()`Yi Ming2026-05-18
|
* 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(pos): move `get_lines` from `lsp.util` to `pos`Yi Ming2026-05-16
|
* refactor(lsp)!: always require `position_encoding`Yi Ming2026-05-11
|
* refactor!: remove deprecated APIsYi Ming2026-05-11
|
* feat(lua)!: vim.isnil, vim.nonnil, deprecate vim.F #39495Olivia Kinnear2026-05-06
|
* docs: misc #39511Justin M. Keyes2026-04-29
|
* fix(lsp): util.lua attempt to concatenate userdata #39225Olivia Kinnear2026-04-28
| | | | | | | | | Problem: Error when querying document symbols using python-lsp-server: lsp/util.lua:1955: attempt to concatenate field 'containerName' (a userdata value) Solution: Check for `vim.NIL`.
* fix(lsp): handle relative='editor' in make_floating_popup_options() #39320Daigo Yamashita2026-04-26
| | | | | | | | | | | | | | | | | | Problem: With `vim.g.health = { style = 'float' }`, running `:checkhealth` from a `:help` buffer placed the float in the top-left corner instead of centered. make_floating_popup_options() picks the NW/NE/SW/SE anchor and the available height from cursor-relative metrics (winline(), wincol(), winheight()). When the caller passes relative='editor', those metrics are meaningless, so the function could flip to an 'E' anchor and clamp the float off-screen. Solution: When relative='editor', treat the whole editor area as available space (lines_above=0, lines_below=&lines, wincol=0). This makes the NW anchor the natural choice and keeps the float position stable regardless of where the cursor is in the current window. AI-assisted: Claude Code
* docs: sort quasi-keysetsJustin M. Keyes2026-04-26
|
* fix(lsp): malformed edit if apply_text_edits() is called twice #34954geril072026-04-23
| | | | | | | | | | | | | | Problem: Use vim.lsp.util.apply_text_edits to re-apply the same textedit causes an incorrect edit, because apply_text_edits silently modifies the parameter. Solution: - Avoid changing `text_edit._index`. - Document this fun feature. Helped-by: Riley Bruins <ribru17@hotmail.com> Helped-by: Yi Ming <ofseed@foxmail.com> Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* fix(lsp): set 'winfixbuf' in open_floating_preview() window #39058Raizento2026-04-15
| | | | | | | | | Problem: The window opened by `vim.lsp.util.open_floating_preview()` allows its buffer to be switched. Presumably that only happens by accident and is disorienting. Solution: Set 'winfixbuf' in the open_floating_preview() window.
* refactor(api): rename "window" to "win" (positional parameters) #39083Justin M. Keyes2026-04-15
| | | | | | | continues d0af4cd9094f. This commit renames positional parameters. This is only "cosmetic", but is intended to make it extra clear which name is preferred, since people often copy existing code despite the guidelines in `:help dev-naming`.
* docs: lsp, options, api #38980Justin M. Keyes2026-04-14
| | | | | | | | | docs: lsp, options - revert bogus change to `_meta/builtin_types.lua` from 3a4a66017b74 Close #38991 Co-authored-by: David Mejorado <david.mejorado@gmail.com>
* fix(lsp): show_document can't position cursor past EOL in insert-mode #38566Lars Debor2026-04-12
| | | | | | | | Problem: vim.lsp.util.show_document insert mode is unable to set the cursor after the target character position if the target character is at end of line. Solution: Move cursor after the target character (in append position) in this case.
* feat(api): rename buffer to buf #35330Jordan2026-04-08
| | | | | | | | | | | | Problem: `:help dev-name-common` states that "buf" should be used instead of "buffer" but there are cases where buffer is mentioned in the lua API. Solution: - Rename occurrences of "buffer" to "buf" for consistency with the documentation. - Support (but deprecate) "buffer" for backwards compatibility. Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* fix(lsp): apply_text_edits causes unwanted BufDelete events #38778glepnir2026-04-08
| | | | | | | | | | | | | | Problem: Since 2f6d1d3c887a87d9402137425b418dd12a904aac, `apply_text_edits` unconditionally sets `buflisted=true`, causing spurious BufDelete events if plugins restore the original 'buflisted' state on unlisted buffers: https://github.com/neovim/neovim/blob/65ef6cec1cb766334c59d3255595dfe523b11020/src/nvim/option.c#L2159-L2169 Solution: - Don't set 'buflisted' in `apply_text_edits`. Set it more narrowly, in `apply_workspace_edit` where the semantics requires affected buffers to be visible to the user. - Also skip setting 'buflisted' if it would not be changed, to avoid redundant `OptionSet` events.
* refactor: integer functions, optimize asserts #34112Lewis Russell2026-03-12
| | | | | | | | | | | | refactor(lua): add integer coercion helpers Add vim._tointeger() and vim._ensure_integer(), including optional base support, and switch integer-only tonumber()/assert call sites in the Lua runtime to use them. This also cleans up related integer parsing in LSP, health, loader, URI, tohtml, and Treesitter code. supported by AI
* fix(lsp): set concealcursor='' in LSP floating windows #36596skewb1k2025-11-17
| | | | | | | | | | | | Problem: Users often jump and navigate through LSP windows to yank text. Concealed markdown can make navigation through hyperlinks and code blocks more difficult. Solution: Change 'concealcursor' from 'n' to '' to preserve clean display while improving navigation and selection of the LSP response. Closes #36537
* fix(lsp): set 'linebreak' in floating windows (#36275)Fredrik Lanker2025-10-22
| | | | | Set linebreak to avoid splitting words. Fix #36268
* fix: remove quotes around `nil` deprecation alternatives (#36047)Maria Solano2025-10-05
|
* refactor(lua): consistent use of local aliasesChristian Clason2025-08-28
|
* refactor(lsp): move `util.enable` to `capability.enable`Yi Ming2025-08-18
|
* feat(lsp): support signature help noActiveParameterSupport #34838skewb1k2025-08-11
|
* feat(lsp): improve signature help display #35190skewb1k2025-08-06
| | | | | - Add delimiter between function signature and documentation, matching hover formatting - Show title only if there are multiple clients or multiple signatures - Avoid duplicating the title inside the window if it's already shown in the border
* fix(lsp): show title when global winborder is set (#35181)glepnir2025-08-06
| | | | | Problem: make_floating_popup_options only shows when opts.border is explicitly set, ignoring global winborder setting Solution: check both opts.border and vim.o.winborder when determining whether to show title
* fix(lsp): make thematic break parsing conform to GFM spec (#35162)skewb1k2025-08-05
| | | | | - Support for '_' and '*' as delimiters - Allow spaces between delimiters - Use more efficient implementation
* fix(lsp): decode 'null' in server responses as vim.NIL #34849skewb1k2025-08-03
| | | | | | | | | | | | | | | | Problem: Previously, 'null' value in LSP responses were decoded as 'nil'. This caused ambiguity for fields typed as '? | null' and led to loss of explicit 'null' values, particularly in 'data' parameters. Solution: Decode all JSON 'null' values as 'vim.NIL' and adjust handling where needed. This better aligns with the LSP specification, where 'null' and absent fields are distinct, and 'null' should not be used to represent missing values. This also enables proper validation of response messages to ensure that exactly one of 'result' or 'error' is present, as required by the JSON-RPC specification.
* fix(lsp): support `containerName` in symbol requests #35029Riley Bruins2025-07-22
| | | The field is present for SymbolInformation and WorkspaceSymbol.