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

Be more tolerant about plugin name conflicts #163

Open
malcolmr opened this issue Nov 27, 2015 · 8 comments
Open

Be more tolerant about plugin name conflicts #163

malcolmr opened this issue Nov 27, 2015 · 8 comments

Comments

@malcolmr
Copy link
Member

Adding two plugins with the same canonical name to &rtp breaks Maktaba's plugin detection completely, reporting e.g.

Error detected while processing function maktaba#plugin#Detect[2]..maktaba#plugin#GetOrInstall:
line   11:
E605: Exception not caught: ERROR(AlreadyExists): Conflict for plugin "foo": foo/ and foo.vim/

However, it seems like we should be able to deal with this more tolerantly and ignore the second one, not just completely fail.

(The real case I'm looking at is using both https://github.com/junegunn/fzf and https://github.com/junegunn/fzf.vim, which seems reasonable.)

@mushanyoung
Copy link

+1

@shehabk
Copy link

shehabk commented Feb 18, 2020

+1, is the issue resolved ?

@dbarnett
Copy link
Contributor

Nope! We have more projects than contributors so progress is slow.

As a workaround, you could add an addon-info.json file to one of hte plugins to give it a different unique name. For instance, in the case of fzf.vim, the plugin name is supposed to include the ".vim", so we can explicitly configure the name as "fzf.vim":

echo '{ "name": "fzf.vim" }' > fzf.vim/addon-info.json

Longer term, @malcolmr, WDYT about making it never fail but in the general case append a unique numeric index? Example:

Plug 'whatever/foo'
Plug 'yet-another/foo
echo maktaba#plugin#RegisteredPlugins()

Would print: ['foo', 'foo2']

We could also make smarter heuristics for guessing plugin names so that if you already have "fzf" installed and then install "fzf.vim", it'll keep the full name "fzf.vim", but that'll probably end up being order-dependent behavior and sometimes giving you "fzf" and "fzf2".

@shehabk
Copy link

shehabk commented Feb 18, 2020

Thanks @dbarnett , the workaround works for me.

@malcolmr
Copy link
Member Author

Yes, fzf.vim adding an adding an addon-info.json would fix this specific case.

In general: sounds like that uniquifying the plugin name might work. It would mean that maktaba#plugin#Get() would be effectively non-functional for any conflicting plugins, so you'd have to be careful about plugin load order: if you had one plugin that was Maktaba-aware, it'd need to be found first so it got the 'correct' name.

(In this case I guess we're mostly talking about plugins that aren't aware of Maktaba at all(?), so nobody would be calling maktaba#plugin#Get()(?).)

I note that this behaviour is actually documented; see https://github.com/google/vim-maktaba/blob/ec7a094/autoload/maktaba/plugin.vim#L304-L307.

@dbarnett
Copy link
Contributor

Hmm, now that you mention it, generally you won't have conflicting plugins that are both using maktaba, and plugins do assume they'll be able to look up their own plugin object by plugin name. Preferably a plugin that doesn't use maktaba at all wouldn't conflict with a maktaba plugin at all.

What about if we make a "soft"/lazy registration for plugins without an explicit name? Then we'd only try to disambiguate when you access the plugin object via maktaba#plugin#Enter or maktaba#plugin#Get. Still some corner cases there to think through, but the code would be able to make a much more informed decision if it resolved ties later in the process.

@malcolmr
Copy link
Member Author

That sounds reasonable, I think. Certainly I agree with the principle that non-Maktaba-using plugins shouldn't conflict with anything, if possible.

(Also, we can add maktaba#extension#GetRegistry(name) as an example of something where the caller expects to be able to predict the plugin name from outside.)

@dbarnett
Copy link
Contributor

Yep, but plugin name references from the outside don't help disambiguate, so these implicit strategies might still run into an unavoidable conflict if something looks up the plugin from the outside before the right plugin initializes.

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

4 participants