Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept first word with Ctrl-B #11

Merged
merged 5 commits into from
Nov 19, 2024

Conversation

m18coppola
Copy link
Contributor

Added functionality to insert first word of suggestion.
I decided on using Ctrl-B for the default key bind, as it's one of the few unused insert-mode commands that also isn't used for terminal control flow.

I used ^\s*\S\+ as the pattern to match the first word in the suggestion. I experimented with alternative patterns that matched against \w's or matched up until a word boundary, but found that it was annoying, especially around sections of code that was symbol dense, i.e. for (i = 0; i < x; i++) {. I may come back with a better pattern in the future.

Resolves #2

@m18coppola m18coppola marked this pull request as draft November 15, 2024 23:06
@ggerganov
Copy link
Member

ggerganov commented Nov 16, 2024

Looking good.

Btw, it would be really good if we figure out how to not send a new completion request and instead to keep the remaining of the suggestion. This would also be needed when you start typing the same characters from the suggestion - no need to send new requests. But even as it is, it's a good improvement.

@m18coppola
Copy link
Contributor Author

m18coppola commented Nov 16, 2024

It's currently got a bug where if you try to accept a word on a completion that doesn't start at the end of line, it will delete your code:
Screencast_20241116_113141
I'm working on that right now. I really like the idea of keeping the remaining completion instead of doing a new curl request.

@m18coppola
Copy link
Contributor Author

m18coppola commented Nov 18, 2024

I fixed the bug where llama#accept_fim('word') was deleting text that came after the cursor.
I began investigating how to prevent making a new request when accepting only a word but found a catch. My first instinct was to make sure that llama#fim_cancel() was not called when accepting a word, but the CursorMoved event handler calls llama#fim_cancel() whenever the cursor moves, including when the cursor shifts while accepting a suggestion. I believe this change will be a little more involved and should be in a PR of its own, or perhaps be included with the PR that resolves #3

@m18coppola m18coppola marked this pull request as ready for review November 18, 2024 20:02
@ggerganov ggerganov merged commit f25519d into ggml-org:master Nov 19, 2024
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.

llama.vim : accept word functionality
2 participants