Friday, March 4, 2016

Re: Packages

Lcd wrote:

> On 4 March 2016, Nikolay Aleksandrovich Pavlov <zyx.vim@gmail.com> wrote:
> > 2016-03-04 14:25 GMT+03:00 LCD 47 <lcd047@gmail.com>:
> > > On 3 March 2016, Bram Moolenaar <Bram@moolenaar.net> wrote:
> > > [...]
> > >> I realize several people who have previously been using Pathogen
> > >> are confused. Perhaps we can just put every directory under
> > >> "pack/*/ever" in 'runtimepath'?
> > >
> > > A tangentially related question. Assume I need to check that
> > > a plugin named "foo" is installed and enabled. Assume also "foo"
> > > contains
> >
> > If you need to check that it is installed and *enabled* then you
> > should not do anything you are not already doing.
>
> So if
>
> globpath(&runtimepath, "autoload/foo.vim", 1) != ""
>
> returns true, I can assume "foo" is installed and enabled?

If it was added with automatic mechanisms, yes. If the path appears in
'runtimepath' the related plugin would have been loaded. That is, after
initialization (loading plugins) is done.

This won't work if initialization hasn't finished yet.

This won't work if the user adds a directory to 'runtimepath' without
loading the plugin.

The best way to avoid this kind of uncertainty is to set a global
variable:

let g:fooPluginLoaded = 1

Or with the version, like what Charles uses:

let g:loaded_netrwPlugin = "v155"

Only then can you be 100% sure that the plugin was actually sourced.

> > Problem is that with "just put every directory under pack/*/ever"
> > you probably will not be able to do this from the vimrc: rationale is
> > that
> >
> > 1. Putting should be automatic.
> > 2. Yet user settings regarding where "pack" is should be respected.
> >
> > So "just put" should be done somewhere between "load vimrc" and "load
> > plugins" initialization stages.
>
> I'm trying to write a plugin that happens to need "foo", not a
> plugin manager. I don't want to install "foo" if it's missing, I just
> want to know if I can call "foo#bar()". Checking for the function
> itself is not reliable:
>
> exists("*foo#bar")
>
> returns false if the corresponding autoload file is not already loaded.
> I also don't want to load the file just to make sure I can use the
> function at some later point in time.

--
BEDEVERE: Why do you think she is a witch?
SECOND VILLAGER: She turned me into a newt.
BEDEVERE: A newt?
SECOND VILLAGER: (After looking at himself for some time) I got better.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment