diff options
author | Gregory Anders <greg@gpanders.com> | 2021-08-21 18:23:10 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-21 17:23:10 -0700 |
commit | a90513c24bd8f789fba980509a4bdd1d7fc890ec (patch) | |
tree | f9fde7550a74e0ebc2bbfe6b9be67386e4258959 /src | |
parent | 50b30de2007961718cc11811a30f6b0f35c3c793 (diff) | |
download | rneovim-a90513c24bd8f789fba980509a4bdd1d7fc890ec.tar.gz rneovim-a90513c24bd8f789fba980509a4bdd1d7fc890ec.tar.bz2 rneovim-a90513c24bd8f789fba980509a4bdd1d7fc890ec.zip |
feat(keywordprg): use :terminal for external commands #15398
Open external 'keywordprg' commands in a :terminal in a new tab. <Esc> is
mapped to stop the job and close the buffer.
Closes #2995
Closes #2761
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/normal.c | 14 | ||||
-rw-r--r-- | src/nvim/testdir/test_normal.vim | 2 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 2a530db934..7b2f77a6f9 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -4931,7 +4931,8 @@ static void nv_ident(cmdarg_T *cap) snprintf(buf, buf_size, ".,.+%" PRId64, (int64_t)(cap->count0 - 1)); } - STRCAT(buf, "! "); + do_cmdline_cmd("tabnew"); + STRCAT(buf, "terminal "); if (cap->count0 == 0 && isman_s) { STRCAT(buf, "man"); } else { @@ -5028,6 +5029,17 @@ static void nv_ident(cmdarg_T *cap) g_tag_at_cursor = true; do_cmdline_cmd(buf); g_tag_at_cursor = false; + + if (cmdchar == 'K' && !kp_ex && !kp_help) { + // Start insert mode in terminal buffer + restart_edit = 'i'; + + add_map((char_u *)"<buffer> <esc> <Cmd>call jobstop(&channel)<CR>", TERM_FOCUS, true); + do_cmdline_cmd("autocmd TermClose <buffer> " + " if !v:event.status |" + " exec 'bdelete! ' .. expand('<abuf>') |" + " endif"); + } } xfree(buf); diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index 5c413d1e16..aff22f5d01 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -1227,7 +1227,7 @@ func Test_normal23_K() set iskeyword-=\| " Only expect "man" to work on Unix - if !has("unix") + if !has("unix") || has('nvim') " Nvim K uses :terminal. #15398 let &keywordprg = k bw! return |