Skip to content

feat(suggestions): export clear_preview and update_preview#571

Merged
AntoineGS merged 3 commits into
zbirenbaum:masterfrom
samiulsami:export-preview-utils
Sep 26, 2025
Merged

feat(suggestions): export clear_preview and update_preview#571
AntoineGS merged 3 commits into
zbirenbaum:masterfrom
samiulsami:export-preview-utils

Conversation

@samiulsami
Copy link
Copy Markdown
Contributor

These utility functions allow us to massively improve the UX for manually triggered suggestion workflows by loading suggestions in the background, and only showing them when triggered; greatly reducing the wait time required to generate a suggestion from scratch.

Example code snippet using the exported functions (with auto-trigger enabled):

		local copilot_suggestion = require("copilot.suggestion")

		vim.b.copilot_suggestion_hidden = true
		vim.api.nvim_create_autocmd({ "CursorMovedI", "InsertEnter", "InsertLeave" }, {
			group = vim.api.nvim_create_augroup("CopilotSuggestionHideGroup", { clear = true }),
			callback = function()
				if vim.b.copilot_suggestion_hidden then
					copilot_suggestion.clear_preview()
				end
				vim.b.copilot_suggestion_hidden = true
			end,
		})

		vim.keymap.set("i", "<C-o>", function()
			vim.b.copilot_suggestion_hidden = false
			if copilot_suggestion.is_visible() then
				copilot_suggestion.accept_line()
				return
			end
			copilot_suggestion.update_preview()
		end, { desc = "Accept Copilot suggestion (Line)" })

@samiulsami samiulsami force-pushed the export-preview-utils branch 2 times, most recently from 7197903 to 4bd7bf5 Compare September 21, 2025 20:11
@samiulsami samiulsami changed the title feat(copilot.suggestions): export clear_preview and update_preview feat(suggestions): export clear_preview and update_preview Sep 21, 2025
@AntoineGS
Copy link
Copy Markdown
Collaborator

You can ignore that last test failure, it does not seem related.
I'll make some tweaks as I am looking to move API endpoints to their own file to help future maintenance.
Thanks for the PR :)

@AntoineGS AntoineGS merged commit 4725916 into zbirenbaum:master Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants