Skip to content

Commit 5b1a75b

Browse files
authored
docs(copilot): add instructions to enable lsp inline completion (#4111)
1 parent b8c3630 commit 5b1a75b

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

lsp/copilot.lua

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,33 @@
1313
---
1414
--- Please see [terms of use for GitHub Copilot](https://docs.github.com/en/site-policy/github-terms/github-terms-for-additional-products-and-features#github-copilot)
1515
---
16+
--- You need to enable `:help lsp-inline-completion` to receive suggestions. For example, you can enable it in the LspAttach event:
17+
---
18+
--- ```lua
19+
--- vim.api.nvim_create_autocmd('LspAttach', {
20+
--- callback = function(args)
21+
--- local bufnr = args.buf
22+
--- local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
23+
---
24+
--- if client:supports_method(vim.lsp.protocol.Methods.textDocument_inlineCompletion, bufnr) then
25+
--- vim.lsp.inline_completion.enable(true, { bufnr = bufnr })
26+
---
27+
--- vim.keymap.set(
28+
--- 'i',
29+
--- '<C-F>',
30+
--- vim.lsp.inline_completion.get,
31+
--- { desc = 'LSP: accept inline completion', buffer = bufnr }
32+
--- )
33+
--- vim.keymap.set(
34+
--- 'i',
35+
--- '<C-G>',
36+
--- vim.lsp.inline_completion.select,
37+
--- { desc = 'LSP: switch inline completion', buffer = bufnr }
38+
--- )
39+
--- end
40+
--- end
41+
--- })
42+
--- ```
1643

1744
---@param bufnr integer,
1845
---@param client vim.lsp.Client

0 commit comments

Comments
 (0)