mirror of
https://github.com/amix/vimrc
synced 2025-07-21 11:54:59 +08:00
merge
This commit is contained in:
@ -10,7 +10,7 @@
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
if exists("g:loaded_syntastic_vim_vimlint_checker")
|
||||
if exists('g:loaded_syntastic_vim_vimlint_checker')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_vim_vimlint_checker = 1
|
||||
@ -18,9 +18,9 @@ let g:loaded_syntastic_vim_vimlint_checker = 1
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_vim_vimlint_GetHighlightRegex(item)
|
||||
function! SyntaxCheckers_vim_vimlint_GetHighlightRegex(item) " {{{1
|
||||
let term = matchstr(a:item['text'], '\m `\zs[^`]\+\ze`')
|
||||
if term != ''
|
||||
if term !=# ''
|
||||
let col = get(a:item, 'col', 0)
|
||||
|
||||
if col && term[0:1] ==# 'l:'
|
||||
@ -33,17 +33,19 @@ function! SyntaxCheckers_vim_vimlint_GetHighlightRegex(item)
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
endfunction " }}}1
|
||||
|
||||
function! SyntaxCheckers_vim_vimlint_IsAvailable() dict
|
||||
let vimlparser = globpath(&runtimepath, 'autoload/vimlparser.vim')
|
||||
let vimlint = globpath(&runtimepath, 'autoload/vimlint.vim')
|
||||
call self.log("globpath(&runtimepath, 'autoload/vimlparser.vim') = " . string(vimlparser) . ', ' .
|
||||
\ "globpath(&runtimepath, 'autoload/vimlint.vim') = " . string(vimlint))
|
||||
return vimlparser != '' && vimlint != ''
|
||||
endfunction
|
||||
function! SyntaxCheckers_vim_vimlint_IsAvailable() dict " {{{1
|
||||
let vimlparser = globpath(&runtimepath, 'autoload/vimlparser.vim', 1)
|
||||
let vimlint = globpath(&runtimepath, 'autoload/vimlint.vim', 1)
|
||||
call self.log("globpath(&runtimepath, 'autoload/vimlparser.vim', 1) = " . string(vimlparser) . ', ' .
|
||||
\ "globpath(&runtimepath, 'autoload/vimlint.vim', 1) = " . string(vimlint))
|
||||
return vimlparser !=# '' && vimlint !=# ''
|
||||
endfunction " }}}1
|
||||
|
||||
function! SyntaxCheckers_vim_vimlint_GetLocList() dict " {{{1
|
||||
let buf = bufnr('')
|
||||
|
||||
function! SyntaxCheckers_vim_vimlint_GetLocList() dict
|
||||
" EVL102: unused variable v
|
||||
" EVL103: unused argument v
|
||||
" EVL104: variable may not be initialized on some execution path: v
|
||||
@ -67,18 +69,21 @@ function! SyntaxCheckers_vim_vimlint_GetLocList() dict
|
||||
\ 'EVL204': 3,
|
||||
\ 'EVL205': 3 }
|
||||
|
||||
if exists('g:syntastic_vimlint_options')
|
||||
if type(g:syntastic_vimlint_options) == type({})
|
||||
let options = filter(copy(g:syntastic_vimlint_options), 'v:key =~# "\\m^EVL"')
|
||||
call extend(param, options, 'force')
|
||||
endif
|
||||
let opts = syntastic#util#bufVar(buf, 'vimlint_options')
|
||||
if type(opts) == type({})
|
||||
let options = filter(copy(opts), 'v:key =~# "\\m^EVL"')
|
||||
call extend(param, options, 'force')
|
||||
endif
|
||||
|
||||
return vimlint#vimlint(expand('%'), param)
|
||||
endfunction
|
||||
call self.log('options =', param)
|
||||
|
||||
return vimlint#vimlint(bufname(buf), param)
|
||||
endfunction " }}}1
|
||||
|
||||
" Utilities {{{1
|
||||
|
||||
" @vimlint(EVL103, 1, a:filename)
|
||||
function! s:vimlintOutput(filename, pos, ev, eid, mes, obj)
|
||||
function! s:vimlintOutput(filename, pos, ev, eid, mes, obj) " {{{2
|
||||
call add(a:obj.error, {
|
||||
\ 'bufnr': bufnr(''),
|
||||
\ 'lnum': a:pos.lnum,
|
||||
@ -87,15 +92,16 @@ function! s:vimlintOutput(filename, pos, ev, eid, mes, obj)
|
||||
\ 'type': a:ev[0],
|
||||
\ 'text': '[' . a:eid . '] ' . a:mes,
|
||||
\ 'valid': a:pos.lnum > 0 })
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
" @vimlint(EVL103, 0, a:filename)
|
||||
|
||||
" }}}1
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'vim',
|
||||
\ 'name': 'vimlint',
|
||||
\ 'exec': 'vim' })
|
||||
\ 'name': 'vimlint' })
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
55
sources_non_forked/syntastic/syntax_checkers/vim/vint.vim
Normal file
55
sources_non_forked/syntastic/syntax_checkers/vim/vint.vim
Normal file
@ -0,0 +1,55 @@
|
||||
"============================================================================
|
||||
"File: vint.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: LCD 47 <lcd047 at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
if exists('g:loaded_syntastic_vim_vint_checker')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_vim_vint_checker = 1
|
||||
|
||||
if !exists('g:syntastic_vim_vint_sort')
|
||||
let g:syntastic_vim_vint_sort = 1
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_vim_vint_GetLocList() dict
|
||||
let makeprg = self.makeprgBuild({ 'post_args': '--json' })
|
||||
|
||||
let errorformat = '%f:%l:%c:%t: %m'
|
||||
|
||||
let loclist = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'preprocess': 'vint',
|
||||
\ 'returns': [0, 1] })
|
||||
|
||||
for e in loclist
|
||||
if e['type'] ==? 's'
|
||||
let e['type'] = 'w'
|
||||
let e['subtype'] = 'Style'
|
||||
elseif e['type'] !=? 'e' && e['type'] !=? 'w'
|
||||
let e['type'] = 'e'
|
||||
endif
|
||||
endfor
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'vim',
|
||||
\ 'name': 'vint'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
Reference in New Issue
Block a user