aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/completion.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2025-03-02 14:27:52 -0800
committerGitHub <noreply@github.com>2025-03-02 14:27:52 -0800
commitc4a0c1d3b02761626ffced32fe74b0df5b665a5f (patch)
treed83ec56eed5ee6b9f8c5683a84f3062b577a991e /runtime/lua/vim/lsp/completion.lua
parent0a5a0efda64ccc789cda25b90fa907f277006cd3 (diff)
downloadrneovim-c4a0c1d3b02761626ffced32fe74b0df5b665a5f.tar.gz
rneovim-c4a0c1d3b02761626ffced32fe74b0df5b665a5f.tar.bz2
rneovim-c4a0c1d3b02761626ffced32fe74b0df5b665a5f.zip
docs: misc #31996
Diffstat (limited to 'runtime/lua/vim/lsp/completion.lua')
-rw-r--r--runtime/lua/vim/lsp/completion.lua24
1 files changed, 23 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/completion.lua b/runtime/lua/vim/lsp/completion.lua
index 1466dcf438..7b8ce02726 100644
--- a/runtime/lua/vim/lsp/completion.lua
+++ b/runtime/lua/vim/lsp/completion.lua
@@ -1,3 +1,25 @@
+--- @brief
+--- The `vim.lsp.completion` module enables insert-mode completion driven by an LSP server. Call
+--- `enable()` to make it available through Nvim builtin completion (via the |CompleteDone| event).
+--- Specify `autotrigger=true` to activate "auto-completion" when you type any of the server-defined
+--- `triggerCharacters`.
+---
+--- Example: activate LSP-driven auto-completion:
+--- ```lua
+--- vim.lsp.start({
+--- name = 'ts_ls',
+--- cmd = …,
+--- on_attach = function(client, bufnr)
+--- vim.lsp.completion.enable(true, client.id, bufnr, {
+--- autotrigger = true,
+--- convert = function(item)
+--- return { abbr = item.label:gsub('%b()', '') }
+--- end,
+--- })
+--- end,
+--- })
+--- ```
+
local M = {}
local api = vim.api
@@ -749,7 +771,7 @@ function M.enable(enable, client_id, bufnr, opts)
end
end
---- Trigger LSP completion in the current buffer.
+--- Triggers LSP completion once in the current buffer.
function M.trigger()
local bufnr = api.nvim_get_current_buf()
local clients = (buf_handles[bufnr] or {}).clients or {}