-
Notifications
You must be signed in to change notification settings - Fork 155
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
base: main
Are you sure you want to change the base?
Conversation
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 |
9c2e218
to
7c27dc7
Compare
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)
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! |
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!