diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2025-03-21 03:34:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-21 03:34:28 -0700 |
commit | 264b4303a04381602113ea16c49635f538e0d856 (patch) | |
tree | 359665d5be1d260ada238177e34a9a4906e4ab35 /runtime/lua/vim | |
parent | c908c2560db891dcd152ed9d3cf10a36179bfed6 (diff) | |
download | rneovim-264b4303a04381602113ea16c49635f538e0d856.tar.gz rneovim-264b4303a04381602113ea16c49635f538e0d856.tar.bz2 rneovim-264b4303a04381602113ea16c49635f538e0d856.zip |
docs: LSP completion #33006
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r-- | runtime/lua/vim/lsp/completion.lua | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/runtime/lua/vim/lsp/completion.lua b/runtime/lua/vim/lsp/completion.lua index 6aedac8fd9..9345cb8d83 100644 --- a/runtime/lua/vim/lsp/completion.lua +++ b/runtime/lua/vim/lsp/completion.lua @@ -2,11 +2,12 @@ --- 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`. +--- `triggerCharacters`. Use CTRL-Y to select an item from the completion menu. |complete_CTRL-Y| --- --- Example: activate LSP-driven auto-completion: --- ```lua --- -- Works best with completeopt=noselect. +--- -- Use CTRL-Y to select an item. |complete_CTRL-Y| --- vim.cmd[[set completeopt+=menuone,noselect,popup]] --- vim.lsp.start({ --- name = 'ts_ls', @@ -673,8 +674,9 @@ local function get_augroup(bufnr) return string.format('nvim.lsp.completion_%d', bufnr) end +--- @inlinedoc --- @class vim.lsp.completion.BufferOpts ---- @field autotrigger? boolean Default: false When true, completion triggers automatically based on the server's `triggerCharacters`. +--- @field autotrigger? boolean (default: false) When true, completion triggers automatically based on the server's `triggerCharacters`. --- @field convert? fun(item: lsp.CompletionItem): table Transforms an LSP CompletionItem to |complete-items|. ---@param client_id integer @@ -777,6 +779,7 @@ local function disable_completions(client_id, bufnr) end --- Enables or disables completions from the given language client in the given buffer. +--- Example: |lsp-attach| |lsp-completion| --- --- @param enable boolean True to enable, false to disable --- @param client_id integer Client ID @@ -796,7 +799,21 @@ end --- @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. +--- Triggers LSP completion once in the current buffer, if LSP completion is enabled +--- (see |lsp-attach| |lsp-completion|). +--- +--- Used by the default LSP |omnicompletion| provider |vim.lsp.omnifunc()|, thus |i_CTRL-X_CTRL-O| +--- invokes this in LSP-enabled buffers. Use CTRL-Y to select an item from the completion menu. +--- |complete_CTRL-Y| +--- +--- To invoke manually with CTRL-space, use this mapping: +--- ```lua +--- -- Use CTRL-space to trigger LSP completion. +--- -- Use CTRL-Y to select an item. |complete_CTRL-Y| +--- vim.keymap.set('i', '<c-space>', function() +--- vim.lsp.completion.get() +--- end) +--- ``` --- --- @param opts? vim.lsp.completion.get.Opts function M.get(opts) |