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

Consideration of 'as' (or 'name') option #371

Closed
zydxhs opened this issue Dec 31, 2015 · 17 comments
Closed

Consideration of 'as' (or 'name') option #371

zydxhs opened this issue Dec 31, 2015 · 17 comments

Comments

@zydxhs
Copy link

zydxhs commented Dec 31, 2015

Hi,
I read the readme.md, and find that the "dir" option is the same as vundle's "name" option, but the "dir" option is very difficult to use.

I hope this feature will be improved int the next version. If I am wrong, please add an option like vundle.

for vundle, I Write:

Plugin 'kien/ctrlp.vim', {'name': 'ctrlp'}

for vim-plug, I must write:

Plug 'kien/ctrlp.vim', {'dir': '$VIM/vimfiles/bundle/ctrlp'}
@junegunn
Copy link
Owner

Thanks for the suggestion. But why do you care? Let vim-plug do what it has to do and just forget about the gritty details. The only reason one would need the option is when two plugins share the same name, but it never happens in practice. vim-plug tries to be a product that just works ™️, so basically I don't recommend changing the directory but if you really must, here's a slightly simpler version:

Plug 'kien/ctrlp.vim', {'dir': g:plug_home.'/ctrlp'}

@starcraftman
Copy link
Contributor

@zydxhs Side note, if you are going to use ctrlp, note that kien's repo has been dead for a while. There is an active fork made by ctrlpvim organization. You may also want to make use of the faster pymatcher.

In your vimrc:
Plug 'ctrlpvim/ctrlp.vim' | Plug 'FelikZ/ctrlp-py-matcher'

As for the issue, I'm likewise puzzled why you want to bother naming things. Don't like the .vim suffix on the directories?

@zydxhs
Copy link
Author

zydxhs commented Jan 4, 2016

thanks everyone.
"dir" is not the same as "name", I hope add "name" in the future version.
when many plugins that I want change it's default name, I have to write a lot of letters.

@junegunn
Copy link
Owner

junegunn commented Jan 4, 2016

I want change it's default name

Can you tell us why? If there is no practical reason you must use different names and if it's just a matter of aesthetics, we're probably not going to add it to vim-plug. Actually this topic was discussed before and we decided not to do it. See #331

@starcraftman
Copy link
Contributor

@zackhsi I'm guessing here but is your use case that you say develop a few plugins and regularly cd into the plugins folders to work on them. I can see that being a nuisance given the name collisions on completion due to common vim- prefix. I'd suggest instead of abusing the dir feature, use local plugs.

Example: Plugin comes from URI, you want name x, plugins name is actually vim-x.

  1. git clone URI ~/x
  2. In your vimrc, you simply toggle the Plug 'user/vim-x' to Plug '~/x'
  3. When done with developing for plugin, just return to old line and delete ~/x.

@zackhsi
Copy link
Contributor

zackhsi commented Jan 6, 2016

Hey @starcraftman, think you meant to mention @zydxhs.

I'm quite happy with my vim-plug usage 😺

@starcraftman
Copy link
Contributor

Hehe, little too fast on that completion of names. Anyway, @zydxhs see my above comment. If your desire for naming things is purely cosmetic and not related to dev, well, I just don't think we are going to put such a thing in.

@zydxhs
Copy link
Author

zydxhs commented Jan 8, 2016

I'm a typical completist, and I dislike plugin's name which with .vim, and on the other hand, is also in order to resolve the name conflict.

@junegunn junegunn changed the title The dir option to too difficult to use Consideration of 'as' (or 'name') option Jan 14, 2016
@junegunn
Copy link
Owner

to resolve the name conflict

Yes, but without some real-world examples, the point is moot. I'll leave this issue open. Let's see if we can get some feedbacks from other users.

@zydxhs
Copy link
Author

zydxhs commented Jan 14, 2016

ok.

@chadrien
Copy link

Heya all and specially @junegunn! I just ended here because I was actually looking for how to resolve a naming conflict.

I'm using honza/vim-snippets but I also created (a long time ago, before using plug) chadrien/vim-snippets to store snippets of my own. And obviously I stumbled upon the naming conflict, and was happy to learn about the dir workaround.

So yeah, a as option could be simpler to write, or we could let plug manage this on it's own and, for instance, if 2 repos has the same names the username could be prepended. In my case, I'd had honza-vim-snippets and chadrien-vim-snippets

Edit: after a quick try, dir does not seem to help me, the repo does even seem to be treated, probably because it's only the last one with the same name that is treated (didn't look at the code, it's just an hunch).

So for now, I'll just rename my repository, but the fact that repos with identical names should be managed remains, some day I'm not be owner of one of the repos and forking it then renaming it is not really a viable solution.

FYI: here is the used configuration:

Plug 'garbas/vim-snipmate' | Plug 'chadrien/vim-snippets', {'dir': g:plug_home.'/chadrien-vim-snippets'} | Plug 'honza/vim-snippets'

chadrien pushed a commit to chadrien/dotfiles that referenced this issue Jan 25, 2016
@starcraftman
Copy link
Contributor

@chadrien You are correct, in your use case the dir flag is useless as we infer the key in g:plugs from the name of the repo. Collisions are resolved by last key winning. Up to @junegunn on whether that fits his criteria of a valid use case. Changes required would definitely be trivial, this tiny patch works:

    if a:0 == 1 && has_key(a:1, 'as')
      let name = a1['as']
    else
      let name = fnamemodify(repo, ':t:s?\.git$??')
    endif

@junegunn junegunn added rfc and removed rfc labels Jan 25, 2016
junegunn added a commit that referenced this issue Jan 25, 2016
@junegunn
Copy link
Owner

Just pushed the implementation to as branch. It's a small fix and I checked that it does not affect the startup time to an observable degree. The only use cases we have seen so far are 1. for snippets (#331, #371 (comment)), 2. and for cosmetic purposes, both of which are not very convincing arguments for the addition of a new option. But still, the change is minimal, so it's probably fine to have it. Thoughts?

@vheon
Copy link
Contributor

vheon commented Jan 25, 2016

I think it would be fine to add it. From a code point of view all it gets added is a get into a dictionary and a local variable. Is a feature that many users coming from vundle are used to have (even though I don't know to how they use it) and I think they would appreciate to still have it.

@starcraftman
Copy link
Contributor

@junegunn I'm like you kinda on the fence, its not super important but a few people have wanted it. I think I am in favour though, because it is a simple change and lines 453-5 seem cleaner to me.

@junegunn
Copy link
Owner

@vheon @starcraftman Alright, thanks for the review.

@junegunn
Copy link
Owner

as merged to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants