mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 11:15:14 -07:00
refactor(aucmd): call define_autocmd() directly for default autocmds
This commit is contained in:
parent
83170a4986
commit
7ab2e12ebc
@ -2707,14 +2707,21 @@ static void do_autocmd_focusgained(bool gained)
|
||||
recursive = false;
|
||||
}
|
||||
|
||||
// initialization
|
||||
static void define_autocmd(event_T event, char *pat, char *group, bool once, bool nested, char *cmd)
|
||||
{
|
||||
AucmdExecutable exec = AUCMD_EXECUTABLE_INIT;
|
||||
exec.type = CALLABLE_EX;
|
||||
exec.callable.cmd = cmd; // autocmd_register() makes a copy
|
||||
int group_id = augroup_add(group);
|
||||
autocmd_register(0, event, pat, (int)strlen(pat), group_id, once, nested, NULL, exec);
|
||||
}
|
||||
|
||||
/// initialization of default autocmds
|
||||
void init_default_autocmds(void)
|
||||
{
|
||||
// open terminals when opening files that start with term://
|
||||
#define PROTO "term://"
|
||||
do_cmdline_cmd("augroup nvim_terminal");
|
||||
do_cmdline_cmd("autocmd BufReadCmd " PROTO "* ++nested "
|
||||
define_autocmd(EVENT_BUFREADCMD, PROTO "*", "nvim_terminal", false, true,
|
||||
"if !exists('b:term_title')|call termopen("
|
||||
// Capture the command string
|
||||
"matchstr(expand(\"<amatch>\"), "
|
||||
@ -2723,11 +2730,8 @@ void init_default_autocmds(void)
|
||||
"{'cwd': expand(get(matchlist(expand(\"<amatch>\"), "
|
||||
"'\\c\\m" PROTO "\\(.\\{-}\\)//'), 1, ''))})"
|
||||
"|endif");
|
||||
do_cmdline_cmd("augroup END");
|
||||
#undef PROTO
|
||||
|
||||
// limit syntax synchronization in the command window
|
||||
do_cmdline_cmd("augroup nvim_cmdwin");
|
||||
do_cmdline_cmd("autocmd! CmdwinEnter [:>] syntax sync minlines=1 maxlines=1");
|
||||
do_cmdline_cmd("augroup END");
|
||||
define_autocmd(EVENT_CMDWINENTER, "[:>]", "nvim_cmdwin", false, false,
|
||||
"syntax sync minlines=1 maxlines=1");
|
||||
}
|
||||
|
@ -499,11 +499,11 @@ describe('sysinit', function()
|
||||
[[" -u NONE -i NONE --cmd "set noruler" -D')]])
|
||||
screen:expect([[
|
||||
^ |
|
||||
|
|
||||
Entering Debug mode. Type "cont" to continue. |
|
||||
cmd: augroup nvim_terminal |
|
||||
pre-vimrc command line |
|
||||
cmd: set noruler |
|
||||
> |
|
||||
<" -u NONE -i NONE --cmd "set noruler" -D 1,0-1 All|
|
||||
<" -u NONE -i NONE --cmd "set noruler" -D 1,1 All|
|
||||
|
|
||||
]])
|
||||
command([[call chansend(g:id, "cont\n")]])
|
||||
|
Loading…
Reference in New Issue
Block a user