commit bd891d3c3ede61626db4af0110f1ebb0ffd023c0
parent 12a42c478b7e345eb6cedc0086ae087affb159f7
Author: Daniel Moch <daniel@danielmoch.com>
Date: Sun, 2 Apr 2017 17:23:29 -0400
MakeJob v1.2
Add a configuration option, g:makejob_hide_preview_window, to do pretty
much what it says. If set to 1, the preview window is hidden during
execution. This option does not affect configured autocmds, which might
open the quickfix or location windows upon job completion if there are
errors.
Diffstat:
3 files changed, 59 insertions(+), 25 deletions(-)
diff --git a/README.md b/README.md
@@ -98,13 +98,19 @@ mapping to my `.vimrc`:
`nnoremap <Leader>g :GrepJob!<Space>`
+Finally, if you find the preview windows distracting or otherwise
+disruptive to your workflow, you can hide it with the following, global
+setting:
+
+`let g:makejob_hide_preview_window = 1`
+
## Gotchas
1. If `grepprg` is set to `'internal'`, then Vim uses its own builtin grep
command. This still works when you call `:GrepJob`, but not
asynchronously.
2. For simplicity, only one instance of a given executable can run at
once. You can run `make` and `pylint`, but you can't run two
- instances of `make`.
+ instances of `make` simultaneously.
## Vim Documentation
Part of the goal of _MakeJob_ is to minimize the size of the plugin by
diff --git a/doc/makejob.txt b/doc/makejob.txt
@@ -3,57 +3,76 @@
Author: Daniel Moch <daniel@danielmoch.com>
License: MIT (see LICENSE file for details)
-INTRODUCTION *makejob* *vim-makejob*
+ MakeJob *makejob* *vim-makejob*
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.
+1. Commands |makejob-commands|
+2. Configuration |makejob-configuration|
+3. About |makejob-about|
+
{only when compiled with the |channel|, |job|, and |quickfix| features}
+=============================================================================
+1. MakeJob Commands *makejob-commands*
+
Here are your new quickfix commands.
- *makejob-MakeJob*
+ *makejob-MakeJob* *:MakeJob*
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 the
- name of the file to make, and is appended to the
- end of |makeprg|. Ex special characters are
+ MakeJob is called. {filename}, if specified, is
+ the name of the file to make, and is appended to
+ the end of |makeprg|. Ex special characters are
expanded (see |cmdline-special|). |autowrite|,
- |QuickFixCmdPre|, and |QuickFixCmdPost| all
- work as expected. While the job runs, output
- will be directed to a preview buffer below
- the active buffer. If [!] is not given, the
- first error is jumped to.
+ |QuickFixCmdPre|, and |QuickFixCmdPost| all work
+ as expected. While the job runs, output will be
+ directed to a preview buffer below the active
+ buffer. If [!] is not given, the first error is
+ jumped to.
- *makejob-LmakeJob*
+ *makejob-LmakeJob* *:LmakeJob*
LmakeJob[!] [{filename}] Same as ":MakeJob", except the location list for
the current window is used instead of the quickfix
list.
- *makejob-GrepJob*
-GrepJob[!] {filename} Run the grep command specified in |grepprg|
- and read into the quickfix list using
- |grepformat|. {filename} must be specified,
- but can contain wildcards.
+ *makejob-GrepJob* *:GrepJob*
+GrepJob[!] {filename} Run the grep command specified in |grepprg| and
+ read into the quickfix list using |grepformat|.
+ {filename} must be specified, but can contain
+ wildcards.
- *makejob-LgrepJob*
+ *makejob-LgrepJob* *:LgrepJob*
LgrepJob[!] {filename} Same as ":GrepJob", except the location list for
the current window is used instead of the quickfix
list.
- *makejob-GrepaddJob*
+ *makejob-GrepaddJob* *:GrepaddJob*
GrepaddJob[!] {filename} Same as ":GrepJob", but add findings to the
quickfix list without clearing it first.
- *makejob-LgrepaddJob*
+ *makejob-LgrepaddJob* *:LgrepaddJob*
LgrepaddJob[!] {filename} Same as ":GrepaddJob", but add findings to the
location list without clearing it first.
-ABOUT *makejob-about*
+=============================================================================
+2. CONFIGURATION *makejob-configuration*
+
+ *g:makejob_hide_preview_window*
+ number (default 0)
+g:makejob_hide_preview_window Hide the preview window during execution.
+ Default (0) is to show the preview window.
+ Set to 1 to hide it.
+
+=============================================================================
+3. ABOUT *makejob-about*
More details can be found in README.md or by navigating to:
https://github.com/djmoch/vim-makejob
+
+vim:tw=78:ts=8:ft=help:norl:
diff --git a/plugin/makejob.vim b/plugin/makejob.vim
@@ -1,7 +1,7 @@
"
" TITLE: VIM-MAKEJOB
" AUTHOR: Daniel Moch <daniel@danielmoch.com>
-" VERSION: 1.2-dev
+" VERSION: 1.2
"
if exists('g:loaded_makejob') || &cp
finish
@@ -14,6 +14,10 @@ let s:save_cpo = &cpo
set cpo&vim
let s:jobinfo = {}
+if !exists('g:makejob_hide_preview_window')
+ let g:makejob_hide_preview_window = 0
+endif
+
function! s:InitAutocmd(lmake, grep, cmd)
let l:returnval = 'doautocmd QuickFixCmd'.a:cmd.' '
if a:grep
@@ -44,7 +48,7 @@ function! s:JobHandler(channel) abort
let l:qfcmd = l:job['grepadd'] ? 'caddbuffer' : 'cgetbuffer'
endif
- if bufwinnr(l:job['outbufnr'])
+ if bufwinnr(l:job['outbufnr']) && l:job['outbufhidden'] == 0
silent execute bufwinnr(l:job['outbufnr']).'close'
endif
silent execute l:qfcmd.' '.l:job['outbufnr']
@@ -77,7 +81,11 @@ function! s:CreateMakeJobWindow(prog)
setlocal bufhidden=hide buftype=nofile nobuflisted nolist
setlocal noswapfile nowrap nomodifiable
let l:bufnum = winbufnr(0)
- wincmd p
+ if g:makejob_hide_preview_window
+ hide
+ else
+ wincmd p
+ end
return l:bufnum
endfunction
@@ -156,7 +164,8 @@ function! s:MakeJob(grep, lmake, grepadd, bang, ...)
\ 'outbufnr': l:outbufnr,
\ 'srcbufnr': winbufnr(0),
\ 'cfirst': !a:bang, 'grep': a:grep,
- \ 'grepadd': a:grepadd }
+ \ 'grepadd': a:grepadd,
+ \ 'outbufhidden': g:makejob_hide_preview_window }
echomsg s:jobinfo[split(job_getchannel(l:job))[1]]['prog']
\ .' started'
end