Skip to content

Commit 2766279

Browse files
author
skywind3000
committed
take care of &makeencoding option;
provide more information for runners/translators fixed minor issues
1 parent 0794a82 commit 2766279

File tree

3 files changed

+89
-3
lines changed

3 files changed

+89
-3
lines changed

autoload/asyncrun/program/capture.vim

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
"======================================================================
2+
"
3+
" capture.vim -
4+
"
5+
" Created by skywind on 2022/11/02
6+
" Last Modified: 2022/11/02 17:21:04
7+
"
8+
"======================================================================
9+
10+
if !exists('g:asyncrun_capture_file')
11+
if isdirectory(expand('~/.vim'))
12+
let g:asyncrun_capture_file = expand('~/.vim/capture.tmp')
13+
else
14+
let base = expand('~/.cache/vim')
15+
if !isdirectory(base)
16+
silent! call mkdir(base, 'p')
17+
endif
18+
let g:asyncrun_capture_file = base . '/capture.tmp'
19+
endif
20+
endif
21+
22+
function! asyncrun#program#capture#translate(opts)
23+
let cmd = asyncrun#utils#strip(a:opts.cmd)
24+
let tmp = g:asyncrun_capture_file
25+
let tee = ''
26+
if a:opts.code != 6
27+
endif
28+
if executable('tee')
29+
let tee = 'tee'
30+
elseif executable('busybox')
31+
let tee = 'busybox tee'
32+
else
33+
call asyncrun#utils#errmsg('not find tee')
34+
return cmd
35+
endif
36+
let s:history_cmd = cmd
37+
let cmd = cmd . ' | ' . shellescape(tee) . ' ' . shellescape(tmp)
38+
let a:opts.post = 'call asyncrun#program#capture#update()'
39+
let a:opts.safe = 1
40+
return cmd
41+
endfunc
42+
43+
44+
function! asyncrun#program#capture#update()
45+
let tmp = g:asyncrun_capture_file
46+
if filereadable(tmp)
47+
let msg = get(s:, 'history_cmd', '')
48+
let msg = '[' . msg . ']'
49+
cexpr msg
50+
let save = &l:makeencoding
51+
if g:asyncrun_encs != ''
52+
let &l:makeencoding = g:asyncrun_encs
53+
endif
54+
exec 'caddf ' . fnameescape(g:asyncrun_capture_file)
55+
let &l:makeencoding = save
56+
cfirst
57+
silent! call delete(tmp)
58+
let s:history_cmd = ''
59+
call asyncrun#utils#quickfix_request()
60+
endif
61+
endfunc
62+
63+

autoload/asyncrun/utils.vim

+12
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,15 @@ function! asyncrun#utils#set_title(title, expanded)
118118
endfunction
119119

120120

121+
"----------------------------------------------------------------------
122+
" try to open quickfix
123+
"----------------------------------------------------------------------
124+
function! asyncrun#utils#quickfix_request()
125+
let height = get(g:, "asyncrun_open", 0)
126+
if height > 0
127+
call asyncrun#quickfix_toggle(height, 1)
128+
endif
129+
endfunc
130+
131+
132+

plugin/asyncrun.vim

+14-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Maintainer: skywind3000 (at) gmail.com, 2016-2022
44
" Homepage: https://github.com/skywind3000/asyncrun.vim
55
"
6-
" Last Modified: 2022/11/02 17:14
6+
" Last Modified: 2022/11/02 17:53
77
"
88
" Run shell command in background and output to quickfix:
99
" :AsyncRun[!] [options] {cmd} ...
@@ -1768,21 +1768,32 @@ function! s:run(opts)
17681768
endif
17691769
let l:efm1 = &g:efm
17701770
let l:efm2 = &l:efm
1771+
if exists('&makeencoding')
1772+
let l:encoding = &l:makeencoding
1773+
if g:asyncrun_encs != ''
1774+
let &l:makeencoding = g:asyncrun_encs
1775+
endif
1776+
endif
17711777
if g:asyncrun_local != 0
17721778
let &g:efm = s:async_efm
17731779
let &l:efm = s:async_efm
17741780
endif
17751781
if has('autocmd')
17761782
call s:AsyncRun_Job_AutoCmd(0, opts.auto)
1777-
exec "noautocmd make!"
1783+
silent exec "noautocmd make!"
17781784
call s:AsyncRun_Job_AutoCmd(1, opts.auto)
17791785
else
1780-
exec "make!"
1786+
silent exec "make!"
17811787
endif
17821788
if g:asyncrun_local != 0
17831789
if l:efm1 != &g:efm | let &g:efm = l:efm1 | endif
17841790
if l:efm2 != &l:efm | let &l:efm = l:efm2 | endif
17851791
endif
1792+
if exists('&makeencoding')
1793+
if g:asyncrun_encs != ''
1794+
let &l:makeencoding = l:encoding
1795+
endif
1796+
endif
17861797
let &l:makeprg = l:makesave
17871798
if s:asyncrun_windows == 0
17881799
try | call delete(l:script) | catch | endtry

0 commit comments

Comments
 (0)