mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
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
This commit is contained in:
parent
50b30de200
commit
a90513c24b
@ -4931,7 +4931,8 @@ static void nv_ident(cmdarg_T *cap)
|
|||||||
snprintf(buf, buf_size, ".,.+%" PRId64, (int64_t)(cap->count0 - 1));
|
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) {
|
if (cap->count0 == 0 && isman_s) {
|
||||||
STRCAT(buf, "man");
|
STRCAT(buf, "man");
|
||||||
} else {
|
} else {
|
||||||
@ -5028,6 +5029,17 @@ static void nv_ident(cmdarg_T *cap)
|
|||||||
g_tag_at_cursor = true;
|
g_tag_at_cursor = true;
|
||||||
do_cmdline_cmd(buf);
|
do_cmdline_cmd(buf);
|
||||||
g_tag_at_cursor = false;
|
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);
|
xfree(buf);
|
||||||
|
@ -1227,7 +1227,7 @@ func Test_normal23_K()
|
|||||||
set iskeyword-=\|
|
set iskeyword-=\|
|
||||||
|
|
||||||
" Only expect "man" to work on Unix
|
" Only expect "man" to work on Unix
|
||||||
if !has("unix")
|
if !has("unix") || has('nvim') " Nvim K uses :terminal. #15398
|
||||||
let &keywordprg = k
|
let &keywordprg = k
|
||||||
bw!
|
bw!
|
||||||
return
|
return
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local eq, clear, eval, feed =
|
local eq, clear, eval, feed, retry =
|
||||||
helpers.eq, helpers.clear, helpers.eval, helpers.feed
|
helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.retry
|
||||||
|
|
||||||
describe('K', function()
|
describe('K', function()
|
||||||
local test_file = 'K_spec_out'
|
local test_file = 'K_spec_out'
|
||||||
@ -31,7 +31,7 @@ describe('K', function()
|
|||||||
|
|
||||||
-- K on the text "K_spec_out" resolves to `!echo fnord >> K_spec_out`.
|
-- K on the text "K_spec_out" resolves to `!echo fnord >> K_spec_out`.
|
||||||
feed('i'..test_file..'<ESC>K')
|
feed('i'..test_file..'<ESC>K')
|
||||||
feed('<CR>') -- Press ENTER
|
retry(nil, nil, function() eq(1, eval('filereadable("'..test_file..'")')) end)
|
||||||
eq({'fnord'}, eval("readfile('"..test_file.."')"))
|
eq({'fnord'}, eval("readfile('"..test_file.."')"))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user