mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
vim-patch:8.0.1777: cannot cleanup before loading another colorscheme (#9104)
Problem: Cannot cleanup before loading another colorscheme.
Solution: Add the ColorSchemePre autocommand event.
60a68362aa
This commit is contained in:
parent
e17e21e4cf
commit
2bf1aa5628
@ -42,7 +42,16 @@ this autocmd might be useful:
|
|||||||
Replace "blue_sky" with the name of the colorscheme.
|
Replace "blue_sky" with the name of the colorscheme.
|
||||||
|
|
||||||
In case you want to tweak a colorscheme after it was loaded, check out the
|
In case you want to tweak a colorscheme after it was loaded, check out the
|
||||||
ColorScheme autocmd event.
|
ColorScheme autocommand event.
|
||||||
|
|
||||||
|
To clean up just before loading another colorscheme, use the ColorSchemePre
|
||||||
|
autocommand event. For example:
|
||||||
|
let g:term_ansi_colors = ...
|
||||||
|
augroup MyColorscheme
|
||||||
|
au!
|
||||||
|
au ColorSchemePre * unlet g:term_ansi_colors
|
||||||
|
au ColorSchemePre * au! MyColorscheme
|
||||||
|
augroup END
|
||||||
|
|
||||||
To customize a colorscheme use another name, e.g. "~/.vim/colors/mine.vim",
|
To customize a colorscheme use another name, e.g. "~/.vim/colors/mine.vim",
|
||||||
and use `:runtime` to load the original colorscheme:
|
and use `:runtime` to load the original colorscheme:
|
||||||
|
@ -27,6 +27,7 @@ return {
|
|||||||
'CmdWinEnter', -- after entering the cmdline window
|
'CmdWinEnter', -- after entering the cmdline window
|
||||||
'CmdWinLeave', -- before leaving the cmdline window
|
'CmdWinLeave', -- before leaving the cmdline window
|
||||||
'ColorScheme', -- after loading a colorscheme
|
'ColorScheme', -- after loading a colorscheme
|
||||||
|
'ColorSchemePre', -- before loading a colorscheme
|
||||||
'CompleteDone', -- after finishing insert complete
|
'CompleteDone', -- after finishing insert complete
|
||||||
'CursorHold', -- cursor in same position for a while
|
'CursorHold', -- cursor in same position for a while
|
||||||
'CursorHoldI', -- idem, in Insert mode
|
'CursorHoldI', -- idem, in Insert mode
|
||||||
|
@ -6779,7 +6779,9 @@ static bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io,
|
|||||||
* invalid.
|
* invalid.
|
||||||
*/
|
*/
|
||||||
if (fname_io == NULL) {
|
if (fname_io == NULL) {
|
||||||
if (event == EVENT_COLORSCHEME || event == EVENT_OPTIONSET) {
|
if (event == EVENT_COLORSCHEME
|
||||||
|
|| event == EVENT_COLORSCHEMEPRE
|
||||||
|
|| event == EVENT_OPTIONSET) {
|
||||||
autocmd_fname = NULL;
|
autocmd_fname = NULL;
|
||||||
} else if (fname != NULL && !ends_excmd(*fname)) {
|
} else if (fname != NULL && !ends_excmd(*fname)) {
|
||||||
autocmd_fname = fname;
|
autocmd_fname = fname;
|
||||||
@ -6830,6 +6832,7 @@ static bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io,
|
|||||||
sfname = vim_strsave(fname);
|
sfname = vim_strsave(fname);
|
||||||
// Don't try expanding the following events.
|
// Don't try expanding the following events.
|
||||||
if (event == EVENT_COLORSCHEME
|
if (event == EVENT_COLORSCHEME
|
||||||
|
|| event == EVENT_COLORSCHEMEPRE
|
||||||
|| event == EVENT_DIRCHANGED
|
|| event == EVENT_DIRCHANGED
|
||||||
|| event == EVENT_FILETYPE
|
|| event == EVENT_FILETYPE
|
||||||
|| event == EVENT_FUNCUNDEFINED
|
|| event == EVENT_FUNCUNDEFINED
|
||||||
|
@ -6326,6 +6326,7 @@ int load_colors(char_u *name)
|
|||||||
recursive = true;
|
recursive = true;
|
||||||
size_t buflen = STRLEN(name) + 12;
|
size_t buflen = STRLEN(name) + 12;
|
||||||
buf = xmalloc(buflen);
|
buf = xmalloc(buflen);
|
||||||
|
apply_autocmds(EVENT_COLORSCHEMEPRE, name, curbuf->b_fname, false, curbuf);
|
||||||
snprintf((char *)buf, buflen, "colors/%s.vim", name);
|
snprintf((char *)buf, buflen, "colors/%s.vim", name);
|
||||||
retval = source_runtime(buf, DIP_START + DIP_OPT);
|
retval = source_runtime(buf, DIP_START + DIP_OPT);
|
||||||
xfree(buf);
|
xfree(buf);
|
||||||
|
Loading…
Reference in New Issue
Block a user