mirror of
https://github.com/neovim/neovim.git
synced 2025-11-15 23:01:24 +00:00
vim-patch:9.1.1892: Not possible to know once Vim is done with sourcing vimrc (#36429)
Problem: A plugin does not know when startup scripts were already
triggered. This is useful to determine if a function is
called inside vimrc or after (like when sourcing 'plugin/'
files).
Solution: Add the v:vim_did_init variable (Evgeni Chasnovski)
closes: vim/vim#18668
294bce21ee
Nvim has two more steps between sourcing startup scripts and loading
plugins. Set this variable after these two steps.
Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
This commit is contained in:
@@ -367,6 +367,7 @@ VIMSCRIPT
|
||||
• |getcompletiontype()| gets command-line completion type for any string.
|
||||
• |prompt_getinput()| gets current user-input in prompt-buffer.
|
||||
• |wildtrigger()| triggers command-line expansion.
|
||||
• |v:vim_did_init| is set after sourcing |init.vim| but before |load-plugins|.
|
||||
|
||||
==============================================================================
|
||||
CHANGED FEATURES *news-changed*
|
||||
|
||||
@@ -301,6 +301,12 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|.
|
||||
each directory is inserted before others), after
|
||||
loading the ftdetect scripts.
|
||||
|
||||
To programmatically decide if `!` is needed during
|
||||
startup, check |v:vim_did_init|: use `!` if 0 (to not
|
||||
duplicate |load-plugins| step), no `!` otherwise (to
|
||||
force load plugin files as otherwise they won't be
|
||||
loaded automatically).
|
||||
|
||||
*:packl* *:packloadall*
|
||||
:packl[oadall][!] Load all packages in the "start" directory under each
|
||||
entry in 'packpath'.
|
||||
|
||||
@@ -517,7 +517,9 @@ accordingly, proceeding as follows:
|
||||
< Skipped if ":syntax off" was called or if the "-u NONE" command
|
||||
line argument was given.
|
||||
|
||||
10. Load the plugin scripts. *load-plugins*
|
||||
10. Set the |v:vim_did_init| variable to 1.
|
||||
|
||||
11. Load the plugin scripts. *load-plugins*
|
||||
This does the same as the command: >
|
||||
:runtime! plugin/**/*.{vim,lua}
|
||||
< The result is that all directories in 'runtimepath' will be searched
|
||||
@@ -547,21 +549,21 @@ accordingly, proceeding as follows:
|
||||
if packages have been found, but that should not add a directory
|
||||
ending in "after".
|
||||
|
||||
11. Set 'shellpipe' and 'shellredir'
|
||||
12. Set 'shellpipe' and 'shellredir'
|
||||
The 'shellpipe' and 'shellredir' options are set according to the
|
||||
value of the 'shell' option, unless they have been set before.
|
||||
This means that Nvim will figure out the values of 'shellpipe' and
|
||||
'shellredir' for you, unless you have set them yourself.
|
||||
|
||||
12. Set 'updatecount' to zero, if "-n" command argument used.
|
||||
13. Set 'updatecount' to zero, if "-n" command argument used.
|
||||
|
||||
13. Set binary options if the |-b| flag was given.
|
||||
14. Set binary options if the |-b| flag was given.
|
||||
|
||||
14. Read the |shada-file|.
|
||||
15. Read the |shada-file|.
|
||||
|
||||
15. Read the quickfix file if the |-q| flag was given, or exit on failure.
|
||||
16. Read the quickfix file if the |-q| flag was given, or exit on failure.
|
||||
|
||||
16. Open all windows
|
||||
17. Open all windows
|
||||
When the |-o| flag was given, windows will be opened (but not
|
||||
displayed yet).
|
||||
When the |-p| flag was given, tab pages will be created (but not
|
||||
@@ -571,7 +573,7 @@ accordingly, proceeding as follows:
|
||||
Buffers for all windows will be loaded, without triggering |BufAdd|
|
||||
autocommands.
|
||||
|
||||
17. Execute startup commands
|
||||
18. Execute startup commands
|
||||
If a |-t| flag was given, the tag is jumped to.
|
||||
Commands given with |-c| and |+cmd| are executed.
|
||||
The starting flag is reset, has("vim_starting") will now return zero.
|
||||
|
||||
@@ -744,6 +744,12 @@ v:versionlong
|
||||
*v:vim_did_enter* *vim_did_enter-variable*
|
||||
v:vim_did_enter
|
||||
0 during startup, 1 just before |VimEnter|.
|
||||
Read-only.
|
||||
|
||||
*v:vim_did_init* *vim_did_init-variable*
|
||||
v:vim_did_init
|
||||
0 during initialization, 1 after sourcing |vimrc| and just
|
||||
before |load-plugins|.
|
||||
Read-only.
|
||||
|
||||
*v:virtnum* *virtnum-variable*
|
||||
|
||||
Reference in New Issue
Block a user