quintanar401 / autocomplete-kdb-q

Autocomplete/linter for KDB-Q
MIT License
13 stars 6 forks source link

autocomplete-kdb-q package

Autocomplete, QDoc and linter (error checking) provider for KDB+ Q

Installation

autocomplete-kdb-q requires:

Install them as usual via apm or install page in the settings view.

The last two packages are tremendously useful themselves and can be used with many other languages.

Status

Available features:

Autocomplete

Example below shows what info is saved by autocomplete and how it is used.

/ This comment will be shown for .im.global
.im.global:100h / globals are names that start with .
if[1b; global: 100] / or names defined outside any function.
`imglobaltoo set 100 / or symbols with set
fn:{[a]  / a is local
  b: 100; / local too
  c:: 100; / global
  d[10]:: 100 / parser is clever enough to understand that d is a global
  : `end / `end is remembered too
 }
\d .my
var: 100 / autocomplete understands this and remembers var as file local and .my.var as global
\d .

Autocomplete determines for each name or symbol the following properties:

Error reporting

Currently only indentation errors and bracket mismatches are reported.

References and definitions

You can open the reference view for any symbol or name. Put the cursor on it and select from the context menu KDB-Q/Find references or press ctrl+shift+r. The reference panel will appear, you can select any row or close it with the close button.

You can jump to the definition (assignment) of any name. Put the cursor on it and select from the context menu KDB-Q/Find definition or press ctrl+alt+d. If there are several definitions do this several times. After the last definition you will return to the original place.

QDoc support

QDoc is implemented along JavaDoc and is compatible with the already existing QDoc schemas. All standard functions and .Q/.z functions are already documented.

All tags are mutiline except @name, @file, @see, @noautocomplete and @module. @module and @file are not supported atm. All QDoc lines should start with /, all lines with more than one / are ignored allowing you to add private comments. The Q function or variable name should be on the next line after the comment block. Note that QDoc doesn't need the code to be correct.

The following tags are supported:

TypeExpr is type or (type name) or (type 1|type 2).

Example:

/ The verb xkey sets the primary keys in a table.
/ The left argument is a symbol list of column names, which must belong to the table.
/ The right argument is a table. If passed by reference, it is updated. If passed by value, a new table is returned.
/ @param x (symbol|symbol list) Columns.
/ @param y (symbol|table)  Table to be keyed.
/ @returns (symbol|table) Table is keyed, what is returned depends on the second argument.
/ @example `sym xkey `trade
/ @see cols xcol xcols
xkey

If you press F1 on xkey you'll see this: help

Note that QDoc also adds a link to the definition and allows you to request all references to the displayed name.

settings

Autocomplete looks for .autocomplete-kdb-q.json file in each project directory. This file can contain some settings:

Example:

{
  "ignorePaths": ["node_modules"],
  "includePaths": ["C:\\somepath\\test.q","C:\\somedir"],
  "ignoreNames": ["a2014.q",".git"],
  "cache": ".cache"
}