diff --git a/plugin/syntastic/registry.vim b/plugin/syntastic/registry.vim index 1fa5b66d..6f61d65f 100644 --- a/plugin/syntastic/registry.vim +++ b/plugin/syntastic/registry.vim @@ -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 diff --git a/syntax_checkers/eruby/ruby.vim b/syntax_checkers/eruby/ruby.vim index 6032bc22..3a772351 100644 --- a/syntax_checkers/eruby/ruby.vim +++ b/syntax_checkers/eruby/ruby.vim @@ -1,5 +1,5 @@ "============================================================================ -"File: eruby.vim +"File: ruby.vim "Description: Syntax checking plugin for syntastic.vim "Maintainer: Martin Grenfell "License: This program is free software. It comes without any warranty, @@ -31,15 +31,20 @@ function! SyntaxCheckers_eruby_ruby_GetLocList() let fname = "'" . escape(expand('%'), "\\'") . "'" - let enc = &fileencoding != '' ? &fileencoding : &encoding - let encoding_string = enc ==? 'utf-8' ? 'UTF-8' : 'BINARY' + " 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_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 = diff --git a/syntax_checkers/gentoo_metadata/xmllint.vim b/syntax_checkers/gentoo_metadata/xmllint.vim deleted file mode 100644 index 2e92707f..00000000 --- a/syntax_checkers/gentoo_metadata/xmllint.vim +++ /dev/null @@ -1,40 +0,0 @@ -"============================================================================ -"File: gentoo-metadata.vim -"Description: Syntax checking plugin for Gentoo's metadata.xml files -"Maintainer: James Rowe -"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 diff --git a/syntax_checkers/haskell/ghc-mod.vim b/syntax_checkers/haskell/ghc-mod.vim index 9340c381..f3677dc1 100644 --- a/syntax_checkers/haskell/ghc-mod.vim +++ b/syntax_checkers/haskell/ghc-mod.vim @@ -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({ diff --git a/syntax_checkers/haskell/hlint.vim b/syntax_checkers/haskell/hlint.vim new file mode 100644 index 00000000..c748b77c --- /dev/null +++ b/syntax_checkers/haskell/hlint.vim @@ -0,0 +1,38 @@ +"============================================================================ +"File: hlint.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Nicolas Wu +"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'}) diff --git a/syntax_checkers/html/tidy.vim b/syntax_checkers/html/tidy.vim index b7d508f8..27a97613 100644 --- a/syntax_checkers/html/tidy.vim +++ b/syntax_checkers/html/tidy.vim @@ -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 = [ \ " lacks \"summary\" attribute", \ "not approved by W3C", \ "attribute \"placeholder\"", @@ -63,8 +81,44 @@ let s:ignore_html_errors = [ \ " 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