mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
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>
This commit is contained in:
committed by
GitHub
parent
f5dd30948e
commit
3e3775961f
@ -42,7 +42,7 @@ LSP
|
|||||||
• *vim.lsp.util.jump_to_location* Use |vim.lsp.util.show_document()| with
|
• *vim.lsp.util.jump_to_location* Use |vim.lsp.util.show_document()| with
|
||||||
`{focus=true}` instead.
|
`{focus=true}` instead.
|
||||||
• *vim.lsp.buf.execute_command* Use |Client:exec_cmd()| 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
|
• vim.lsp.buf_request_all The `error` key has been renamed to `err` inside
|
||||||
the result parameter of the handler.
|
the result parameter of the handler.
|
||||||
• *vim.lsp.with()* Pass configuration to equivalent
|
• *vim.lsp.with()* Pass configuration to equivalent
|
||||||
|
@ -1879,7 +1879,7 @@ enable({enable}, {client_id}, {bufnr}, {opts})
|
|||||||
• {opts} (`vim.lsp.completion.BufferOpts?`) See
|
• {opts} (`vim.lsp.completion.BufferOpts?`) See
|
||||||
|vim.lsp.completion.BufferOpts|.
|
|vim.lsp.completion.BufferOpts|.
|
||||||
|
|
||||||
trigger({opts}) *vim.lsp.completion.trigger()*
|
get({opts}) *vim.lsp.completion.get()*
|
||||||
Triggers LSP completion once in the current buffer.
|
Triggers LSP completion once in the current buffer.
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
|
@ -29,7 +29,8 @@ LSP
|
|||||||
• `vim.lsp.buf.document_symbol()` uses the |location-list| by default. Use
|
• `vim.lsp.buf.document_symbol()` uses the |location-list| by default. Use
|
||||||
`vim.lsp.buf.document_symbol({ loclist = false })` to use the |quickfix|
|
`vim.lsp.buf.document_symbol({ loclist = false })` to use the |quickfix|
|
||||||
list.
|
list.
|
||||||
|
• `vim.lsp.completion.trigger()` has been renamed to
|
||||||
|
|vim.lsp.completion.get()|.
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
|
|
||||||
|
@ -536,7 +536,7 @@ local function on_insert_char_pre(handle)
|
|||||||
local ctx = { triggerKind = protocol.CompletionTriggerKind.TriggerForIncompleteCompletions }
|
local ctx = { triggerKind = protocol.CompletionTriggerKind.TriggerForIncompleteCompletions }
|
||||||
if debounce_ms == 0 then
|
if debounce_ms == 0 then
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
M.trigger({ ctx = ctx })
|
M.get({ ctx = ctx })
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
completion_timer = new_timer()
|
completion_timer = new_timer()
|
||||||
@ -544,7 +544,7 @@ local function on_insert_char_pre(handle)
|
|||||||
debounce_ms,
|
debounce_ms,
|
||||||
0,
|
0,
|
||||||
vim.schedule_wrap(function()
|
vim.schedule_wrap(function()
|
||||||
M.trigger({ ctx = ctx })
|
M.get({ ctx = ctx })
|
||||||
end)
|
end)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@ -791,13 +791,13 @@ function M.enable(enable, client_id, bufnr, opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- @inlinedoc
|
--- @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`.
|
--- @field ctx? lsp.CompletionContext Completion context. Defaults to a trigger kind of `invoked`.
|
||||||
|
|
||||||
--- Triggers LSP completion once in the current buffer.
|
--- Triggers LSP completion once in the current buffer.
|
||||||
---
|
---
|
||||||
--- @param opts? vim.lsp.completion.trigger.Opts
|
--- @param opts? vim.lsp.completion.get.Opts
|
||||||
function M.trigger(opts)
|
function M.get(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local ctx = opts.ctx or { triggerKind = protocol.CompletionTriggerKind.Invoked }
|
local ctx = opts.ctx or { triggerKind = protocol.CompletionTriggerKind.Invoked }
|
||||||
local bufnr = api.nvim_get_current_buf()
|
local bufnr = api.nvim_get_current_buf()
|
||||||
|
@ -847,7 +847,7 @@ describe('vim.lsp.completion: protocol', function()
|
|||||||
exec_lua(function()
|
exec_lua(function()
|
||||||
local win = vim.api.nvim_get_current_win()
|
local win = vim.api.nvim_get_current_win()
|
||||||
vim.api.nvim_win_set_cursor(win, pos)
|
vim.api.nvim_win_set_cursor(win, pos)
|
||||||
vim.lsp.completion.trigger()
|
vim.lsp.completion.get()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
@ -1153,7 +1153,7 @@ describe('vim.lsp.completion: protocol', function()
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.lsp.completion.trigger()
|
vim.lsp.completion.get()
|
||||||
|
|
||||||
return params
|
return params
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user