cloudhead / neovim-fuzzy

Minimalistic fuzzy file finding for neovim
BSD 3-Clause "New" or "Revised" License
111 stars 17 forks source link

Add option to jump if already open and/or open in new tab #2

Closed techhazard closed 8 years ago

techhazard commented 8 years ago

This commit adds a new setting:

g:fuzzy_opencmd opens the file with the specified command instead of the current one

Not setting g:fuzzy_opencmd is equivalent to setting it to 'edit' Examples:

'edit'      " always opens in current window
'tabedit'   " always opens in new tab
'split'     " always opens in horizontal split
'vsplit'    " always opens in vertical split
'drop'      " open in current window if unopened or jump to if it is open
'tab drop'  " open in new tab if unopened or jump to if it is open (note the space!)

Open in (v)split or jump is an exercise for the reader ;-)

cloudhead commented 8 years ago

Hey, thanks for this. I think I would prefer if there was just a g:fuzzy_opencmd variable that defaulted to edit, and the user could configure it to whatever they wanted to, ex tab drop in your case. If you make those changes I'll merge it in.

techhazard commented 8 years ago

What do you think? Do you want me to remove the toggles as well?

cloudhead commented 8 years ago

Yeah I think the toggles are unnecessary.

techhazard commented 8 years ago

The way I see it: the toggles are an easy way to get started using tabs/jumps beyond that we have the opencmd that offers full customisability (which overrides the toggles anyway)

Would you mind leaving the toggles in place?

cloudhead commented 8 years ago

The problem is we're then using three global options to do what a single option can do. I think it's more confusing. Best would be to document usage of fuzzy_opencmd with examples of how to use it to open files in new tabs, or to drop into already open buffers. There's other ways to open files too, ex: split and vsplit, and there's no reason there should be an option to specifically open in a new tab, but not to open in a split. But we don't want to multiply the number of options!

techhazard commented 8 years ago

good point

techhazard commented 8 years ago

I edited the first comment to reflect my changes

cloudhead commented 8 years ago

Great, thanks! I'll add your examples to the doc once I create it :sweat_smile: