From c4a0c1d3b02761626ffced32fe74b0df5b665a5f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 2 Mar 2025 14:27:52 -0800 Subject: docs: misc #31996 --- runtime/lua/vim/lsp/completion.lua | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'runtime/lua/vim/lsp/completion.lua') 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 {} -- cgit