aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc
diff options
context:
space:
mode:
authorYi Ming <ofseed@foxmail.com>2024-11-21 04:19:07 +0800
committerGitHub <noreply@github.com>2024-11-20 12:19:07 -0800
commit629483e24eed3f2c07e55e0540c553361e0345a2 (patch)
tree0ac4969929cef4cdc272362bf8e6d01c40669179 /runtime/doc
parent1b6442034f6a821d357fe59cd75fdae47a7f7cff (diff)
downloadrneovim-629483e24eed3f2c07e55e0540c553361e0345a2.tar.gz
rneovim-629483e24eed3f2c07e55e0540c553361e0345a2.tar.bz2
rneovim-629483e24eed3f2c07e55e0540c553361e0345a2.zip
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.
Diffstat (limited to 'runtime/doc')
-rw-r--r--runtime/doc/lsp.txt17
-rw-r--r--runtime/doc/news.txt3
2 files changed, 8 insertions, 12 deletions
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index ae26abd34d..3cb3e590f4 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -2025,12 +2025,10 @@ make_given_range_params({start_pos}, {end_pos}, {bufnr}, {offset_encoding})
selection.
• {bufnr} (`integer?`) buffer handle or 0 for current,
defaults to current
- • {offset_encoding} (`'utf-8'|'utf-16'|'utf-32'?`) defaults to
- `offset_encoding` of first client of `bufnr`
+ • {offset_encoding} (`'utf-8'|'utf-16'|'utf-32'`)
Return: ~
- (`table`) { textDocument = { uri = `current_file_uri` }, range = {
- start = `start_position`, end = `end_position` } }
+ (`{ textDocument: { uri: lsp.DocumentUri }, range: lsp.Range }`)
*vim.lsp.util.make_position_params()*
make_position_params({window}, {offset_encoding})
@@ -2040,9 +2038,7 @@ make_position_params({window}, {offset_encoding})
Parameters: ~
• {window} (`integer?`) window handle or 0 for current,
defaults to current
- • {offset_encoding} (`'utf-8'|'utf-16'|'utf-32'?`) defaults to
- `offset_encoding` of first client of buffer of
- `window`
+ • {offset_encoding} (`'utf-8'|'utf-16'|'utf-32'`)
Return: ~
(`lsp.TextDocumentPositionParams`)
@@ -2060,13 +2056,10 @@ make_range_params({window}, {offset_encoding})
Parameters: ~
• {window} (`integer?`) window handle or 0 for current,
defaults to current
- • {offset_encoding} (`"utf-8"|"utf-16"|"utf-32"?`) defaults to
- `offset_encoding` of first client of buffer of
- `window`
+ • {offset_encoding} (`"utf-8"|"utf-16"|"utf-32"`)
Return: ~
- (`table`) { textDocument = { uri = `current_file_uri` }, range = {
- start = `current_position`, end = `current_position` } }
+ (`{ textDocument: { uri: lsp.DocumentUri }, range: lsp.Range }`)
*vim.lsp.util.make_text_document_params()*
make_text_document_params({bufnr})
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 32deb85278..f3d82786bd 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -95,6 +95,9 @@ LSP
Instead use: >lua
vim.diagnostic.config(config, vim.lsp.diagnostic.get_namespace(client_id))
<
+• |vim.lsp.util.make_position_params()|, |vim.lsp.util.make_range_params()|
+ and |vim.lsp.util.make_given_range_params()| now require the `offset_encoding`
+ parameter.
LUA