Saturday, November 25, 2023

Re: Rely on ‘runtimeparh’ in import autoload

On Sat, Nov 25, 2023 at 2:20 PM Lifepillar <lifepillar@lifepillar.me> wrote:
>
> On 2023-11-24, Matan Nassau <matan.nassau@gmail.com> wrote:
> > When is it good practice to use the import autoload form that relies
> > on 'runtimepath'?
> >
> > import autoload 'foo.vim'
> >
> > I think plugins generally know where their autoload stuff is, and can
> > gain a few milliseconds by pointing the import directly at it with
> > a relative path.
> >
> > And, the runtimepath form generally won't work when 'loadplugins'
> > isn't set (when starting Vim with --clean for example).
>
> What is the use case for an autoload mechanism when plugins have been
> turned off? Are you talking about `import autoload` statements in
> a vimrc file?
>
> > So what is the feature for
>
> Vim 9 script inherits the autoload mechanism from Vim legacy script,
> where runtimepath is used. I think that is the main reason for that
> behaviour.
>
> >, when is it a good time to use it?
>
> It's just a matter of personal preference. In most cases the difference
> won't be noticeable. I'd stick with relative paths to avoid potential,
> although probably rare, name conflicts.
>
> Life.

The advantage of using 'runtimepath' (not 'runtimeparh') is that the
sysadmin and the user can to some extent customize the plugin by
adding their own scripts in other directories than those located under
$VIMRUNTIME (which is reserved for scripts distributed together with
Vim). For instance, if a sysadmin loads a set of scripts for all users
of a given system under $VIM/vimfiles/… a user who knows what (s)he's
doing can customize it by means of additional scripts of the same name
and path below (on Unix) $HOME/.vim/after/… or (on Windows but in Vim
notation) $HOME/vimfiles/after/…

Also, if a third-party plugin (installed under $VIM/vimfiles/… or
$HOME/.vim/… etc.) becomes an "official plugin" distributed with Vim
(as happened in the past for matchit, netrw, VimBall, and others), its
scripts will change location and come under $VIMRUNTIME/… By using
'runtimepath' the plugin will continue functioning in exactly the same
way regardless of under which of the 'runtimepath' directories its
scripts are installed.

Best regards,
Tony.

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXtRsRjF7zqp8d5SBkFXMwCbLqoMK2DEAkpREh7xbijHaQ%40mail.gmail.com.

No comments: