mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Add TabNew event
TabNew triggers when entering a new tab page, but not when entering an already created one.
This commit is contained in:
parent
0429857689
commit
817be96be5
@ -296,6 +296,7 @@ Name triggered by ~
|
||||
|WinLeave| before leaving a window
|
||||
|TabEnter| after entering another tab page
|
||||
|TabLeave| before leaving a tab page
|
||||
|TabNew| when creating a new tab page
|
||||
|CmdwinEnter| after entering the command-line window
|
||||
|CmdwinLeave| before leaving the command-line window
|
||||
|
||||
@ -859,6 +860,10 @@ TabEnter Just after entering a tab page. |tab-page|
|
||||
TabLeave Just before leaving a tab page. |tab-page|
|
||||
A WinLeave event will have been triggered
|
||||
first.
|
||||
*TabNew*
|
||||
TabNew When creating a new tab page. |tab-page|
|
||||
After WinEnter and before TabEnter.
|
||||
|
||||
*TermChanged*
|
||||
TermChanged After the value of 'term' has changed. Useful
|
||||
for re-loading the syntax file to update the
|
||||
|
@ -251,6 +251,9 @@ When switching to another tab page the order is:
|
||||
WinEnter
|
||||
BufEnter
|
||||
|
||||
When entering a new tab page (|:tabnew|), TabNew is triggered before TabEnter
|
||||
and after WinEnter.
|
||||
|
||||
==============================================================================
|
||||
4. Setting 'tabline' *setting-tabline*
|
||||
|
||||
|
@ -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 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 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
|
||||
|
@ -5715,6 +5715,8 @@ void ex_splitview(exarg_T *eap)
|
||||
if (win_new_tabpage(cmdmod.tab != 0 ? cmdmod.tab
|
||||
: 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);
|
||||
|
||||
/* set the alternate buffer for the window we came from */
|
||||
|
@ -5247,6 +5247,7 @@ static struct event_name {
|
||||
{"Syntax", EVENT_SYNTAX},
|
||||
{"TabEnter", EVENT_TABENTER},
|
||||
{"TabLeave", EVENT_TABLEAVE},
|
||||
{"TabNew", EVENT_TABNEW},
|
||||
{"TermChanged", EVENT_TERMCHANGED},
|
||||
{"TermResponse", EVENT_TERMRESPONSE},
|
||||
{"TextChanged", EVENT_TEXTCHANGED},
|
||||
|
@ -95,6 +95,7 @@ typedef enum auto_event {
|
||||
EVENT_CURSORMOVEDI, /* cursor was moved in Insert mode */
|
||||
EVENT_TABLEAVE, /* before leaving a tab page */
|
||||
EVENT_TABENTER, /* after entering a tab page */
|
||||
EVENT_TABNEW, /* when creating a new tab */
|
||||
EVENT_SHELLCMDPOST, /* after ":!cmd" */
|
||||
EVENT_SHELLFILTERPOST, /* after ":1,2!cmd", ":w !cmd", ":r !cmd". */
|
||||
EVENT_TEXTCHANGED, /* text was modified */
|
||||
|
24
test/functional/autocmd/tabnew_spec.lua
Normal file
24
test/functional/autocmd/tabnew_spec.lua
Normal file
@ -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('TabNew', function()
|
||||
describe('au TabNew', function()
|
||||
clear()
|
||||
describe('with * as <afile>', function()
|
||||
it('matches when opening any new tab', function()
|
||||
nvim('command', 'au! TabNew * echom "tabnew:".tabpagenr().":".bufnr("")')
|
||||
eq("\ntabnew:2:1", nvim('command_output', 'tabnew'))
|
||||
eq("\ntabnew:3:2\n\"test.x\" [New File]", nvim('command_output', 'tabnew test.x'))
|
||||
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! TabNew '..tmp_path..' echom "tabnew:match"')
|
||||
eq("\ntabnew:4:3\ntabnew:match\n\""..tmp_path.."\" [New File]", nvim('command_output', 'tabnew '..tmp_path))
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
end)
|
Loading…
Reference in New Issue
Block a user