|
3 | 3 | " Maintainer: skywind3000 (at) gmail.com, 2016, 2017, 2018, 2019, 2020
|
4 | 4 | " Homepage: http://www.vim.org/scripts/script.php?script_id=5431
|
5 | 5 | "
|
6 |
| -" Last Modified: 2020/02/21 10:54 |
| 6 | +" Last Modified: 2020/02/21 17:06 |
7 | 7 | "
|
8 | 8 | " Run shell command in background and output to quickfix:
|
9 | 9 | " :AsyncRun[!] [options] {cmd} ...
|
|
117 | 117 | "----------------------------------------------------------------------
|
118 | 118 | "- Global Settings & Variables
|
119 | 119 | "----------------------------------------------------------------------
|
120 |
| -if !exists('g:asyncrun_exit') |
121 |
| - let g:asyncrun_exit = '' |
122 |
| -endif |
123 | 120 |
|
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', '') |
127 | 123 |
|
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) |
131 | 126 |
|
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', '') |
135 | 129 |
|
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) |
139 | 132 |
|
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', '') |
143 | 135 |
|
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) |
147 | 138 |
|
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) |
151 | 141 |
|
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', '') |
155 | 144 |
|
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', '') |
159 | 147 |
|
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', '') |
163 | 150 |
|
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) |
167 | 153 |
|
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', '') |
171 | 156 |
|
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) |
175 | 159 |
|
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', '') |
179 | 162 |
|
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', '') |
183 | 165 |
|
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', '') |
187 | 168 |
|
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', {}) |
191 | 171 |
|
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) |
195 | 174 |
|
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) |
199 | 177 |
|
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', '') |
203 | 180 |
|
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) |
207 | 183 |
|
| 184 | +" enable stdin ? |
208 | 185 | if !exists('g:asyncrun_stdin')
|
209 | 186 | let g:asyncrun_stdin = has('win32') || has('win64') || has('win95')
|
210 | 187 | endif
|
211 | 188 |
|
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', {}) |
215 | 197 |
|
216 | 198 |
|
217 | 199 | "----------------------------------------------------------------------
|
@@ -1375,9 +1357,10 @@ function! s:run(opts)
|
1375 | 1357 | endif
|
1376 | 1358 | endif
|
1377 | 1359 |
|
| 1360 | + let g:asyncrun_cmd = l:command |
1378 | 1361 | let t = s:StringStrip(l:command)
|
1379 | 1362 |
|
1380 |
| - if strpart(t, 0, 1) == ':' |
| 1363 | + if strpart(t, 0, 1) == ':' && g:asyncrun_strict == 0 |
1381 | 1364 | exec strpart(t, 1)
|
1382 | 1365 | return ''
|
1383 | 1366 | elseif l:runner != ''
|
@@ -1710,7 +1693,7 @@ endfunc
|
1710 | 1693 | " asyncrun - version
|
1711 | 1694 | "----------------------------------------------------------------------
|
1712 | 1695 | function! asyncrun#version()
|
1713 |
| - return '2.4.8' |
| 1696 | + return '2.4.9' |
1714 | 1697 | endfunc
|
1715 | 1698 |
|
1716 | 1699 |
|
|
0 commit comments