diff --git a/README.md b/README.md index f9961031..f0b1f754 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ require("copilot.panel").refresh() When `auto_trigger` is `true`, copilot starts suggesting as soon as you enter insert mode. -When `auto_trigger` is `false`, use the `next` or `prev` keymap to trigger copilot suggestion. +When `auto_trigger` is `false`, use the `next`, `prev` or `accept` keymap to trigger copilot suggestion. To toggle auto trigger for the current buffer, use `require("copilot.suggestion").toggle_auto_trigger()`. @@ -148,6 +148,7 @@ cmp.event:on("menu_closed", function() vim.b.copilot_suggestion_hidden = false end) ``` +
@@ -169,8 +170,8 @@ vim.api.nvim_create_autocmd("User", { }) ``` -
+ The `copilot.suggestion` module exposes the following functions: diff --git a/lua/copilot/suggestion.lua b/lua/copilot/suggestion.lua index 57966234..ae1d1852 100644 --- a/lua/copilot/suggestion.lua +++ b/lua/copilot/suggestion.lua @@ -447,6 +447,12 @@ end function mod.accept(modifier) local ctx = get_ctx() + -- no suggestion request yet + if not ctx.first then + schedule(ctx) + return + end + local suggestion = get_current_suggestion(ctx) if not suggestion or vim.fn.empty(suggestion.text) == 1 then return