aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/aucmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/aucmd.c')
-rw-r--r--src/nvim/aucmd.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/nvim/aucmd.c b/src/nvim/aucmd.c
index 32c77fa288..af519dcba9 100644
--- a/src/nvim/aucmd.c
+++ b/src/nvim/aucmd.c
@@ -1,15 +1,16 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
-#include "nvim/os/os.h"
-#include "nvim/fileio.h"
-#include "nvim/vim.h"
-#include "nvim/main.h"
-#include "nvim/ui.h"
#include "nvim/aucmd.h"
+#include "nvim/buffer.h"
#include "nvim/eval.h"
+#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
-#include "nvim/buffer.h"
+#include "nvim/fileio.h"
+#include "nvim/main.h"
+#include "nvim/os/os.h"
+#include "nvim/ui.h"
+#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "aucmd.c.generated.h"
@@ -35,6 +36,29 @@ 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 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 [:>] syntax sync minlines=1 maxlines=1");
+ do_cmdline_cmd("augroup END");
+}
+
static void focusgained_event(void **argv)
{
bool *gainedp = argv[0];