-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathphpstan.vim
More file actions
38 lines (28 loc) · 1 KB
/
phpstan.vim
File metadata and controls
38 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function! phpstan#PHPStanAnalyse(...)
let paths = join(a:000, '\ ')
let phpstan_path = phpstan#_resolvePhpstanPath()
let cmd = phpstan_path . ' analyse --errorFormat=raw --no-progress -l' . g:phpstan_analyse_level . ' ' . paths
let output = system(cmd)
let list = []
for line in split(output, "\n")
" Parse the filename and line number
let parts = split(line, ':')
" The reset of the string is the description
let description = join(parts[2:], ':')
" Add to the quickfix List
call add(list, { 'filename': parts[0], 'lnum': parts[1], 'text': description })
endfor
call setqflist(list)
exe 'cwindow'
endfun
function! phpstan#_resolvePhpstanPath()
for phpstan_path in g:phpstan_paths
if filereadable(phpstan_path)
return phpstan_path
endif
endfor
if !executable('phpstan')
throw "PHPStan doesn't seem to be globally installed or detected locally"
endif
return 'phpstan'
endfun