Skip to content

Commit b32d598

Browse files
author
skywind3000
committed
improve <nomodeline> compatibility
1 parent 2766279 commit b32d598

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

plugin/asyncrun.vim

Lines changed: 16 additions & 17 deletions
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:53
6+
" Last Modified: 2022/11/02 18:41
77
"
88
" Run shell command in background and output to quickfix:
99
" :AsyncRun[!] [options] {cmd} ...
@@ -230,14 +230,21 @@ function! s:NotSupport()
230230
call s:ErrorMsg(msg)
231231
endfunc
232232

233+
" doautocmd
234+
function! s:DoAutoCmd(text)
235+
let cmd = (g:asyncrun_silent)? 'silent doautocmd' : 'doautocmd'
236+
if v:version >= 704
237+
let cmd = cmd . ' <nomodeline>'
238+
endif
239+
if has('autocmd')
240+
exec cmd . ' ' . a:text
241+
endif
242+
endfunc
243+
233244
" run autocmd
234245
function! s:AutoCmd(name)
235246
if has('autocmd') && ((g:asyncrun_skip / 2) % 2) == 0
236-
if g:asyncrun_silent
237-
exec 'silent doautocmd <nomodeline> User AsyncRun'.a:name
238-
else
239-
exec 'doautocmd <nomodeline> User AsyncRun'.a:name
240-
endif
247+
call s:DoAutoCmd('User AsyncRun' . a:name)
241248
endif
242249
endfunc
243250

@@ -528,17 +535,9 @@ function! s:AsyncRun_Job_AutoCmd(mode, auto)
528535
return 0
529536
endif
530537
if a:mode == 0
531-
if g:asyncrun_silent
532-
silent exec 'doautocmd <nomodeline> QuickFixCmdPre '. name
533-
else
534-
exec 'doautocmd <nomodeline> QuickFixCmdPre '. name
535-
endif
538+
call s:DoAutoCmd('QuickFixCmdPre ' . name)
536539
else
537-
if g:asyncrun_silent
538-
silent exec 'doautocmd <nomodeline> QuickFixCmdPost '. name
539-
else
540-
exec 'doautocmd <nomodeline> QuickFixCmdPost '. name
541-
endif
540+
call s:DoAutoCmd('QuickFixCmdPost ' . name)
542541
endif
543542
endfunc
544543

@@ -2108,7 +2107,7 @@ endfunc
21082107
" asyncrun - version
21092108
"----------------------------------------------------------------------
21102109
function! asyncrun#version()
2111-
return '2.10.7'
2110+
return '2.10.8'
21122111
endfunc
21132112

21142113

0 commit comments

Comments
 (0)