Determine whether vim is loading or whether the VimEnter event was already fired

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

Determine whether vim is loading or whether the VimEnter event was already fired

Tom Link-3
Hi,

Is there a general/standard way to determine whether vim is loading
(before VimEnter) or whether the startup was already completed?
Something like v:loading (similar to v:dying) maybe? I.e. how could I
distinguish whether a script/plugin is loaded during startup or by
means of a :source or :runtime command?

Regards,
Tom

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Determine whether vim is loading or whether the VimEnter event was already fired

Nikolay Aleksandrovich Pavlov
Ответ на сообщение «Determine whether vim is loading or whether the VimEnter
event was already fired»,
присланное в 10:23:18 04 сентября 2010, Суббота,
отправитель Tom Link:

I know the way used in vim-addon-manager: it sets key in dictionary on VimEnter
event, so that at startup there is no `started_up' key and after there is.

By the way, :source/:runtime commands can be called during startup.

Текст сообщения:

> Hi,
>
> Is there a general/standard way to determine whether vim is loading
> (before VimEnter) or whether the startup was already completed?
> Something like v:loading (similar to v:dying) maybe? I.e. how could I
> distinguish whether a script/plugin is loaded during startup or by
> means of a :source or :runtime command?
>
> Regards,
> Tom

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Determine whether vim is loading or whether the VimEnter event was already fired

Tom Link-3
> I know the way used in vim-addon-manager: it sets key in dictionary on VimEnter
> event, so that at startup there is no `started_up' key and after there is.

Initially, I was hoping that vim would set some variable that could be
checked. Anyway, I now remove all VimEnter autocommands before
sourcing a script and then I then call :doautocommand VimEnter
afterwards.

BTW I noticed that

  au! VimEnter

doesn't remove autocommands that belong to a group. So I have to first
get a list of VimEnter autocommands and then remove each group like.
Am I missing something? Is there some magic group name that matches
any group? Something like

  au! * VimEnter

or

  au! ALL VimEnter

Regards,
Tom

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Determine whether vim is loading or whether the VimEnter event was already fired

MarcWeber
In reply to this post by Tom Link-3
Excerpts from Tom Link's message of Sat Sep 04 08:23:18 +0200 2010:
> Hi,
>
> Is there a general/standard way to determine whether vim is loading
> (before VimEnter) or whether the startup was already completed?
> Something like v:loading (similar to v:dying) maybe? I.e. how could I
> distinguish whether a script/plugin is loaded during startup or by
> means of a :source or :runtime command?

  " hack: Vim sources plugin files after sourcing .vimrc
  "       Vim doesn't source the after/plugin/*.vim files in other runtime
  "       paths. So do this *after* plugin/* files have been sourced
  fun! scriptmanager#Hack()
    let s:c['started_up'] = 1

That's called by VimEnter in vim-addon-manager.

What's your exact use case, Tom?

If you want to depend on vim-addon-manager you can check for
  g:vim_script_manager['started_up']

Or implement something similar yourself.

Marc Weber

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Determine whether vim is loading or whether the VimEnter event was already fired

anwoku
In reply to this post by Tom Link-3
On 4 Sep., 08:23, Tom Link <[hidden email]> wrote:

> Hi,
>
> Is there a general/standard way to determine whether vim is loading
> (before VimEnter) or whether the startup was already completed?
> Something like v:loading (similar to v:dying) maybe? I.e. how could I
> distinguish whether a script/plugin is loaded during startup or by
> means of a :source or :runtime command?
>
> Regards,
> Tom

has("vim_starting")

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Determine whether vim is loading or whether the VimEnter event was already fired

Nikolay Aleksandrovich Pavlov
Ответ на сообщение «Re: Determine whether vim is loading or whether the VimEnter
event was already fired»,
присланное в 14:36:29 07 сентября 2010, Вторник,
отправитель anwoku:

Thanks, it appears that `vim_starting' is available at least from version 5.8.

Текст сообщения:

> On 4 Sep., 08:23, Tom Link <[hidden email]> wrote:
> > Hi,
> >
> > Is there a general/standard way to determine whether vim is loading
> > (before VimEnter) or whether the startup was already completed?
> > Something like v:loading (similar to v:dying) maybe? I.e. how could I
> > distinguish whether a script/plugin is loaded during startup or by
> > means of a :source or :runtime command?
> >
> > Regards,
> > Tom
>
> has("vim_starting")

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Determine whether vim is loading or whether the VimEnter event was already fired

Tom Link-3
In reply to this post by anwoku
Hi,

> has("vim_starting")

It's probably worth mentioning that vim_starting is set to 0 before
the VimEnter event is triggered:

autocmd VimEnter * echom has('vim_starting')
=> 0

But that's ok.

Regards,
Tom

--
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