vim-xquery-syntax


Ⅰ. 插件描述

VIM XQuery syntax file

Ⅱ. 基本信息

创建日期:  2010-11-22
使用用户:  5
Github星:  3
插件作者:  Jeroen Pulles

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'jeroenp/vim-xquery-syntax'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'jeroenp/vim-xquery-syntax'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'jeroenp/vim-xquery-syntax'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/jeroenp/vim-xquery-syntax

Ⅳ. 文档说明

XQuery syntax file for VIM

Motivation

This syntax file differs from Jean-Marc Vanel’s syntax file in that it doesn’t
use the XML syntax as a base. I find the XML highlighting distracting when
programming; Since you’re only working with snippets of XML at a time, I don’t
think the XML highlighting helps. Instead, the code structure is highlighted.
It’s easy to spot variable references inside XML literals this way, for
example.

Background

The syntax file has been used while working on a 2000+ lines project with
numerous modules where I found that the xquery syntax that currently comes with
VIM didn’t work. This syntax file is by no means complete, but I think that
it’s good enough to release.

I try to stay close to the way VIM does C syntax highlighting. That makes me
most comfortable with working with large XQuery files. For variable names I use
the \k character class for keywords, which may not correspond to the XQuery
specification but in practice this will be what most people will want to use.
Standard library functions, such as those from XPath, like fn:document-uri,
are not marked as keyword, instead they’re treated as any other function.

-- Jeroen

DETAILS

Reference

See the XQuery grammar specification at Appendix A XQuery Grammar

Words

XQuery uses NCNames for most keywords, and as it happens that sometimes even
includes dots. Which is totally weird for people coming from other programming

  1. This syntax file uses standard \k with minus and dot, -..

Comments

XQuery comments are balanced, so (: (: :) leaves a comment open; At least,
this is how it works in Mark Logic 4. XML Comments are supported like any
other literal piece of XML. So yes, these are part of the output and shouldn’t
be used to document your code.

XML rendering

The start tag is also used for end tags in Processing Instructions and CDATA sections.

TODO

  • Function names should be marked as xqyFunction
  • xs:string is currently marked as a "type", but that needs a more generic
    solution that also works for sequences and matchers like

schema-element(<type>)

  • Operators such as <>+- should be marked as keywords
  • Conditionals such as if/then and typeswitch can benefit from using a
    nextgroup
  • {} could be marked as a fold, but my short experiments with it gave
    problems in balancing the brackets when trying the fold.
  • Specify all declare variations and make sure that these only work in the
    prolog and not in blocks.

添加新评论