Hello developer, I have configured PHP syntax checking in init.vim, but this will cause vimr to crash when command+s is saved. Can this solve the problem?
let g:PHP_SYNTAX_CHECK_BIN = '/usr/local/opt/php@7.4/bin/php'
autocmd BufWritePost *.php call PHPSyntaxCheck()
if !exists('g:PHP_SYNTAX_CHECK_BIN')
let g:PHP_SYNTAX_CHECK_BIN = 'php'
endif
function! PHPSyntaxCheck()
try
let result = system(g:PHP_SYNTAX_CHECK_BIN.' -l -n '.expand('%'))
if (stridx(result, 'No syntax errors detected') == -1)
echohl WarningMsg | echo result | echohl None
endif
catch /E\:\ .*/
echohl ErrorMsg | echo "执行PHP语法检查时出错: " . v:exception | echohl None
endtry
endfunction
Hello developer, I have configured PHP syntax checking in init.vim, but this will cause vimr to crash when command+s is saved. Can this solve the problem?