Skip to content

Commit

Permalink
Add <C-c> buffer local mapping for :MakeJobStop
Browse files Browse the repository at this point in the history
  • Loading branch information
djmoch committed May 5, 2017
1 parent e70bc58 commit b64d207
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions doc/makejob.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions plugin/makejob.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit b64d207

Please sign in to comment.