-
Notifications
You must be signed in to change notification settings - Fork 177
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
WIP: First pass at terminal-mode completions #665
Conversation
Remove debug line Use chansend() to set prompt text Add configuration options for terminal sources and keymaps Make a note about terminal completions in README (and fix a broken link)
You can use |
It is known issue. I think auto insert feature should be disabled in terminal mode. |
Thanks, done! This has also fixed the issue with completions being triggered after accepting :)
Thanks, good to know. Agreed - I'll look into this. |
Wow, this looks great, thank you!
That code is truly cursed 😂 The idea is that when the user types, we trigger the
For now, I think it would be enough to support |
7c27dc7
to
48667d5
Compare
Thanks for the review! And for explaining the cmdline code 😁
I think things are working correctly as-is? It's possible that there are edge cases I haven't checked yet though...
Good shout :) These both seem to be working now. Looking more into what you can do with these, e.g. settings Thanks again, this has been a fun one! |
Marked as draft again as I've discovered a few sharp edges. Will keep polishing! |
d3ee4dc
to
ec7da0b
Compare
Heya, finally coming back to this after getting a bit distracted over Christmas. The issue I'm having is that completions kind of flicker/stutter a bit in the terminal and I have no clue what's causing this. I'll keep digging in when I get the chance, but in the meantime @Saghen is there any chance you can suggest some avenues for exploration? This should show you what I mean: Screen.Recording.2025-01-26.at.17.23.04.mov |
Absolutely, I'll take a look as soon as I have some time |
ec7da0b
to
06e6b4f
Compare
Rebased on main and it's working really well! Weirdly enough, the stuttering seems to only happen on neovim v0.10, while nightly doesn't have any stutter. It seems like the event comes before the terminal gets updated so we effectively update before the event is applied. I'm pretty comfortable making this a nightly only feature for now given we need a shell source, and v0.11 is just around the corner |
Amazing work on this, tysm! |
Awesome! Gives me a good excuse to finally start using the nightly builds 😄 Thanks for checking and merging 🙏 |
Hi :)
Following #305 I thought I'd have a crack at terminal-mode completions. This is very much at proof-of-concept stage, but I've enjoyed tinkering with it so far so would be happy to keep working on it if you don't mind feeding back on current progress and advising about design for next steps.
Key things to note:
I created
cmp/lib/term_events.lua
to listen for edits in the terminal. I usedvim.on_key()
to achieve this as there's no terminal equivalent for theInsertCharPre
event. I was pretty torn about simply lifting the code fromcmp/lib/cmdline_events.lua
, but decided against this as there's a few things there I didn't quite understand, e.g. the use of timers and everything being accomplished byon_cursor_moved()
. If you don't mind explaining what these are doing I'll be happy to add equivalent functionality if needed :)AFAIK Neovim doesn't provide a convenient API for inserting text into the terminal prompt, so I had to cobble something together using
vim.feedkeys()
. I also experimented withvim.paste()
, but the results didn't feel good.Still to do:
Autocompletion immediately triggers after accepting a suggestion. It looks like after accepting a suggestion like
Bla
, the final character in the accepted text, in this casea
, is once again used to trigger a completion. Unfortunately I couldn't work out how this is avoided in cmdline/insert mode, so very grateful for any pointers here. My guess is that this has something to do with my omission ofon_cursor_moved()
, but playing with this functionality hasn't (yet) led me to a fix.I haven't added any user-facing configuration for terminal mode. I can imagine this is something most users will want quite fine-grained control over, so I thought I'd seek some pointers on this before diving in.
Thanks in advance for review!