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

Ex-Mode completion by external tool #259

Open
fanglingsu opened this issue Dec 3, 2015 · 6 comments
Open

Ex-Mode completion by external tool #259

fanglingsu opened this issue Dec 3, 2015 · 6 comments
Labels
component: completion rfc stale bot protection

Comments

@fanglingsu
Copy link
Owner

According to #253 there are cases where the current implementation of completion does not meet the needs of the users or is in a way to inflexible. So it would be nice to be able to let vimb call a configurable script that generates the completions entries.

Suggestion is to do something similar to the bookmark completion for the :open and :tabopen commands. If the inpubox contains a known command followed by space and and '@', the command and the stuff after the add should be given to the script which is considered to write the resulting matching entries to stdout to be displayed like all the other completions.
:command @tokens given to script<Tab> would call the configured script with the two params 'command' and 'token given to script'.

If the script writes lines containing a tab-char, then the line is split at the first one into the two parts that are displayed in the url history completion (only if FEATURE_TITLE_IN_COMPLETION is defined).

@fanglingsu fanglingsu added the rfc stale bot protection label Dec 3, 2015
@fanglingsu fanglingsu added this to the Feature Pool RFC milestone Dec 3, 2015
@infmagic2047
Copy link
Contributor

I think it is better to pass the full command line as argument and let the script decide whether to provide a completion. In this way the script can support multiple characters for different modes of completion, or override some builtin completion.

@fanglingsu
Copy link
Owner Author

@yyt16384 Do you mean to give the whole command line as one argument, or separated. You are right, to give the full command line provides more flexibility but on the other side the script has to implement the logic to separate the parts that is already implemented in vimb.

@cdlscpmv
Copy link
Contributor

@fanglingsu No, I think @yyt16384 means to call the script on every completion invocation regardless of the context, i.e., without @. In this way, you can not only override completion for some built-in commands, but also implement completion for user defined commands (or built-in commands with some character appended, like @). (Vimb doesn't currently support the :command directive from Vim, but maybe it will in the future.) If the completion script doesn't exist or it returns nothing (or a special exit code), Vimb should fall back to its own completion. @fanglingsu What do you think?

@fanglingsu
Copy link
Owner Author

Sounds flexible, but also slow. To complete, it must be called a script that my handle the completion, if this does not return anything or returns a special return code the vimb internal one is used. At the moment I don't see a reason to complexify the completion to much to allo the user to change the behavior. In my opinion it should be sufficient to allow to kick in custom logic by using a special completion char like the @. So it's clear who should be responsible for doing the completion.

@cdlscpmv
Copy link
Contributor

@fanglingsu I totally agree. I also thought about the possibility of slowing things down. So the first approach seems more optimal for now.

On the other hand, why not borrow something from Vim itself? I mentioned the :command directive before. It allows not only to define custom commands but also to set a custom completion for them. Besides usual things, like completion of filenames and history, it allows for a completion list generated by a function. In our case, since there is no VimL, this function can be a script which provides the completion. For example, :command -complete=custom,<script_name> Tabopen tabopen. The script must be supplied with the arguments which you proposed above.

While in Vim you cannot override completion for default commands, since it doesn't allow user-defined commands to start with a lowercase letter, this behavior not necesserily needs to be inherited in Vimb. (I don't really know the reasons behind this.)

The :command directive in Vim is rather evolved. Implementing just a subset of it would be a good start. What do you think?

@fanglingsu
Copy link
Owner Author

I am undecided. Of course, the :command command would allow to do more fancy things to tweak vimb to the need of the user. But on the other side, I don't see much cases where custom commands would make sense. Browsers are in this way different from editors, where you want to do a lot of things to text buffers.

@fanglingsu fanglingsu removed this from the Feature Pool RFC milestone Jun 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: completion rfc stale bot protection
Projects
None yet
Development

No branches or pull requests

3 participants