Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: dismissal and acceptWord commands#62

Open
alvaromrveiga wants to merge 1 commit intoaugmentcode:mainaugmentcode/augment.vim:mainfrom
alvaromrveiga:alvaromrveiga/feat-dismissal-accept-wordalvaromrveiga/augment.vim:alvaromrveiga/feat-dismissal-accept-wordCopy head branch name to clipboard
Open

feat: dismissal and acceptWord commands#62
alvaromrveiga wants to merge 1 commit intoaugmentcode:mainaugmentcode/augment.vim:mainfrom
alvaromrveiga:alvaromrveiga/feat-dismissal-accept-wordalvaromrveiga/augment.vim:alvaromrveiga/feat-dismissal-accept-wordCopy head branch name to clipboard

Conversation

@alvaromrveiga
Copy link

Motivation

I was missing being able to accept only a few words of the suggestion and also dismissing it when it is not relevant, hope this helps other people too.

augment.webm

Changes

This pull requests exposes augment#suggestion#Clear() as a public API that can be called as augment#Dismiss and create the new command augment#AcceptWord() it accepts a fallback just like augment#Accept does.

Here is an example on how I configured those keys in Neovim using lazy.nvim:

	keys = {
		{ "<M-d>", "<cmd>call augment#Accept()<cr>", desc = "Accept Augment suggestion", mode = "i" },
		{ "<M-a>", "<cmd>call augment#AcceptWord()<cr>", desc = "Accept one Augment suggestion word", mode = "i" },
		{ "<M-;>", "<cmd>call augment#Dismiss()<cr>", desc = "Dismiss Augment suggestion", mode = "i" },
	},
	config = function()
		vim.g.augment_disable_tab_mapping = true
	end,

In case someone else needs it, I use nvim-cmp for completions so this change was needed in my config so it does not get in the way of suggestions:

					-- Allow Augment keybinds to work even when cmp is visible
					["<M-a>"] = cmp.mapping(function(fallback)
						-- Close cmp and let Augment handle the key
						if cmp.visible() then
							cmp.close()
						end
						fallback()
					end, { "i" }),
					["<M-d>"] = cmp.mapping(function(fallback)
						-- Close cmp and let Augment handle the key
						if cmp.visible() then
							cmp.close()
						end
						fallback()
					end, { "i" }),

Testing

  • Verified that augment#AcceptWord() correctly moves the cursor and accepts only the next word of the ghost text.

  • Confirmed augment#Dismiss() clears the current suggestion UI immediately.

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.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.