commit b64d2078eb5da1e9729c5fa5894547d450bc9e67
parent e70bc581f04e7b75851c0915ae7f3d281f830192
Author: Daniel Moch <daniel@danielmoch.com>
Date: Fri, 5 May 2017 12:18:34 -0400
Add <C-c> buffer local mapping for :MakeJobStop
Diffstat:
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
@@ -3,7 +3,7 @@
This is a plugin for folks who think that Vim's quickfix feature is
great, but who don't like how calls to `:make` and `:grep` freeze the
editor. _MakeJob_ implements asynchronous versions of the builtin
-commands in just over 150 lines of Vimscript.
+commands in just a couple hundred lines of Vimscript.
## Goals
1. Implement a minimal solution for asynchronous `:make` and `:grep`.
@@ -38,7 +38,10 @@ while _MakeJob_ runs.
If _MakeJob_ reports findings, use `:copen` to view the Quickfix window
(in the case of `:MakeJob`), and likewise `:lopen` to open the LocationList
-for `:LmakeJob`. There's also `:MakeJobStop` to stop a running MakeJob.
+for `:LmakeJob`. If the current buffer is showing the output of a
+running MakeJob, or if it spawned a running MakeJob, then `<C-c>` stops
+it. There's also `:MakeJobStop` to stop an arbitrary MakeJob (with
+command completion).
Speaking of `:LmakeJob`, all of the LocationList complements to the
Quickfix commands are there with _MakeJob_, bringing the full list of
diff --git a/doc/makejob.txt b/doc/makejob.txt
@@ -8,7 +8,7 @@ License: MIT (see LICENSE file for details)
This is a plugin for folks who think that Vim's quickfix feature is
great, but who don't like how calls to |:make| and |:grep| freeze the
editor. MakeJob implements asynchronous versions of the builtin
-commands in just over 150 lines of Vimscript.
+commands in just a couple hundred lines of Vimscript.
1. Commands |makejob-commands|
2. Configuration |makejob-configuration|
@@ -22,7 +22,7 @@ commands in just over 150 lines of Vimscript.
Here are your new quickfix commands.
*makejob-MakeJob* *:MakeJob*
-MakeJob[!] [{filename}] Start a makejob on the specified buffer,
+MakeJob[!] [{filename}] Start a MakeJob on the specified buffer,
populating findings in the quickfix list.
|makeprg| and |errorformat| must be set before
MakeJob is called. {filename}, if specified, is
@@ -35,6 +35,11 @@ MakeJob[!] [{filename}] Start a makejob on the specified buffer,
buffer. If [!] is not given, the first error is
jumped to.
+ <C-c> can be used in normal mode to cancel a
+ running MakeJob, provided the current buffer
+ either spawned it or is showing its output.
+ Otherwise |:MakeJobStop| can be used.
+
*makejob-LmakeJob* *:LmakeJob*
LmakeJob[!] [{filename}] Same as ":MakeJob", except the location list for
the current window is used instead of the quickfix
diff --git a/plugin/makejob.vim b/plugin/makejob.vim
@@ -78,6 +78,8 @@ function! s:JobHandler(channel) abort
endif
silent execute l:qfcmd.' '.l:job['outbufnr']
silent execute l:job['outbufnr'].'bwipe!'
+ unlet b:makejob
+ nunmap <buffer> <C-c>
wincmd p
let l:initqf = l:job['lmake'] ? getloclist(bufwinnr(
@@ -105,6 +107,7 @@ function! s:CreateMakeJobBuffer(prog)
silent execute 'belowright 10split '.a:prog
setlocal bufhidden=hide buftype=nofile buflisted nolist
setlocal noswapfile nowrap nomodifiable
+ nmap <buffer> <C-c> :MakeJobStop<CR>
let l:bufnum = winbufnr(0)
if g:makejob_hide_preview_window
hide
@@ -198,6 +201,7 @@ function! s:MakeJob(grep, lmake, grepadd, bang, ...) abort
execute bufwinnr(l:outbufnr).'wincmd w'
let b:makejob = l:makejob
wincmd p
+ nmap <buffer> <C-c> :MakeJobStop<CR>
end
endfunction