Skip to content

Commit e0f500e

Browse files
author
skywind3000
committed
2.4.9: new g:asyncrun_strict
1 parent f88bc7b commit e0f500e

File tree

1 file changed

+55
-72
lines changed

1 file changed

+55
-72
lines changed

plugin/asyncrun.vim

Lines changed: 55 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Maintainer: skywind3000 (at) gmail.com, 2016, 2017, 2018, 2019, 2020
44
" Homepage: http://www.vim.org/scripts/script.php?script_id=5431
55
"
6-
" Last Modified: 2020/02/21 10:54
6+
" Last Modified: 2020/02/21 17:06
77
"
88
" Run shell command in background and output to quickfix:
99
" :AsyncRun[!] [options] {cmd} ...
@@ -117,101 +117,83 @@
117117
"----------------------------------------------------------------------
118118
"- Global Settings & Variables
119119
"----------------------------------------------------------------------
120-
if !exists('g:asyncrun_exit')
121-
let g:asyncrun_exit = ''
122-
endif
123120

124-
if !exists('g:asyncrun_bell')
125-
let g:asyncrun_bell = 0
126-
endif
121+
" script will be executed after finished.
122+
let g:asyncrun_exit = get(g:, 'asyncrun_exit', '')
127123

128-
if !exists('g:asyncrun_stop')
129-
let g:asyncrun_stop = ''
130-
endif
124+
" non-zero to ring a bell after finished.
125+
let g:asyncrun_bell = get(g:, 'asyncrun_bell', 0)
131126

132-
if !exists('g:asyncrun_mode')
133-
let g:asyncrun_mode = 0
134-
endif
127+
" stoponexit option of job_start
128+
let g:asyncrun_stop = get(g:, 'asyncrun_stop', '')
135129

136-
if !exists('g:asyncrun_hook')
137-
let g:asyncrun_hook = ''
138-
endif
130+
" specify how to run your command
131+
let g:asyncrun_mode = get(g:, 'asyncrun_mode', 0)
139132

140-
if !exists('g:asyncrun_last')
141-
let g:asyncrun_last = 0
142-
endif
133+
" command hook
134+
let g:asyncrun_hook = get(g:, 'asyncrun_hook', '')
143135

144-
if !exists('g:asyncrun_timer')
145-
let g:asyncrun_timer = 25
146-
endif
136+
" quickfix scroll mode
137+
let g:asyncrun_last = get(g:, 'asyncrun_last', 0)
147138

148-
if !exists('g:asyncrun_code')
149-
let g:asyncrun_code = ''
150-
endif
139+
" speed for each timer
140+
let g:asyncrun_timer = get(g:, 'asyncrun_timer', 25)
151141

152-
if !exists('g:asyncrun_status')
153-
let g:asyncrun_status = ''
154-
endif
142+
" previous exit code
143+
let g:asyncrun_code = get(g:, 'asyncrun_code', '')
155144

156-
if !exists('g:asyncrun_encs')
157-
let g:asyncrun_encs = ''
158-
endif
145+
" status: 'running', 'success' or 'failure'
146+
let g:asyncrun_status = get(g:, 'asyncrun_status', '')
159147

160-
if !exists('g:asyncrun_trim')
161-
let g:asyncrun_trim = 0
162-
endif
148+
" command encoding
149+
let g:asyncrun_encs = get(g:, 'asyncrun_encs', '')
163150

164-
if !exists('g:asyncrun_text')
165-
let g:asyncrun_text = ''
166-
endif
151+
" trim empty lines ?
152+
let g:asyncrun_trim = get(g:, 'asyncrun_trim', 0)
167153

168-
if !exists('g:asyncrun_local')
169-
let g:asyncrun_local = 1
170-
endif
154+
" user text
155+
let g:asyncrun_text = get(g:, 'asyncrun_text', '')
171156

172-
if !exists('g:asyncrun_auto')
173-
let g:asyncrun_auto = ''
174-
endif
157+
" enable local errorformat ?
158+
let g:asyncrun_local = get(g:, 'asyncrun_local', 1)
175159

176-
if !exists('g:asyncrun_shell')
177-
let g:asyncrun_shell = ''
178-
endif
160+
" name of autocmd in QuickFixCmdPre / QuickFixCmdPost
161+
let g:asyncrun_auto = get(g:, 'asyncrun_auto', '')
179162

180-
if !exists('g:asyncrun_shellflag')
181-
let g:asyncrun_shellflag = ''
182-
endif
163+
" specify shell rather than &shell
164+
let g:asyncrun_shell = get(g:, 'asyncrun_shell', '')
183165

184-
if !exists('g:asyncrun_runner')
185-
let g:asyncrun_runner = {}
186-
endif
166+
" specify shell cmd flag rather than &shellcmdflag
167+
let g:asyncrun_shellflag = get(g:, 'asyncrun_shellflag', '')
187168

188-
if !exists('g:asyncrun_ftrun')
189-
let g:asyncrun_ftrun = {}
190-
endif
169+
" external runners for '-mode=terminal'
170+
let g:asyncrun_runner = get(g:, 'asyncrun_runner', {})
191171

192-
if !exists('g:asyncrun_silent')
193-
let g:asyncrun_silent = 1
194-
endif
172+
" silent the autocmds ?
173+
let g:asyncrun_silent = get(g:, 'asyncrun_silent', 1)
195174

196-
if !exists('g:asyncrun_skip')
197-
let g:asyncrun_skip = 0
198-
endif
175+
" skip autocmds
176+
let g:asyncrun_skip = get(g:, 'asyncrun_skip', 0)
199177

200-
if !exists('g:asyncrun_info')
201-
let g:asyncrun_info = ''
202-
endif
178+
" last args
179+
let g:asyncrun_info = get(g:, 'asyncrun_info', '')
203180

204-
if !exists('g:asyncrun_save')
205-
let g:asyncrun_save = 0
206-
endif
181+
" 0: no save, 1: save current buffer, 2: save all modified buffers.
182+
let g:asyncrun_save = get(g:, 'asyncrun_save', 0)
207183

184+
" enable stdin ?
208185
if !exists('g:asyncrun_stdin')
209186
let g:asyncrun_stdin = has('win32') || has('win64') || has('win95')
210187
endif
211188

212-
if !exists('g:asyncrun_script')
213-
let g:asyncrun_script = ''
214-
endif
189+
" external script for '-mode=4'
190+
let g:asyncrun_script = get(g:, 'asyncrun_script', '')
191+
192+
" strict to execute vim script
193+
let g:asyncrun_strict = get(g:, 'asyncrun_strict', 0)
194+
195+
" file types for asyncrun#execute
196+
let g:asyncrun_ftrun = get(g:, 'asyncrun_ftrun', {})
215197

216198

217199
"----------------------------------------------------------------------
@@ -1375,9 +1357,10 @@ function! s:run(opts)
13751357
endif
13761358
endif
13771359

1360+
let g:asyncrun_cmd = l:command
13781361
let t = s:StringStrip(l:command)
13791362

1380-
if strpart(t, 0, 1) == ':'
1363+
if strpart(t, 0, 1) == ':' && g:asyncrun_strict == 0
13811364
exec strpart(t, 1)
13821365
return ''
13831366
elseif l:runner != ''
@@ -1710,7 +1693,7 @@ endfunc
17101693
" asyncrun - version
17111694
"----------------------------------------------------------------------
17121695
function! asyncrun#version()
1713-
return '2.4.8'
1696+
return '2.4.9'
17141697
endfunc
17151698

17161699

0 commit comments

Comments
 (0)