sponsor Vim development Vim logo Vim Book Ad

XQuery indent/omnicomplete/ftplugin : XQuery indent/omnicomplete/ftplugin

 script karma  Rating 18/6, Downloaded by 1551  Comments, bugs, improvements  Vim wiki

created by
David Lam
 
script type
ftplugin
 
description
This plugin configures Vim to be a little more efficient at editing XQuery...!

It also sets up Exuberant Ctags for XQuery, since it's not one of the supported languages.

ftplugin/xquery.vim:
    -Makes keys like gd and<C-]> and i_CTRL-p work better when editing XQuery files by temporarily adding the hyphen - to the 'iskeyword' option
    -Sets options useful when editing XQuery (like 'set comments')
    -Sets a few variables to make matchit.vim and taglist.vim work better with XQuery
    -Comment regions out via surround.vim by visually selecting an area, then pressing Sc


xquerycomplete.vim:
    -Completes W3C XQuery 'fn' functions, types and keywords.
    -Also completes any MarkLogic functions I could find at...  http://developer.marklogic.com/pubs/4.1/apidocs/All.html

        Examples:

            fn<CTRL-x><CTRL-o>
               ->  list of functions in the 'fn' namespace

            fn:doc<CTRL-x><CTRL-o>
               ->  fn:doc(
                   fn:doc-available(
                   fn:document-uri(

            xs<CTRL-x><CTRL-o>
               ->  list of all xquery types

            decl<CTRL-x><CTRL-o>
               ->  declare
                   declare function
                   declare namespace
                   declare option
                   declare default


indent/xquery.vim:
    - It can recognize complex FLOWR expressions. For example in the example below,
      if in insert mode, hitting enter after the first line will immediately align the cursor with the 'for'.

      Also,  typing out the 'let' in the fourth line will immediately re-indent the line to align with the 'let' on the first line.


             let $foo := for $editor in $editors
                              where not(contains($editor, "emacs"))
                              return $editor
             let $bar := "bar"
             return
                   $bar

        
 
install details
  1.  Copy ftplugin/xquery.vim to $HOME/.vim/ftplugin or $HOME/vimfiles/ftplugin or $VIM/vimfiles/ftplugin (and set 'filetype plugin on')
  2.  Copy autoload/xquerycomplete.vim to $HOME/.vim/autoload or $HOME/vimfiles/autoload or $VIM/vimfiles/autoload
  3.  Copy indent/xquery.vim to $HOME/.vim/indent/ or $HOME/vimfiles/indent or $VIM/vimfiles/indent   (and set 'filetype indent on').  
  4.  Copy _ctags to $HOME/.ctags (or one of the alternatives at http://ctags.sourceforge.net/ctags.html#FILES)
  5.  Download Exuberant Ctags and put it on your path.  Use 'ctags -R' to build a tags file for your XQuery source folder  

The steps are mostly optional, so if you don't want automatic indentation for instance, you can just skip step #3.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
xqueryvim.zip 1.2.1 2020-03-18 8.0 David Lam fix compatibility with Vim 8.0
xqueryvim.zip 1.2 2012-07-05 7.0 David Lam updated with functx and new marklogic 5 functions

patch from Steve Spigarelli
xqueryvim.zip 1.1.1 2011-11-03 7.2 David Lam Same as 1.1, but with a extra /indent/test/xquery.vim that has 'echomsg' debug prints in it.  (Use :mesg to view the log after indenting stuff)
xqueryvim.zip 1.1 2011-06-06 7.2 David Lam Cleaned up some debugging prints... and wrote some documentation
xqueryvim.zip 1.0 2011-05-31 7.0 David Lam Initial upload
ip used for rating: 18.191.186.72

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github