diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 4e55122916..05a4167b48 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -280,8 +280,8 @@ Name triggered by ~ Startup and exit |VimEnter| after doing all the startup stuff -|UIAttach| after a UI attaches -|UIDetach| after a UI detaches +|UIEnter| after a UI attaches +|UILeave| after a UI detaches |TermResponse| after the terminal response to t_RV is received |QuitPre| when using `:quit`, before deciding whether to exit |ExitPre| when using a command that may make Vim exit @@ -805,14 +805,14 @@ FuncUndefined When a user function is used but it isn't NOTE: When writing Vim scripts a better alternative is to use an autoloaded function. See |autoload-functions|. - *UIAttach* -UIAttach After a UI connects via |nvim_ui_attach()|, + *UIEnter* +UIEnter After a UI connects via |nvim_ui_attach()|, after VimEnter. Can be used for GUI-specific configuration. Sets these |v:event| keys: chan - *UIDetach* -UIDetach After a UI detaches from Nvim. + *UILeave* +UILeave After a UI disconnects from Nvim. Sets these |v:event| keys: chan *InsertChange* diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt index 77d687cf0f..b76a37810c 100644 --- a/runtime/doc/deprecated.txt +++ b/runtime/doc/deprecated.txt @@ -28,7 +28,7 @@ Environment Variables ~ Events ~ *EncodingChanged* Never fired; 'encoding' is always "utf-8". *FileEncoding* Never fired; equivalent to |EncodingChanged|. -*GUIEnter* Never fired; use |UIAttach| instead. +*GUIEnter* Never fired; use |UIEnter| instead. *GUIFailed* Never fired. Keycodes ~ diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt index bba38b7607..0df776010b 100644 --- a/runtime/doc/gui.txt +++ b/runtime/doc/gui.txt @@ -12,11 +12,11 @@ Nvim Graphical User Interface *gui* *GUI* Starting the GUI *gui-start* *E229* *E233* *ginit.vim* *gui-init* *gvimrc* *$MYGVIMRC* -For GUI-specific configuration Nvim provides the |UIAttach| event. This +For GUI-specific configuration Nvim provides the |UIEnter| event. This happens after other |initialization|s, like reading your vimrc file. Example: this sets "g:gui" to the value of the UI's "rgb" field: > - :autocmd UIAttach * let g:gui = filter(nvim_list_uis(),{k,v-> v.chan==v:event.chan})[0].rgb + :autocmd UIEnter * let g:gui = filter(nvim_list_uis(),{k,v-> v.chan==v:event.chan})[0].rgb < *:winp* *:winpos* *E188* diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index b96e9892a2..45a94bb961 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -154,8 +154,8 @@ Events: |TermClose| |TermOpen| |TextYankPost| - |UIAttach| - |UIDetach| + |UIEnter| + |UILeave| |VimResume| |VimSuspend| diff --git a/src/nvim/aucmd.c b/src/nvim/aucmd.c index 5188f96a5d..a9a7d834a4 100644 --- a/src/nvim/aucmd.c +++ b/src/nvim/aucmd.c @@ -13,7 +13,7 @@ # include "aucmd.c.generated.h" #endif -void do_autocmd_uiattach(uint64_t chanid, bool attached) +void do_autocmd_uienter(uint64_t chanid, bool attached) { static bool recursive = false; @@ -26,7 +26,7 @@ void do_autocmd_uiattach(uint64_t chanid, bool attached) assert(chanid < VARNUMBER_MAX); tv_dict_add_nr(dict, S_LEN("chan"), (varnumber_T)chanid); tv_dict_set_keys_readonly(dict); - apply_autocmds(attached ? EVENT_UIATTACH : EVENT_UIDETACH, + apply_autocmds(attached ? EVENT_UIENTER : EVENT_UILEAVE, NULL, NULL, false, curbuf); tv_dict_clear(dict); diff --git a/src/nvim/auevents.lua b/src/nvim/auevents.lua index 1505b984ad..c808af37b1 100644 --- a/src/nvim/auevents.lua +++ b/src/nvim/auevents.lua @@ -96,8 +96,8 @@ return { 'TextChangedI', -- text was modified in Insert mode(no popup) 'TextChangedP', -- text was modified in Insert mode(popup) 'TextYankPost', -- after a yank or delete was done (y, d, c) - 'UIAttach', -- after a UI attached - 'UIDetach', -- after a UI detaches + 'UIEnter', -- after UI attaches + 'UILeave', -- after UI detaches 'User', -- user defined autocommand 'VimEnter', -- after starting Vim 'VimLeave', -- before exiting Vim @@ -125,7 +125,7 @@ return { TabNewEntered=true, TermClose=true, TermOpen=true, - UIAttach=true, - UIDetach=true, + UIEnter=true, + UILeave=true, }, } diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 9ff2381189..79fa8b8223 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -296,7 +296,7 @@ void ui_attach_impl(UI *ui, uint64_t chanid) bool is_compositor = (ui == uis[0]); if (!is_compositor) { - do_autocmd_uiattach(chanid, true); + do_autocmd_uienter(chanid, true); } } @@ -333,7 +333,7 @@ void ui_detach_impl(UI *ui, uint64_t chanid) ui_comp_detach(ui); } - do_autocmd_uiattach(chanid, false); + do_autocmd_uienter(chanid, false); } void ui_set_ext_option(UI *ui, UIExtension ext, bool active) diff --git a/test/functional/api/ui_spec.lua b/test/functional/api/ui_spec.lua index f874fe44a5..c5c3185eff 100644 --- a/test/functional/api/ui_spec.lua +++ b/test/functional/api/ui_spec.lua @@ -36,21 +36,21 @@ describe('nvim_ui_attach()', function() end) end) -it('autocmds UIAttach/UIDetach', function() +it('autocmds UIEnter/UILeave', function() clear{args={ '--cmd', 'let g:evs = []', - '--cmd', 'autocmd UIAttach * :call add(g:evs, "UIAttach") | let g:ui_attach_ev = deepcopy(v:event)', - '--cmd', 'autocmd UIDetach * :call add(g:evs, "UIDetach") | let g:ui_detach_ev = deepcopy(v:event)', + '--cmd', 'autocmd UIEnter * :call add(g:evs, "UIEnter") | let g:uienter_ev = deepcopy(v:event)', + '--cmd', 'autocmd UILeave * :call add(g:evs, "UILeave") | let g:uileave_ev = deepcopy(v:event)', '--cmd', 'autocmd VimEnter * :call add(g:evs, "VimEnter")', }} local screen = Screen.new() screen:attach() - eq({chan=1}, eval('g:ui_attach_ev')) + eq({chan=1}, eval('g:uienter_ev')) screen:detach() - eq({chan=1}, eval('g:ui_detach_ev')) + eq({chan=1}, eval('g:uileave_ev')) eq({ 'VimEnter', - 'UIAttach', - 'UIDetach', + 'UIEnter', + 'UILeave', }, eval('g:evs')) end)