mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-12 17:55:41 +08:00
Fix pmd plugin
This commit is contained in:
parent
8d7a581847
commit
a344f57c0d
@ -32,13 +32,17 @@ if !exists('Pmd_Cmd')
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if !exists('Pmd_Cache_Dir')
|
if !exists('Pmd_Cache_Dir')
|
||||||
let g:Pmd_Cache_Dir = '~/.cache/pmd/'
|
let g:Pmd_Cache_Dir = expand('~/.cache/pmd/')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !exists('Pmd_Rulesets')
|
if !exists('Pmd_Rulesets')
|
||||||
let g:Pmd_Rulesets = ["-R", "java-basic,java-design", "-property", "xsltFilename=my-own.xs"]
|
let g:Pmd_Rulesets = ["-R", "java-basic,java-design", "-property", "xsltFilename=my-own.xs"]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !exists('Pmd_silent_stderr')
|
||||||
|
let g:Pmd_silent_stderr = 1
|
||||||
|
endif
|
||||||
|
|
||||||
" load SpaceVim APIs
|
" load SpaceVim APIs
|
||||||
|
|
||||||
let s:JOB = SpaceVim#api#import('job')
|
let s:JOB = SpaceVim#api#import('job')
|
||||||
@ -48,22 +52,39 @@ let s:CMD = SpaceVim#api#import('vim#command')
|
|||||||
|
|
||||||
let s:CMD.options = s:options
|
let s:CMD.options = s:options
|
||||||
|
|
||||||
|
let s:rst = []
|
||||||
|
|
||||||
function! s:on_pmd_stdout(id, data, event) abort
|
function! s:on_pmd_stdout(id, data, event) abort
|
||||||
echom string(a:data)
|
for data in a:data
|
||||||
|
let info = split(data, '\:\d\+\:')
|
||||||
|
if len(info) == 2
|
||||||
|
let [fname, text] = info
|
||||||
|
let lnum = matchstr(data, '\:\d\+\:')[1:-2]
|
||||||
|
call add(s:rst, {
|
||||||
|
\ 'filename' : fnamemodify(fname, ':p'),
|
||||||
|
\ 'lnum' : lnum,
|
||||||
|
\ 'text' : text,
|
||||||
|
\ })
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:on_pmd_stderr(id, data, event) abort
|
function! s:on_pmd_stderr(id, data, event) abort
|
||||||
|
if g:Pmd_silent_stderr == 0
|
||||||
echom string(a:data)
|
echom string(a:data)
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:on_pmd_exit(id, data, event) abort
|
function! s:on_pmd_exit(id, data, event) abort
|
||||||
echom string(a:data)
|
call setqflist(s:rst)
|
||||||
|
let s:rst = []
|
||||||
|
copen
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SpaceVim#plugins#pmd#run(...)
|
function! SpaceVim#plugins#pmd#run(...)
|
||||||
let argv = []
|
let argv = g:Pmd_Cmd
|
||||||
if isdirectory(g:Pmd_Cache_Dir) && index(a:000, '-cache') == -1
|
if isdirectory(g:Pmd_Cache_Dir) && index(a:000, '-cache') == -1
|
||||||
let argv = g:Pmd_Cmd + ['-cache', g:Pmd_Cache_Dir]
|
let argv += ['-cache', g:Pmd_Cache_Dir]
|
||||||
endif
|
endif
|
||||||
let argv += a:000
|
let argv += a:000
|
||||||
if index(a:000, '-R') == -1
|
if index(a:000, '-R') == -1
|
||||||
@ -73,7 +94,7 @@ function! SpaceVim#plugins#pmd#run(...)
|
|||||||
echohl ErrorMsg | echo 'you need to run PMD with -d option!'
|
echohl ErrorMsg | echo 'you need to run PMD with -d option!'
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
echom s:JOB.start(argv,
|
call s:JOB.start(argv,
|
||||||
\ {
|
\ {
|
||||||
\ 'on_stdout' : function('s:on_pmd_stdout'),
|
\ 'on_stdout' : function('s:on_pmd_stdout'),
|
||||||
\ 'on_stderr' : function('s:on_pmd_stderr'),
|
\ 'on_stderr' : function('s:on_pmd_stderr'),
|
||||||
@ -90,3 +111,4 @@ endfunction
|
|||||||
function! SpaceVim#plugins#pmd#complete(ArgLead, CmdLine, CursorPos)
|
function! SpaceVim#plugins#pmd#complete(ArgLead, CmdLine, CursorPos)
|
||||||
return s:CMD.complete(a:ArgLead, a:CmdLine, a:CursorPos)
|
return s:CMD.complete(a:ArgLead, a:CmdLine, a:CursorPos)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user