mirror of
https://github.com/neovim/neovim.git
synced 2025-10-18 07:41:51 +00:00
feat(defaults): limit syntax cost on CmdwinEnter #15401
Add a new default autocommand to limit syntax highlighting synchronization in the command window. This refactors the nvim_terminal autocommand out of main() and into a new init_default_autocmds() function, which is now part of the startup process and can be further extended with more default autocommands down the road. ref #6289 #6399
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "nvim/ui.h"
|
||||
#include "nvim/aucmd.h"
|
||||
#include "nvim/eval.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/ex_getln.h"
|
||||
#include "nvim/buffer.h"
|
||||
|
||||
@@ -35,6 +36,30 @@ void do_autocmd_uienter(uint64_t chanid, bool attached)
|
||||
recursive = false;
|
||||
}
|
||||
|
||||
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!");
|
||||
do_cmdline_cmd("autocmd BufReadCmd " PROTO "* ++nested "
|
||||
"if !exists('b:term_title')|call termopen("
|
||||
// Capture the command string
|
||||
"matchstr(expand(\"<amatch>\"), "
|
||||
"'\\c\\m" PROTO "\\%(.\\{-}//\\%(\\d\\+:\\)\\?\\)\\?\\zs.*'), "
|
||||
// capture the working directory
|
||||
"{'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 [:>] exe 'syntax sync minlines=1 maxlines='..&cmdwinheight");
|
||||
do_cmdline_cmd("augroup END");
|
||||
}
|
||||
|
||||
static void focusgained_event(void **argv)
|
||||
{
|
||||
bool *gainedp = argv[0];
|
||||
|
Reference in New Issue
Block a user