From 3c524a661c55d7aad2412892ee455eb56a2d7fd5 Mon Sep 17 00:00:00 2001 From: James Wright Date: Wed, 21 Oct 2015 18:00:29 -0400 Subject: [PATCH] Added support for XQuery using BaseX.exe --- plugin/syntastic/registry.vim | 1 + syntax_checkers/xquery/basex.vim | 50 ++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 syntax_checkers/xquery/basex.vim diff --git a/plugin/syntastic/registry.vim b/plugin/syntastic/registry.vim index 016d7621..1ec2f889 100644 --- a/plugin/syntastic/registry.vim +++ b/plugin/syntastic/registry.vim @@ -95,6 +95,7 @@ let s:_DEFAULT_CHECKERS = { \ 'xhtml': ['tidy'], \ 'xml': ['xmllint'], \ 'xslt': ['xmllint'], + \ 'xquery': ['basex'], \ 'yacc': ['bison'], \ 'yaml': ['jsyaml'], \ 'z80': ['z80syntaxchecker'], diff --git a/syntax_checkers/xquery/basex.vim b/syntax_checkers/xquery/basex.vim new file mode 100644 index 00000000..6911baf3 --- /dev/null +++ b/syntax_checkers/xquery/basex.vim @@ -0,0 +1,50 @@ +"============================================================================ +"File: basex.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: James Wright +"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. +" +"============================================================================ + +if exists('g:loaded_syntastic_xquery_basex_checker') + finish +endif +let g:loaded_syntastic_xquery_basex_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +if exists('g:syntastic_extra_filetypes') + call add(g:syntastic_extra_filetypes, 'xquery') +else + let g:syntastic_extra_filetypes = ['xquery'] +endif + +function SyntaxCheckers_xquery_basex_IsAvailable() dict + return executable(expand(self.getExec(), 1)) +endfunction + +function SyntaxCheckers_xquery_basex_GetLocList() dict + let makeprg = 'basex -z -q "inspect:module(' . "'" . expand("%:p") . "')" . '"' + let errorformat = + \ '%-GStopped at .\, %l/%c:,'. + \ '%E[%.%#] Stopped at %f\, %l/%c:,'. + \ '%Z[%t%#%n] %m' + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat + \ }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'xquery', + \ 'name': 'basex'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: