mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:7.4.1658
Problem: A plugin does not know when VimEnter autocommands were already
triggered.
Solution: Add the v:vim_did_enter variable.
1473551a44
This commit is contained in:
parent
4539d867d4
commit
9d2985ecba
@ -940,7 +940,15 @@ VimEnter After doing all the startup stuff, including
|
|||||||
loading vimrc files, executing the "-c cmd"
|
loading vimrc files, executing the "-c cmd"
|
||||||
arguments, creating all windows and loading
|
arguments, creating all windows and loading
|
||||||
the buffers in them.
|
the buffers in them.
|
||||||
*VimLeave*
|
Just before this event is triggered the
|
||||||
|
|v:vim_did_enter| variable is set, so that you
|
||||||
|
can do: >
|
||||||
|
if v:vim_did_enter
|
||||||
|
call s:init()
|
||||||
|
else
|
||||||
|
au VimEnter * call s:init()
|
||||||
|
endif
|
||||||
|
< *VimLeave*
|
||||||
VimLeave Before exiting Vim, just after writing the
|
VimLeave Before exiting Vim, just after writing the
|
||||||
.shada file. Executed only once, like
|
.shada file. Executed only once, like
|
||||||
VimLeavePre.
|
VimLeavePre.
|
||||||
|
@ -1765,6 +1765,10 @@ v:version Version number of Vim: Major version number times 100 plus
|
|||||||
version 5.0 and 5.1 may have a patch 123, but these are
|
version 5.0 and 5.1 may have a patch 123, but these are
|
||||||
completely different.
|
completely different.
|
||||||
|
|
||||||
|
*v:vim_did_enter* *vim_did_enter-variable*
|
||||||
|
v:vim_did_enter Zero until most of startup is done. It is set to one just
|
||||||
|
before |VimEnter| autocommands are triggered.
|
||||||
|
|
||||||
*v:warningmsg* *warningmsg-variable*
|
*v:warningmsg* *warningmsg-variable*
|
||||||
v:warningmsg Last given warning message. It's allowed to set this variable.
|
v:warningmsg Last given warning message. It's allowed to set this variable.
|
||||||
|
|
||||||
|
@ -384,6 +384,7 @@ static struct vimvar {
|
|||||||
VV(VV_NULL, "null", VAR_SPECIAL, VV_RO),
|
VV(VV_NULL, "null", VAR_SPECIAL, VV_RO),
|
||||||
VV(VV__NULL_LIST, "_null_list", VAR_LIST, VV_RO),
|
VV(VV__NULL_LIST, "_null_list", VAR_LIST, VV_RO),
|
||||||
VV(VV__NULL_DICT, "_null_dict", VAR_DICT, VV_RO),
|
VV(VV__NULL_DICT, "_null_dict", VAR_DICT, VV_RO),
|
||||||
|
VV(VV_VIM_DID_ENTER, "vim_did_enter", VAR_NUMBER, VV_RO),
|
||||||
};
|
};
|
||||||
#undef VV
|
#undef VV
|
||||||
|
|
||||||
|
@ -124,6 +124,7 @@ typedef enum {
|
|||||||
VV_NULL,
|
VV_NULL,
|
||||||
VV__NULL_LIST, // List with NULL value. For test purposes only.
|
VV__NULL_LIST, // List with NULL value. For test purposes only.
|
||||||
VV__NULL_DICT, // Dictionary with NULL value. For test purposes only.
|
VV__NULL_DICT, // Dictionary with NULL value. For test purposes only.
|
||||||
|
VV_VIM_DID_ENTER,
|
||||||
} VimVarIndex;
|
} VimVarIndex;
|
||||||
|
|
||||||
/// All recognized msgpack types
|
/// All recognized msgpack types
|
||||||
|
@ -511,6 +511,7 @@ int main(int argc, char **argv)
|
|||||||
if (p_im)
|
if (p_im)
|
||||||
need_start_insertmode = TRUE;
|
need_start_insertmode = TRUE;
|
||||||
|
|
||||||
|
set_vim_var_nr(VV_VIM_DID_ENTER, 1L);
|
||||||
apply_autocmds(EVENT_VIMENTER, NULL, NULL, FALSE, curbuf);
|
apply_autocmds(EVENT_VIMENTER, NULL, NULL, FALSE, curbuf);
|
||||||
TIME_MSG("VimEnter autocommands");
|
TIME_MSG("VimEnter autocommands");
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
" This makes testing go faster, since Vim doesn't need to restart.
|
" This makes testing go faster, since Vim doesn't need to restart.
|
||||||
|
|
||||||
source test_assign.vim
|
source test_assign.vim
|
||||||
|
source test_autocmd.vim
|
||||||
source test_cursor_func.vim
|
source test_cursor_func.vim
|
||||||
source test_ex_undo.vim
|
source test_ex_undo.vim
|
||||||
source test_expr.vim
|
source test_expr.vim
|
||||||
|
8
src/nvim/testdir/test_autocmd.vim
Normal file
8
src/nvim/testdir/test_autocmd.vim
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
" Tests for autocommands
|
||||||
|
|
||||||
|
func Test_vim_did_enter()
|
||||||
|
call assert_false(v:vim_did_enter)
|
||||||
|
|
||||||
|
" This script will never reach the main loop, can't check if v:vim_did_enter
|
||||||
|
" becomes one.
|
||||||
|
endfunc
|
@ -786,7 +786,7 @@ static int included_patches[] = {
|
|||||||
// 1661 NA
|
// 1661 NA
|
||||||
// 1660,
|
// 1660,
|
||||||
// 1659 NA
|
// 1659 NA
|
||||||
// 1658,
|
1658,
|
||||||
// 1657 NA
|
// 1657 NA
|
||||||
// 1656,
|
// 1656,
|
||||||
// 1655 NA
|
// 1655 NA
|
||||||
|
@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
|
|||||||
|
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
|
local eq = helpers.eq
|
||||||
local eval = helpers.eval
|
local eval = helpers.eval
|
||||||
|
|
||||||
describe('autocmds:', function()
|
describe('autocmds:', function()
|
||||||
@ -28,4 +29,8 @@ describe('autocmds:', function()
|
|||||||
command('tabnew')
|
command('tabnew')
|
||||||
assert.same(expected, eval('g:foo'))
|
assert.same(expected, eval('g:foo'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('v:vim_did_enter is 1 after VimEnter', function()
|
||||||
|
eq(1, eval('v:vim_did_enter'))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user