Merge branch 'master' into gcc_refactor

This commit is contained in:
LCD 47 2013-07-29 18:51:51 +03:00
commit f66613e04e
6 changed files with 122 additions and 64 deletions

View File

@ -24,6 +24,11 @@ let s:defaultCheckers = {
\ 'tex': ['lacheck']
\ }
let s:defaultFiletypeMap = {
\ 'gentoo-metadata': 'xml',
\ 'lhaskell': 'haskell'
\ }
let g:SyntasticRegistry = {}
" TODO: Handling of filetype aliases: all public methods take aliases as
@ -199,7 +204,8 @@ endfunction
"resolve filetype aliases, and replace - with _ otherwise we cant name
"syntax checker functions legally for filetypes like "gentoo-metadata"
function! s:SyntasticRegistryNormaliseFiletype(ftalias)
let ft = get(g:syntastic_filetype_map, a:ftalias, a:ftalias)
let ft = get(s:defaultFiletypeMap, a:ftalias, a:ftalias)
let ft = get(g:syntastic_filetype_map, ft, ft)
let ft = substitute(ft, '-', '_', 'g')
return ft
endfunction

View File

@ -1,5 +1,5 @@
"============================================================================
"File: eruby.vim
"File: ruby.vim
"Description: Syntax checking plugin for syntastic.vim
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
"License: This program is free software. It comes without any warranty,
@ -31,15 +31,20 @@ function! SyntaxCheckers_eruby_ruby_GetLocList()
let fname = "'" . escape(expand('%'), "\\'") . "'"
" TODO: encodings became useful in ruby 1.9 :)
if syntastic#util#versionIsAtLeast(syntastic#util#parseVersion('ruby --version'), [1, 9])
let enc = &fileencoding != '' ? &fileencoding : &encoding
let encoding_string = enc ==? 'utf-8' ? 'UTF-8' : 'BINARY'
let encoding_spec = ', :encoding => "' . (enc ==? 'utf-8' ? 'UTF-8' : 'BINARY') . '"'
else
let encoding_spec = ''
endif
"gsub fixes issue #7, rails has it's own eruby syntax
let makeprg =
\ exe . ' -rerb -e ' .
\ syntastic#util#shescape('puts ERB.new(File.read(' . fname .
\ ', :encoding => "' . encoding_string .
\ '").gsub(''<\%='',''<\%''), nil, ''-'').src') .
\ syntastic#util#shescape('puts ERB.new(File.read(' .
\ fname . encoding_spec .
\ ').gsub(''<\%='',''<\%''), nil, ''-'').src') .
\ ' \| ' . exe . ' -c'
let errorformat =

View File

@ -1,40 +0,0 @@
"============================================================================
"File: gentoo-metadata.vim
"Description: Syntax checking plugin for Gentoo's metadata.xml files
"Maintainer: James Rowe <jnrowe 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.
"
"============================================================================
" The DTDs required to validate metadata.xml files are available in
" $PORTDIR/metadata/dtd, and these local files can be used to significantly
" speed up validation. You can create a catalog file with:
"
" xmlcatalog --create --add rewriteURI http://www.gentoo.org/dtd/ \
" ${PORTDIR:-/usr/portage}/metadata/dtd/ /etc/xml/gentoo
"
" See xmlcatalog(1) and http://www.xmlsoft.org/catalog.html for more
" information.
if exists("g:loaded_syntastic_gentoo_metadata_xmllint_checker")
finish
endif
let g:loaded_syntastic_gentoo_metadata_xmllint_checker=1
function! SyntaxCheckers_gentoo_metadata_xmllint_IsAvailable()
return SyntaxCheckers_xml_xmllint_IsAvailable()
endfunction
function! SyntaxCheckers_gentoo_metadata_xmllint_GetLocList()
return SyntaxCheckers_xml_xmllint_GetLocList()
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'gentoo_metadata',
\ 'name': 'xmllint'})
runtime! syntax_checkers/xml/*.vim

View File

@ -32,23 +32,14 @@ function! SyntaxCheckers_haskell_ghc_mod_GetLocList()
let makeprg = syntastic#makeprg#build({
\ 'exe': 'ghc-mod check',
\ 'args': '--hlintOpt="--language=XmlSyntax"',
\ 'filetype': 'haskell',
\ 'subchecker': 'ghc_mod' })
let loclist1 = SyntasticMake({
let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat })
let makeprg = syntastic#makeprg#build({
\ 'exe': 'ghc-mod lint',
\ 'args': '--hlintOpt="--language=XmlSyntax"',
\ 'filetype': 'haskell',
\ 'subchecker': 'ghc_mod' })
let loclist2 = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat })
return loclist1 + loclist2
return loclist
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({

View File

@ -0,0 +1,38 @@
"============================================================================
"File: hlint.vim
"Description: Syntax checking plugin for syntastic.vim
"Maintainer: Nicolas Wu <nicolas.wu at gmail dot com>
"License: BSD
"============================================================================
if exists("g:loaded_syntastic_haskell_hlint_checker")
finish
endif
let g:loaded_syntastic_haskell_hlint_checker=1
function! SyntaxCheckers_haskell_hlint_IsAvailable()
return executable('hlint')
endfunction
function! SyntaxCheckers_haskell_hlint_GetLocList()
let errorformat =
\ '%E%f:%l:%c: Error: %m,' .
\ '%W%f:%l:%c: Warning: %m,' .
\ '%C%m'
let makeprg = syntastic#makeprg#build({
\ 'exe': 'hlint',
\ 'filetype': 'haskell',
\ 'subchecker': 'hlint' })
let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'postprocess': ['compressWhitespace'] })
return loclist
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'haskell',
\ 'name': 'hlint'})

View File

@ -14,6 +14,12 @@
"
" - g:syntastic_html_tidy_ignore_errors (list; default: [])
" list of errors to ignore
" - g:syntastic_html_tidy_blocklevel_tags (list; default: [])
" list of additional blocklevel tags, to be added to "--new-blocklevel-tags"
" - g:syntastic_html_tidy_inline_tags (list; default: [])
" list of additional inline tags, to be added to "--new-inline-tags"
" - g:syntastic_html_tidy_empty_tags (list; default: [])
" list of additional empty tags, to be added to "--new-empty-tags"
if exists("g:loaded_syntastic_html_tidy_checker")
finish
@ -24,6 +30,18 @@ if !exists('g:syntastic_html_tidy_ignore_errors')
let g:syntastic_html_tidy_ignore_errors = []
endif
if !exists('g:syntastic_html_tidy_blocklevel_tags')
let g:syntastic_html_tidy_blocklevel_tags = []
endif
if !exists('g:syntastic_html_tidy_inline_tags')
let g:syntastic_html_tidy_inline_tags = []
endif
if !exists('g:syntastic_html_tidy_empty_tags')
let g:syntastic_html_tidy_empty_tags = []
endif
function! SyntaxCheckers_html_tidy_IsAvailable()
return executable('tidy')
endfunction
@ -47,7 +65,7 @@ function! s:TidyEncOptByFenc()
return get(tidy_opts, &fileencoding, '-utf8')
endfunction
let s:ignore_html_errors = [
let s:ignore_errors = [
\ "<table> lacks \"summary\" attribute",
\ "not approved by W3C",
\ "attribute \"placeholder\"",
@ -63,8 +81,44 @@ let s:ignore_html_errors = [
\ "<input> attribute \"type\" has invalid value \"search\""
\ ]
let s:blocklevel_tags = [
\ "main",
\ "section",
\ "article",
\ "aside",
\ "hgroup",
\ "header",
\ "footer",
\ "nav",
\ "figure",
\ "figcaption"
\ ]
let s:inline_tags = [
\ "video",
\ "audio",
\ "source",
\ "embed",
\ "mark",
\ "progress",
\ "meter",
\ "time",
\ "ruby",
\ "rt",
\ "rp",
\ "canvas",
\ "command",
\ "details",
\ "datalist"
\ ]
let s:empty_tags = [
\ "wbr",
\ "keygen"
\ ]
function! s:IgnoreError(text)
for i in s:ignore_html_errors + g:syntastic_html_tidy_ignore_errors
for i in s:ignore_errors + g:syntastic_html_tidy_ignore_errors
if stridx(a:text, i) != -1
return 1
endif
@ -72,11 +126,15 @@ function! s:IgnoreError(text)
return 0
endfunction
function! s:NewTags(name)
return syntastic#util#shescape(join( s:{a:name} + g:syntastic_html_tidy_{a:name}, ',' ))
endfunction
function s:Args()
let args = s:TidyEncOptByFenc() .
\ ' --new-blocklevel-tags ' . syntastic#util#shescape('main, section, article, aside, hgroup, header, footer, nav, figure, figcaption') .
\ ' --new-inline-tags ' . syntastic#util#shescape('video, audio, source, embed, mark, progress, meter, time, ruby, rt, rp, canvas, command, details, datalist') .
\ ' --new-empty-tags ' . syntastic#util#shescape('wbr, keygen') .
\ ' --new-blocklevel-tags ' . s:NewTags('blocklevel_tags') .
\ ' --new-inline-tags ' . s:NewTags('inline_tags') .
\ ' --new-empty-tags ' . s:NewTags('empty_tags') .
\ ' -e'
return args
endfunction