aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Fußenegger <mfussenegger@users.noreply.github.com>2025-03-16 13:58:38 +0100
committerGitHub <noreply@github.com>2025-03-16 13:58:38 +0100
commit3e3775961fd231ab7cf1e8c67bb28249f720333c (patch)
treed2220893408b500c0a282bf61f432fd841103e9b
parentf5dd30948e67b0bfbfe0f1023a9b0c8a0b20b486 (diff)
downloadrneovim-3e3775961fd231ab7cf1e8c67bb28249f720333c.tar.gz
rneovim-3e3775961fd231ab7cf1e8c67bb28249f720333c.tar.bz2
rneovim-3e3775961fd231ab7cf1e8c67bb28249f720333c.zip
refactor(lsp)!: rename lsp.completion.trigger() to get() (#32911)
Problem: `trigger` is a custom word not yet used in APIs. Solution: Use `get` instead because the main effect is that the completion candidates will be collected (and shown by default, but follow-up commits are planned to add an `on_result` callback that allows more general handling). --------- Co-authored-by: Christian Clason <c.clason@uni-graz.at>
-rw-r--r--runtime/doc/deprecated.txt2
-rw-r--r--runtime/doc/lsp.txt2
-rw-r--r--runtime/doc/news.txt3
-rw-r--r--runtime/lua/vim/lsp/completion.lua10
-rw-r--r--test/functional/plugin/lsp/completion_spec.lua4
5 files changed, 11 insertions, 10 deletions
diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt
index 68258fedb4..21f35637e6 100644
--- a/runtime/doc/deprecated.txt
+++ b/runtime/doc/deprecated.txt
@@ -42,7 +42,7 @@ LSP
• *vim.lsp.util.jump_to_location* Use |vim.lsp.util.show_document()| with
`{focus=true}` instead.
• *vim.lsp.buf.execute_command* Use |Client:exec_cmd()| instead.
-• *vim.lsp.buf.completion* Use |vim.lsp.completion.trigger()| instead.
+• *vim.lsp.buf.completion* Use |vim.lsp.completion.get()| instead.
• vim.lsp.buf_request_all The `error` key has been renamed to `err` inside
the result parameter of the handler.
• *vim.lsp.with()* Pass configuration to equivalent
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index 16ea9c18a0..3a2de6bc70 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -1879,7 +1879,7 @@ enable({enable}, {client_id}, {bufnr}, {opts})
• {opts} (`vim.lsp.completion.BufferOpts?`) See
|vim.lsp.completion.BufferOpts|.
-trigger({opts}) *vim.lsp.completion.trigger()*
+get({opts}) *vim.lsp.completion.get()*
Triggers LSP completion once in the current buffer.
Parameters: ~
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index d79e22e174..e74344cece 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -29,7 +29,8 @@ LSP
• `vim.lsp.buf.document_symbol()` uses the |location-list| by default. Use
`vim.lsp.buf.document_symbol({ loclist = false })` to use the |quickfix|
list.
-
+• `vim.lsp.completion.trigger()` has been renamed to
+ |vim.lsp.completion.get()|.
OPTIONS
diff --git a/runtime/lua/vim/lsp/completion.lua b/runtime/lua/vim/lsp/completion.lua
index 4064e02597..dcb7b5fa9b 100644
--- a/runtime/lua/vim/lsp/completion.lua
+++ b/runtime/lua/vim/lsp/completion.lua
@@ -536,7 +536,7 @@ local function on_insert_char_pre(handle)
local ctx = { triggerKind = protocol.CompletionTriggerKind.TriggerForIncompleteCompletions }
if debounce_ms == 0 then
vim.schedule(function()
- M.trigger({ ctx = ctx })
+ M.get({ ctx = ctx })
end)
else
completion_timer = new_timer()
@@ -544,7 +544,7 @@ local function on_insert_char_pre(handle)
debounce_ms,
0,
vim.schedule_wrap(function()
- M.trigger({ ctx = ctx })
+ M.get({ ctx = ctx })
end)
)
end
@@ -791,13 +791,13 @@ function M.enable(enable, client_id, bufnr, opts)
end
--- @inlinedoc
---- @class vim.lsp.completion.trigger.Opts
+--- @class vim.lsp.completion.get.Opts
--- @field ctx? lsp.CompletionContext Completion context. Defaults to a trigger kind of `invoked`.
--- Triggers LSP completion once in the current buffer.
---
---- @param opts? vim.lsp.completion.trigger.Opts
-function M.trigger(opts)
+--- @param opts? vim.lsp.completion.get.Opts
+function M.get(opts)
opts = opts or {}
local ctx = opts.ctx or { triggerKind = protocol.CompletionTriggerKind.Invoked }
local bufnr = api.nvim_get_current_buf()
diff --git a/test/functional/plugin/lsp/completion_spec.lua b/test/functional/plugin/lsp/completion_spec.lua
index 94578aa6da..7772a47589 100644
--- a/test/functional/plugin/lsp/completion_spec.lua
+++ b/test/functional/plugin/lsp/completion_spec.lua
@@ -847,7 +847,7 @@ describe('vim.lsp.completion: protocol', function()
exec_lua(function()
local win = vim.api.nvim_get_current_win()
vim.api.nvim_win_set_cursor(win, pos)
- vim.lsp.completion.trigger()
+ vim.lsp.completion.get()
end)
retry(nil, nil, function()
@@ -1153,7 +1153,7 @@ describe('vim.lsp.completion: protocol', function()
end,
})
- vim.lsp.completion.trigger()
+ vim.lsp.completion.get()
return params
end)