aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/autocmd.txt5
-rw-r--r--runtime/syntax/vim.vim2
-rw-r--r--src/nvim/ex_docmd.c2
-rw-r--r--src/nvim/fileio.c1
-rw-r--r--src/nvim/fileio.h1
-rw-r--r--test/functional/autocmd/tabnewentered_spec.lua24
6 files changed, 32 insertions, 3 deletions
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index c86a244a5e..9d645d435d 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -297,6 +297,7 @@ Name triggered by ~
|TabEnter| after entering another tab page
|TabLeave| before leaving a tab page
|TabNew| when creating a new tab page
+|TabNewEntered| after entering a new tab page
|CmdwinEnter| after entering the command-line window
|CmdwinLeave| before leaving the command-line window
@@ -863,7 +864,9 @@ TabLeave Just before leaving a tab page. |tab-page|
*TabNew*
TabNew When creating a new tab page. |tab-page|
After WinEnter and before TabEnter.
-
+ *TabNewEntered*
+TabNewEntered After entering a new tab page. |tab-page|
+ After BufEnter.
*TermChanged*
TermChanged After the value of 'term' has changed. Useful
for re-loading the syntax file to update the
diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim
index d9f3c85921..7d6a4b91a5 100644
--- a/runtime/syntax/vim.vim
+++ b/runtime/syntax/vim.vim
@@ -76,7 +76,7 @@ syn keyword vimErrSetting contained hardtabs ht w1200 w300 w9600
" AutoCmd Events {{{2
syn case ignore
-syn keyword vimAutoEvent contained BufAdd BufCreate BufDelete BufEnter BufFilePost BufFilePre BufHidden BufLeave BufNew BufNewFile BufRead BufReadCmd BufReadPost BufReadPre BufUnload BufWinEnter BufWinLeave BufWipeout BufWrite BufWriteCmd BufWritePost BufWritePre Cmd-event CmdwinEnter CmdwinLeave ColorScheme CompleteDone CursorHold CursorHoldI CursorMoved CursorMovedI EncodingChanged FileAppendCmd FileAppendPost FileAppendPre FileChangedRO FileChangedShell FileChangedShellPost FileEncoding FileReadCmd FileReadPost FileReadPre FileType FileWriteCmd FileWritePost FileWritePre FilterReadPost FilterReadPre FilterWritePost FilterWritePre FocusGained FocusLost FuncUndefined GUIEnter GUIFailed InsertChange InsertCharPre InsertEnter InsertLeave JobActivity MenuPopup QuickFixCmdPost QuickFixCmdPre QuitPre RemoteReply SessionLoadPost ShellCmdPost ShellFilterPost SourceCmd SourcePre SpellFileMissing StdinReadPost StdinReadPre SwapExists Syntax TabEnter TabLeave TabNew TermChanged TermResponse TextChanged TextChangedI User UserGettingBored VimEnter VimLeave VimLeavePre VimResized WinEnter WinLeave
+syn keyword vimAutoEvent contained BufAdd BufCreate BufDelete BufEnter BufFilePost BufFilePre BufHidden BufLeave BufNew BufNewFile BufRead BufReadCmd BufReadPost BufReadPre BufUnload BufWinEnter BufWinLeave BufWipeout BufWrite BufWriteCmd BufWritePost BufWritePre Cmd-event CmdwinEnter CmdwinLeave ColorScheme CompleteDone CursorHold CursorHoldI CursorMoved CursorMovedI EncodingChanged FileAppendCmd FileAppendPost FileAppendPre FileChangedRO FileChangedShell FileChangedShellPost FileEncoding FileReadCmd FileReadPost FileReadPre FileType FileWriteCmd FileWritePost FileWritePre FilterReadPost FilterReadPre FilterWritePost FilterWritePre FocusGained FocusLost FuncUndefined GUIEnter GUIFailed InsertChange InsertCharPre InsertEnter InsertLeave JobActivity MenuPopup QuickFixCmdPost QuickFixCmdPre QuitPre RemoteReply SessionLoadPost ShellCmdPost ShellFilterPost SourceCmd SourcePre SpellFileMissing StdinReadPost StdinReadPre SwapExists Syntax TabEnter TabLeave TabNew TabNewEntered TermChanged TermResponse TextChanged TextChangedI User UserGettingBored VimEnter VimLeave VimLeavePre VimResized WinEnter WinLeave
" Highlight commonly used Groupnames {{{2
syn keyword vimGroup contained Comment Constant String Character Number Boolean Float Identifier Function Statement Conditional Repeat Label Operator Keyword Exception PreProc Include Define Macro PreCondit Type StorageClass Structure Typedef Special SpecialChar Tag Delimiter SpecialComment Debug Underlined Ignore Error Todo
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 9d2285acb5..189881be34 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -5716,8 +5716,8 @@ void ex_splitview(exarg_T *eap)
: eap->addr_count == 0 ? 0
: (int)eap->line2 + 1) != FAIL) {
apply_autocmds(EVENT_TABNEW, eap->arg, eap->arg, FALSE, curbuf);
- entering_new_tab = true;
do_exedit(eap, old_curwin);
+ apply_autocmds(EVENT_TABNEWENTERED, NULL, NULL, FALSE, curbuf);
/* set the alternate buffer for the window we came from */
if (curwin != old_curwin
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index c8944fffe4..6aeb36b719 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -5248,6 +5248,7 @@ static struct event_name {
{"TabEnter", EVENT_TABENTER},
{"TabLeave", EVENT_TABLEAVE},
{"TabNew", EVENT_TABNEW},
+ {"TabNewEntered", EVENT_TABNEWENTERED},
{"TermChanged", EVENT_TERMCHANGED},
{"TermResponse", EVENT_TERMRESPONSE},
{"TextChanged", EVENT_TEXTCHANGED},
diff --git a/src/nvim/fileio.h b/src/nvim/fileio.h
index 134759577c..48d96760db 100644
--- a/src/nvim/fileio.h
+++ b/src/nvim/fileio.h
@@ -96,6 +96,7 @@ typedef enum auto_event {
EVENT_TABLEAVE, /* before leaving a tab page */
EVENT_TABENTER, /* after entering a tab page */
EVENT_TABNEW, /* when creating a new tab */
+ EVENT_TABNEWENTERED, /* after entering a new tab */
EVENT_SHELLCMDPOST, /* after ":!cmd" */
EVENT_SHELLFILTERPOST, /* after ":1,2!cmd", ":w !cmd", ":r !cmd". */
EVENT_TEXTCHANGED, /* text was modified */
diff --git a/test/functional/autocmd/tabnewentered_spec.lua b/test/functional/autocmd/tabnewentered_spec.lua
new file mode 100644
index 0000000000..f220c15ef7
--- /dev/null
+++ b/test/functional/autocmd/tabnewentered_spec.lua
@@ -0,0 +1,24 @@
+local helpers = require('test.functional.helpers')
+local clear, nvim, buffer, curbuf, curwin, eq, neq, ok =
+ helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
+ helpers.eq, helpers.neq, helpers.ok
+
+describe('TabNewEntered', function()
+ describe('au TabNewEntered', function()
+ describe('with * as <afile>', function()
+ it('matches when entering any new tab', function()
+ clear()
+ nvim('command', 'au! TabNewEntered * echom "tabnewentered:".tabpagenr().":".bufnr("")')
+ eq("\ntabnewentered:2:2", nvim('command_output', 'tabnew'))
+ eq("\n\"test.x2\" [New File]\ntabnewentered:3:3", nvim('command_output', 'tabnew test.x2'))
+ end)
+ end)
+ describe('with FILE as <afile>', function()
+ it('matches when opening a new tab for FILE', function()
+ tmp_path = nvim('eval', 'tempname()')
+ nvim('command', 'au! TabNewEntered '..tmp_path..' echom "tabnewentered:match"')
+ eq("\n\""..tmp_path.."\" [New File]\ntabnewentered:4:4\ntabnewentered:match", nvim('command_output', 'tabnew '..tmp_path))
+ end)
+ end)
+ end)
+end)