Feature/plugin dependency checks in plugins

classic Classic list List threaded Threaded
5 messages Options
BPJ
Reply | Threaded
Open this post in threaded view
|

Feature/plugin dependency checks in plugins

BPJ
What is the best practice when a plugin needs a minimum version of
Vim with certain features, or on some other plugin? Do you check
for the version (and if so how) or do you check for some each
feature or for some feature which is indicative that the others
exist too? Is it best to check when the plugin is loaded or in
each function which needs a certain feature? What do you do when
the requirements aren't met --- issue a warning/error message or
just silently do nothing? My preference is definitely to issue a
message, but I'm concerned that it may be too noisy and get lost
if it is issued at loading time. There is also the concern that if
you are using a plugin manager some other plugin which you depend
on may not be loaded yet even though it eventually will be.

TIA,

/bpj

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Feature/plugin dependency checks in plugins

meine van essen
On Sat, Feb 16, 2019 at 09:54:01AM +0100, BPJ wrote:
> What is the best practice when a plugin needs a minimum version of
> Vim with certain features, or on some other plugin?

several times a week I run an update of all software on my machines,
and therefor I always use the most recent version of Vim avaliable.

together with a minimal use of plugins ---in fact I only use Goyo---
there aren't any compatibility problems.

regular updates are a good security and performance habit in any way, so
you win on both edges...

I must confess that updates and upgrades are very easy on my FreeBSD
boxes.

//meine

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
BPJ
Reply | Threaded
Open this post in threaded view
|

Re: Feature/plugin dependency checks in plugins

BPJ
Den 2019-02-16 kl. 11:53, skrev meine:

> On Sat, Feb 16, 2019 at 09:54:01AM +0100, BPJ wrote:
>> What is the best practice when a plugin needs a minimum version of
>> Vim with certain features, or on some other plugin?
>
> several times a week I run an update of all software on my machines,
> and therefor I always use the most recent version of Vim avaliable.
>
> together with a minimal use of plugins ---in fact I only use Goyo---
> there aren't any compatibility problems.
>
> regular updates are a good security and performance habit in any way, so
> you win on both edges...
>
> I must confess that updates and upgrades are very easy on my FreeBSD
> boxes.
>
> //meine
>

Good for you, but some are stuck with the version of Vim found in
the Ubuntu repos for example.  I can't just assume that everyone
has the latest and greatest.

/bpj

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Feature/plugin dependency checks in plugins

lith
In reply to this post by BPJ
> for the version (and if so how)

Many plugins define a variable that holds the plugin version

    let g:loaded_FOO = 100

in plugin/FOO.vim.

> There is also the concern that if
> you are using a plugin manager some other plugin which you depend
> on may not be loaded yet even though it eventually will be.

Do you really have to check for that dependency in the file under the plugin directory? IMHO it's often sufficient to check dependencies in an autoload file which also solves this problem.

Regards

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Feature/plugin dependency checks in plugins

Luc Hermitte
In reply to this post by BPJ

Hi,

> What is the best practice when a plugin needs a minimum version of
> Vim with certain features, or on some other plugin?

1- I try to document the identified requirement
2- I provide emulation of new features I use when this is possible.

See for instance https://github.com/luchermitte/lh-vim-lib/blob/master/autoload/lh/list.vim

3- Regarding the dependency to other plugins I usually expect the plugin I depend on to be up-to-date. And I provide the dependencies in the documentation of my plugin. I also highly recommend people to use plugin managers that understand dependencies (like VAM or vim-flavor). But I'm perfectly aware that people usually fancy plugin managers that download multiple plugins in parallel or have some other smooths feature. Personally I'm mainly interested in dependencies management.

BTW, version requirements can be expressed with vim-flavor.


> Do you check
> for the version (and if so how) or do you check for some each
> feature or for some feature which is indicative that the others
> exist too? Is it best to check when the plugin is loaded or in
> each function which needs a certain feature? What do you do when
> the requirements aren't met --- issue a warning/error message or
> just silently do nothing?

"Ignore" or "error" when the plugin file is loaded. But definitively "error" when a plugin feature is triggered and that the requirements are not met.
It depends on whether the plugin is critical or not. And whether it could be a non-critical dependency on some other plugin. For instance, my refactoring plugin implements a refactoring that depends on a plugin (lh-tags) that depends on ctags. It also implements other refactoring. I don't want to notify the end user that lh-tags cannot be used because ctags is not installed just because lh-tags is automatically installed (VAM) when the refactoring plugin is installed.


> My preference is definitely to issue a
> message, but I'm concerned that it may be too noisy and get lost
> if it is issued at loading time.


> There is also the concern that if
> you are using a plugin manager some other plugin which you depend
> on may not be loaded yet even though it eventually will be.

My plugin manager updates the runtimepath before any file from plugin/ is sourced. Then the dependencies are mainly done through autoloaded function. In case I depend on a mapping or a command, I explicitly source the files that defines it with :runtime.


HTH

--
Luc Hermitte

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.