Language Server and Client for XQuery/eXistdb
A language server and Visual Studio Code extension for developing XQuery code targeted at eXistdb. The language server currently supports the following capabilities for XQuery:
The client extension additionally includes XQuery syntax highlighting based on https://github.com/DotJoshJohnson/vscode-xml.
Important: Most language server features require that the edited file is associated with a workspace folder, which will be used as the context to resolve XQuery import paths etc. (see configuration section below). In Visual Studio Code, use
The language server talks to an eXist instance in order to provide autocompletion, resolve document symbols, definitions etc. There are three places in which those settings can be provided. The language server will check them in this order:
The ~servers~ object maps one or more server ids to the corresponding settings. Right now, the language server supports only one server.
The extension requires a helper package to be installed on the eXist instance. As soon as you open a file which activates the extension, it will automatically check if the helper package is present. If not, a popup should appear, asking if the helper package should be installed.
Syncing Directories to the Server
The extension includes a task provider, which automatically registers a sync task for a workspace if the
To prevent unintentional syncs, the task must be started manually.
Start via status bar icon
If a workspace configuration was found, you should find two statusbar icons to the bottom right of the window:
The first indicates if the database connection is active, the other shows the sync status. It should display 'off' as initial state. Click on the icon to activate sync. This will list all sync tasks available in the current workspace. Select one to start.
|server||the name of the server entry (in the 'servers' section to connect to|
|ignore||an array of file path patterns which should not be synced|
|dir||subdirectory to be watched (default: '.')|
|polling||by default, the watcher uses file system events to detect changes. This may fail in certain environments. If the option is enable, the watcher will instead periodically poll files for changes.|
|interval||interval (in ms) to use when polling|
An open XQuery file can be sent to the server for evaluation, using either
- the command
existdb.executefrom the command palette
- pressing the keyboard shortcut
command-option-enteron a Mac)
- selecting Execute current XQuery on the server from the editor title toolbar
The result returned by eXist is displayed in a new column besides the currently open editor. If the XQuery defines serialization to HTML, the results will be shown in a web view. In all other cases, the source code of the result is displayed.
Building the Extension
- clone the repository and open the directory in Visual Studio Code
- switch to the debug panel in the sidebar and choose Launch Client from the run configurations
vsce once by running
npm install -g vsce
then package the extension into a
.vsix file with