Git Product home page Git Product logo

vim-xquery-syntax's Introduction

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 languages. 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()
  • 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.

vim-xquery-syntax's People

Contributors

james-jw avatar dirkk avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.