Commit Graph

399 Commits

Author SHA1 Message Date
7d5866d471 fix(lsp): open_floating_preview() ignores max_height (#32716)
Problem:  After 47aaddfa the max_height option is no longer respected.
          Hover documentation and Signature help windows take up the
          entire text height.
Solution: Compare to window's current height and only modify the height
          if it would reduce the height, not enlarge it.
2025-03-04 18:36:57 +00:00
c4a0c1d3b0 docs: misc #31996 2025-03-02 14:27:52 -08:00
6a9555c0fa doc: clarify window-id, tab-id, nvim_set_current_x #32528
Problem:
Descriptions are somewhat vague. nvim_set_current_line modifies contents
but nvim_set_current_buf does not, etc.

Solution:
- Make it clear that these functions accept or return a winid/tabid by
  linking to that concept in help.
- Only these few files use the term "handles", so replace them with the
  more conventional terminology.
- Add a new help section for tab-ID. This concept is unique to neovim
  because vim exposes tabnr, but not tab handles. This section is
  modelled after `:h winid`.
2025-02-27 02:05:00 -08:00
47aaddfa0d fix(lsp): resize hover window for concealed lines
Problem:  Height of a (markdown) `vim.lsp.util.open_floating_preview()`
          window can be reduced to account for concealed lines (after #31324).
Solution: Set the window height to the text height of the preview window.
          Set 'concealcursor' to avoid unconcealing the cursorline when
          entering the hover window.
2025-02-25 14:26:58 +01:00
d2cca606a1 fix(float): ensure floating window width can fit title 2025-02-23 10:32:20 +00:00
4fd2694f20 fix(lsp): missing method parameter when canceling requests 2025-02-13 10:19:34 +08:00
be8d87014c fix(lsp): on detach, cancel pending foldingRange requests #31509
Problem:
1. Open a relatively large file (so the server needs some time to
   process the request).
2. Then immediately execute `:bdelete`.
3. Once the request is completed, the handler will obtain the bufstate
   of a buffer already unloaded.

    Error executing vim.schedule lua callback: ...7841_1/share/nvim/runtime/lua/vim/lsp/_folding_range.lua:119: assertion failed!
    stack traceback:
            [C]: in function 'assert'
            ...7841_1/share/nvim/runtime/lua/vim/lsp/_folding_range.lua:119: in function 'multi_handler'
            ...7841_1/share/nvim/runtime/lua/vim/lsp/_folding_range.lua:140: in function 'handler'
            ...HEAD-c137841_1/share/nvim/runtime/lua/vim/lsp/client.lua:669: in function ''
            vim/_editor.lua: in function <vim/_editor.lua:0>

Solution:
On detach, cancel all pending textDocument_foldingRange requests.
2025-02-12 06:22:59 -08:00
e8b5dd1e89 feat(lsp)!: symbol_to_item requires offset_encoding 2025-02-11 18:48:56 +08:00
6722149776 feat(lsp): include end_col and end_lnum in vim.lsp.buf.symbols_to_items 2025-02-11 17:09:39 +08:00
6aa42e8f92 fix: resolve all remaining LuaLS diagnostics 2025-01-27 16:37:50 +00:00
8a236c242a fix(lsp): set floating window filetype after setup #32112
Problem:
The filetype for the floating window buffer is being set before its context is fully initialized.
This results in `FileType` events not receiving the correct context.

Solution:
Set the filetype after the floating preview window and its buffer variables are
fully configured to ensure proper context is provided.
2025-01-20 05:00:13 -08:00
09e01437c9 refactor: use nvim.foo.bar format for autocommand groups 2025-01-14 21:25:25 -08:00
850084b519 refactor: use nvim.foo.bar format for namespaces 2025-01-14 19:55:29 -08:00
a4f575abd8 fix(lsp): minimum height for floating popup #31990
Problem:
The floating window for hover and signature help always cuts off a few lines,
because the `_make_floating_popup_size` function counts empty lines as having
zero height.

Solution:
Ensure the height is at least 1.
2025-01-13 15:17:23 -08:00
7c00e0efbb docs: misc #31867 2025-01-09 09:26:45 -08:00
b12b91c274 feat(health): show :checkhealth in floating window #31086
Problem: health can not shown in a floating window
Solution: add g:health variable
2025-01-07 08:09:01 -08:00
86770108e2 fix(lsp): open_floating_preview() zindex relative to current window #31886
Problem:  open_floating_preview() may be hidden behind current window if
          that is floating and has a higher zindex.
Solution: Open floating preview with zindex higher than current window.
2025-01-06 06:05:50 -08:00
668d2569b4 refactor: add vim._resolve_bufnr 2024-12-07 16:58:40 +00:00
bdfba8598b fix(lsp): cancel pending requests before refreshing
Problem:
Diagnostics and inlay hints can be expensive to calculate, and we
shouldn't stack them as this can cause noticeable lag.

Solution:
Check for duplicate inflight requests and cancel them before issuing a new one.
This ensures that only the latest request is processed, improving
performance and preventing potential conflicts.
2024-12-07 10:08:33 +00:00
203e7a43d1 fix(lsp): mention function name in warning #31301
Problem: The warning message is the same in different functions.
It is not convenient to locate the specific function name

Solution: add function name in warning message
2024-11-27 05:44:29 -08:00
165b099fa3 refactor(lsp): rename offset_encoding to position_encoding #31286
Problem:
LSP spec uses the term "position encoding" where we say "offset encoding".

Solution:
- Rename it everywhere except `vim.lsp.Client.offset_encoding` (which would be breaking).
- Mention "position encoding" in the documentation for `vim.lsp.Client.offset_encoding`.
2024-11-25 08:06:05 -08:00
2a1f604c77 fix(lsp): delete bufvar inside WinClosed event
Problem: floaing preview window can be closed by some
ex commands like `only` `fclose` which will not clean the bufvar

Solution: use WinClosed event with floating_winnr for clean
bufnr, and add test cases for vim.lsp.util.open_floating_preview
2024-11-24 10:47:05 +00:00
7d8db54441 fix(lsp): delete b:lsp_floating_preview buf var after win close
Problem: After floating preview window closed the buf var still exist

Solution: delete  after floating window closed.
2024-11-22 10:16:40 +00:00
629483e24e feat(lsp): require offset_encoding param #31249
Problem:
Since [version 3.17](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocuments),
LSP supports specifying the position encoding (aka offset encoding) supported by
the client through `positionEncoding`. Since #31209, Nvim fully supports
`utf-8`, `utf-16`, and `utf-32` encodings.

Previously, nvim assumed all clients for a buffer had the same
`offset_encoding`, so:
* Nvim provides `vim.lsp._get_offset_encoding()` to get `offset_encoding`, but
  this function is incorrect because `offset_encoding` is per-client, not
  per-buffer.
* Based on the strategy of `vim.lsp._get_offset_encoding()`,
  `vim.lsp.util.make_position_params()`, `vim.lsp.util.make_range_params()`, and
  `vim.lsp.util.make_given_range_params()` do not require the caller to pass
  `offset_encoding`, which is invalid.
* https://github.com/neovim/neovim/issues/25272

Solution:
* Mark `vim.lsp._get_offset_encoding()` as `@deprecated`.
* Change the type annotations of `vim.lsp.util.make_position_params()`,
  `vim.lsp.util.make_range_params()`, `vim.lsp.util.make_given_range_params()`
  to require the `offset_encoding` param.
2024-11-20 12:19:07 -08:00
454ae672aa feat(lsp): deprecate non-method client functions
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.
2024-11-20 08:51:45 +00:00
c5f217db01 refactor(lsp): simplify reference range logic 2024-11-10 09:40:37 +00:00
6e68fed374 feat(lsp): multi-client support for signature_help
Signatures can be cycled using `<C-s>` when the user enters the floating
window.
2024-11-04 11:55:39 +00:00
f54266dbed fix(lsp): hover border type can be string (#31013)
Border type can also be a string as defined in `api-win_config`

Co-authored-by: Nikolai Devolder <nikolai.devolder@yamabiko.eu>
2024-11-01 10:03:09 +01:00
123c0b6b4e docs(lsp): document alternative for vim.lsp.util.jump_to_location 2024-10-27 09:26:52 +00:00
25b53b593e refactor(lsp): drop str_byteindex/str_utfindex wrappers #30915
* deprecate old signatures
* move to new str_byteindex/str_utfindex signature
* use single-underscore name (double-underscore is reserved for Lua itself)
2024-10-26 07:38:25 -07:00
18b43c331d refactor: rename vim.highlight => vim.hl
Problem:
- `vim.highlight` module does not follow `:help dev-name-common`, which
  documents the name for "highlight" as "hl".
- Shorter names are usually preferred.

Solution:
Rename `vim.highlight` to `vim.hl`.

This is not a breaking change until 2.0 (or maybe never).
2024-10-21 00:54:43 +02:00
0083e03d6f feat(lsp)!: support multiple clients in goto methods (#30877)
Relates to:

- https://github.com/neovim/neovim/issues/30034
- https://github.com/neovim/neovim/issues/17712
- https://github.com/neovim/neovim/issues/16363

Closes:

- https://github.com/neovim/neovim/issues/26936 (but only provides bufnr
  and method)
- https://github.com/neovim/neovim/issues/22318

Might fix: https://github.com/neovim/neovim/issues/30737
2024-10-20 23:40:44 +02:00
564173e556 fix(lsp.util): wrong arguments to 'validate' function 2024-10-18 07:37:36 +01:00
fa6ab0d909 Merge pull request #30825 from lewis6991/refactor/lsputil 2024-10-17 13:35:02 +01:00
a18fa2f11c feat(lsp.util): minor codestyle 2024-10-17 12:52:46 +01:00
cbc82011ce feat(lsp.util): improve offset_encoding type annotations 2024-10-17 12:52:45 +01:00
e954a16063 feat(lsp.util): remove some variables 2024-10-17 12:52:45 +01:00
97119a2369 feat(lsp.util): use vim.w/b 2024-10-17 12:52:45 +01:00
3f87e222f7 feat(lsp.util): remove some aliases 2024-10-17 12:52:45 +01:00
8ad000ef7c feat(lsp.util): remove unneeded table 2024-10-17 12:52:45 +01:00
acbc6a7f91 fix(lsp.util): inconsistent handling of offset_encoding 2024-10-17 12:52:45 +01:00
ff1d7d4299 feat(lsp.util): get_bufs_with_prefix -> get_writeable_bufs 2024-10-17 12:52:45 +01:00
1944c0d610 feat(lsp.util): refactor get_border_size() 2024-10-17 12:52:45 +01:00
d44d36b8ff feat(lsp.util): simplify some bounds checking 2024-10-17 12:52:45 +01:00
0621718e3b feat(lsp.util): remove metatable in locations_to_items 2024-10-17 12:52:45 +01:00
f0973d4227 feat(lsp.util): refactor symbols_to_items()
- Remove the trivial function vim.lsp.util._get_symbol_kind_name()
  and its tests.
2024-10-17 12:52:45 +01:00
5bec7288a5 feat(lsp.util): remove uneeded do-end 2024-10-17 12:52:45 +01:00
1edfe5c09e feat(lsp.util): use vim.api alias 2024-10-17 12:52:45 +01:00
92e4e3fb76 feat(lsp.util): fix type errors 2024-10-17 12:52:44 +01:00
80e37aa533 fix(lsp): str_byteindex_enc bounds checking #30747
Problem:
Previously the index was only checked against the UTF8 length. This
could cause unexpected behaviours for strings containing multibyte chars

Solution:
Check indicies correctly against their max value before returning the
fallback length
2024-10-16 09:12:19 -07:00