-
Notifications
You must be signed in to change notification settings - Fork 281
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
Dynamic autocompletion #60
Conversation
Now there is a new item type "PcItemDynamic" which takes function as parameter. When it comes to autocomplete at this position, the function is called, the whole line is given to it (for example if autocompletion depend on previous autocompleted field) and functio should return possible strings how to continue. Example usage: * listing some dynamic key-value storage * listing files in directory
Tested on Debian 5.4.0-3 and Win10, it seems working fine :-) |
@setnicka |
@chzyer Or have you better idea? And is there reason to use PrefixCompleterInterface interface outside this module? |
To serve it to dynamic autocompletion functions. Previously passed line was only following segment (which doesn't work).
Hi! @setnicka , sorry for the lated reply. type DynamicPrefixCompleterInterface interface {
PrefixCompleterInterface
IsDynamic() bool
GetDynamicNames(line []rune) [][]rune
} In function |
BTW, Dynamic autocompletion is really a very cool feature! |
…in Do function Do function was split into doInternal with changed declaration and Do with original declaration.
Sorry for lated reply too (summer trips, camps, etc). I added Plus I split |
Is there something I should fix/modify, or it can be merged? |
Not yet. Sorry about that. |
Ok, it's fine, thank you :-) |
👍 It looks very cool! |
There is a lot of cool stuff in this code that I wish the docs would explain and give examples for. Every time I think I need something, I come across a type that already seems to do it (fair warning: I have exactly 1 day exposure to this code). I'll figure out what everything does (eventually :) - there is a lot of stuff). Would you be open to accepting a PR with godoc additions and examples only? |
@gotwarlost |
* Dynamic autocompletion implemented Now there is a new item type "PcItemDynamic" which takes function as parameter. When it comes to autocomplete at this position, the function is called, the whole line is given to it (for example if autocompletion depend on previous autocompleted field) and functio should return possible strings how to continue. Example usage: * listing some dynamic key-value storage * listing files in directory * Dynamic autocompletion: Updated example * Dynamic autocompletion: Internal Do() is passing the original full line To serve it to dynamic autocompletion functions. Previously passed line was only following segment (which doesn't work). * Dynamic autocompletion: New dynamic interface added + type assertion in Do function Do function was split into doInternal with changed declaration and Do with original declaration.
I implemented dynamic autocompletion mechanism.
Now there is a new item type "PcItemDynamic" which takes function as
parameter.
When it comes to autocomplete at this position, the function is called,
the whole line is given to it (for example if autocompletion depend on
previous autocompleted field) and functio should return possible strings
how to continue.
Example usage: