spacevim/autoload/SpaceVim/plugins/pmd.vim
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

131 lines
3.3 KiB
VimL

"=============================================================================
" pmd.vim --- Integrates PMD using Vim quickfix mode
" Copyright (c) 2016-2023 Wang Shidong & Contributors
" Author: Shidong Wang < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
" init plugin values
let s:options = {
\ '-R' : {
\ 'description' : 'Comma separated list of ruleset names to use',
\ 'complete' : [],
\ },
\ '-f' : {
\ 'description' : '',
\ 'complete' : ['text'],
\ },
\ '-d' : {
\ 'description' : 'Root directory for sources',
\ 'complete' : 'file',
\ },
\ '-cache' : {
\ 'description' : 'Set cache file',
\ 'complete' : 'file',
\ },
\ }
if !exists('Pmd_Cmd')
let g:Pmd_Cmd = ['pmd']
endif
if !exists('Pmd_Rulesets')
let g:Pmd_Rulesets = ['-R', 'java-basic,java-design', '-property', 'xsltFilename=my-own.xs']
endif
if !exists('Pmd_silent_stderr')
let g:Pmd_silent_stderr = 1
endif
" load SpaceVim APIs
let s:JOB = SpaceVim#api#import('job')
let s:CMD = SpaceVim#api#import('vim#command')
let s:STRING = SpaceVim#api#import('data#string')
" set APIs
let s:CMD.options = s:options
let s:rst = []
let s:parserdir = ''
" /home/wsdjeg/sources/Mysql.vim/libs/mysqlvim/src/main/java/com/wsdjeg/mysqlvim/MysqlVi.java:18:^IDocument empty method body
" @vimlint(EVL103, 1, a:id)
" @vimlint(EVL103, 1, a:data)
" @vimlint(EVL103, 1, a:event)
function! s:on_pmd_stdout(id, data, event) abort
for data in a:data
let info = split(data, '\:\d\+\:')
if len(info) == 2
let [fname, text] = info
let text = s:STRING.trim(text)
let lnum = matchstr(data, '\:\d\+\:')[1:-2]
call add(s:rst, {
\ 'filename' : fnamemodify(fname, ':p'),
\ 'abbr' : substitute(fname, s:parserdir, '', 'g'),
\ 'lnum' : lnum,
\ 'col' : 0,
\ 'text' : text,
\ })
endif
endfor
endfunction
function! s:on_pmd_stderr(id, data, event) abort
let s:JOB._message += a:data
if g:Pmd_silent_stderr == 0
echom string(a:data)
endif
endfunction
function! s:on_pmd_exit(id, data, event) abort
call SpaceVim#plugins#quickfix#setqflist(s:rst)
call SpaceVim#plugins#quickfix#openwin()
endfunction
" @vimlint(EVL103, 0, a:id)
" @vimlint(EVL103, 0, a:data)
" @vimlint(EVL103, 0, a:event)
function! SpaceVim#plugins#pmd#run(...) abort
if !executable(g:Pmd_Cmd[0])
echohl WarningMsg
echo g:Pmd_Cmd[0] .. ' is not executable'
echohl None
return
endif
let argv = g:Pmd_Cmd + a:000
if index(a:000, '-R') == -1
let argv += g:Pmd_Rulesets
endif
if index(argv, '-d') == -1
echohl ErrorMsg | echo 'you need to run PMD with -d option!'
return
else
let s:parserdir = fnamemodify(argv[index(argv, '-d') + 1], ':p')
endif
call s:JOB.start(argv,
\ {
\ 'on_stdout' : function('s:on_pmd_stdout'),
\ 'on_stderr' : function('s:on_pmd_stderr'),
\ 'on_exit' : function('s:on_pmd_exit'),
\ }
\ )
endfunction
function! SpaceVim#plugins#pmd#debug() abort
call s:CMD.debug()
call s:JOB.debug()
endfunction
function! SpaceVim#plugins#pmd#complete(ArgLead, CmdLine, CursorPos) abort
return s:CMD.complete(a:ArgLead, a:CmdLine, a:CursorPos)
endfunction