paradigm / SkyBison

Vim plugin to expedite use of cmdline commands
73 stars 9 forks source link

allow for argument prefixing #1

Closed mattsacks closed 10 years ago

mattsacks commented 12 years ago

this plugin is excellent - I'm definitely going to use it with a lot of my common commands. one use I'm already getting great mileage out of is supplanting my vim-fuzzee plugin without having to manually tab to the result of the globbed files.

something I thought could be pretty cool is to create mappings that prefix a command to reduce typing common arguments. I've modified the source so that it will allow for this, but I haven't done too much extensive testing into what I've possibly broken.

as an example: nnoremap <Leader>js :call SkyBison("F app/jav*", 0)

This will call the F command with app/jav*<user input> and allow for completion from the results of the command without having to manually hit to see them.

paradigm commented 12 years ago

I should note you can do something comparable without your pull:

nnoremap js :call SkyBison("F",0)app/java*

The mapping keeps feeding keys into the function's getchar()'s after the is called.

We seem to have very different coding styles (you use spaces for indentation where I use tabs, you drop the variable scope prefix when unnecessary where as I tend to be explicit about it every time). Since I'm going to refactor everything to be more readable anyways, rather than pulling in your code, unifying the style, and then refactoring, I might turn down your pull and re-implement your idea myself when I'm refactoring. Not that there's anything wrong with your code, it just seems like a path of lesser resistance to the same end result.

Currently, SkyBison internally differentiates between the command and the argument (as I'm sure you've noticed). With that in mind, there are three major ways to go about implementing your idea: (1) Attach the prefix to the command, as you did. This means the user cannot delete parts of the prefix without exiting the plugin (which may or may not be desirable). (2) Attach the prefix to the argument. This would be simpler to implement than the first option, as it is just setting the default argument from an empty string to the prefix. However, this means the user can delete parts or all of the prefix (which may or may not be desirable). (3) Stop internally differentiating between the command and the argument. This has a number of repercussions. The user can delete not only the prefix but also the command. If this can be made to work well, this could make SkyBison("",0) act as a mostly functional replacement for not just a individual cmdline commands but the cmdline itself. Perhaps a cnoremap could be made to convert an in-progress cmdline entry to SkyBison. The major barrier here is that, at first glance, there is no really good way to have a sufficiently flexible auto-. I could assume when Vim's cmdline-completion no longer returns more than one possible option we've exhausted the number of cmdline-completion'able arguments. However, commands such as :wqall would then wait for an argument, as that can take an argument, even if people usually don't give it one.

Any preferences? I'm probably going to leave it to churn in the back of my mind for a while, as all three have appealing aspects.

mattsacks commented 12 years ago

I'm totally cool with you declining the pull and I apologize for introducing a different coding style into your file.

This pull serves my needs and might not be applicable to most users. Unfortunately, nnoremap <Leader>js :call SkyBison("F",0)app/java*<CR> doesn't quite do what I want.

What I want is a mapping that prefixes what I type after <Leader>js to be :F app/java* and then show all completions based on that. As I type along, app/java* is consistently prefixed in front of my input.

All 3 options you've introduced don't seem too bad. Coincidentally, my attempt at thinking about an auto-completion system for the command line had to do with adding a new option to wildmode, but I like your plugin much better :smile:

If I had to pick one though, I probably wouldn't. You could add an optional, additional third argument (I know, blech), that determines whether any of the passed in cmd argument can be modified once SkyBison has been called, and default it to false.

As to the flickering - it's only present for me in Terminal Vim (which, thankfully, I don't use often) and isn't in MacVim (at least for me). The cause of which are your calls to redraw. Unfortunately, I don't know of an alternative to the system you've set up in SkyBison.

Hope that helps!

paradigm commented 12 years ago

I apologize for introducing a different coding style into your file.

No need to apologize, that's just how life without a universal coding style standard is.

To make sure I understand the situation: The problem with my nnoremap proposal is that the prefix part can be changed, yes? If the user could not <bs> over it, it'd be good, yes? I'm leaning towards breaking the internal differentiation between command and argument. If I do that, but leave some way to keep the user from changing the content passed in the first argument to SkyBision(), it'd serve what you're looking for, yes?

If so, I'll likely do that. Shouldn't be hard to implement.

paradigm commented 10 years ago

This issue is over a year old without any response to my questions about exactly what is being asked; I'm closing it. If you ever find your way back here do not hesitate to re-open it and explain in more detail and I'll see what I can do.