vim-makejob

Minimal, asynchronous quickfix commands for Vim 8.0
git clone git://git.danielmoch.com/vim-makejob.git
Log | Files | Refs | README | LICENSE

commit 2edc07f22d4020f7df1358668b0153943140d503
parent bef91c6c585240031268e3de8c1b684fce8927df
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Mon,  5 Dec 2016 19:15:34 -0500

Fixes for makeprg expansion

1. Error when empty string passed into GrepJob
2. Use token when expand(token) results in an empty string
3. Refactor to use cgetbuffer and friends

Diffstat:
Mplugin/makejob.vim | 40++++++++++++++++++++++++----------------
1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/plugin/makejob.vim b/plugin/makejob.vim @@ -14,8 +14,6 @@ let s:jobinfo = {} function! s:JobHandler(channel) abort let job = remove(s:jobinfo, split(a:channel)[1]) let is_lmake = job['lmake'] - let output = getbufline(job['outbufnr'], 1, '$') - silent execute job['outbufnr'].'bwipe!' " For reasons I don't understand, copying and re-writing " errorformat fixes a lot of parsing errors @@ -29,19 +27,16 @@ function! s:JobHandler(channel) abort execute bufwinnr(job['srcbufnr']).'wincmd w' if is_lmake - if job['grepadd'] - laddexpr output - else - lgetexpr output - endif + let qfcmd = job['grepadd'] ? 'laddbuffer' : 'lgetbuffer' else - if job['grepadd'] - caddexpr output - else - cgetexpr output - end + let qfcmd = job['grepadd'] ? 'caddbuffer' : 'cgetbuffer' endif + if bufwinnr(job['outbufnr']) + silent execute bufwinnr(job['outbufnr']).'close' + endif + silent execute qfcmd.' '.job['outbufnr'] + silent execute job['outbufnr'].'bwipe!' wincmd p let initqf = is_lmake ? getloclist(bufwinnr(job['srcbufnr'])) : getqflist() @@ -89,14 +84,17 @@ function! s:Expand(input) let split_input = split(a:input) let expanded_input = [] for token in split_input - let expanded_input += [expand(token)] + if expand(token) != '' + let expanded_input += [expand(token)] + else + let expanded_input += [token] + endif endfor return join(expanded_input) endfunction function! s:MakeJob(grep, lmake, grepadd, bang, ...) - let make = a:grep ? &grepprg : &makeprg - let make = s:Expand(make) + let make = a:grep ? s:Expand(&grepprg) : s:Expand(&makeprg) let prog = split(make)[0] let internal_grep = make ==# 'internal' ? 1 : 0 execute 'let openbufnr = bufnr("^'.prog.'$")' @@ -119,7 +117,17 @@ function! s:MakeJob(grep, lmake, grepadd, bang, ...) else let trimmed_arg = substitute(a:1, '^\s\+\|\s\+$', '', 'g') let make = make.' '.expand(trimmed_arg) - end + endif + else + echohl ErrorMsg + if a:lmake + let grepname = grepadd ? 'LgrepAddJob' : 'LgrepJob' + else + let grepname = grepadd ? 'GrepAddJob' : 'GrepJob' + endif + echomsg 'Passed only whitespace to '.grepname + echohl None + return endif let opts = { 'close_cb' : function('s:JobHandler'),