New in Nova


Version 12b

October 7, 2024

Cursor position history

Your cursor position history is now preserved, allowing you to cycle through previous editing locations.

New Find sidebar

Completely resdesigned from the ground up with a refined design and powerful new features.

Copy with Syntax Highlighting

Effortlessly copy code to other applications, complete with syntax highlighting.

Beta Testing Focus Areas

The following features of Nova 12 are particularly important as focus areas during beta testing:

New

New for Extensions

Improved

Fixed

What’s New for Extension Developers

New APIs have been added for language and completion extensions. The first set are new query predicates and directives, and the second set allows a language’s “highlights” query to capture arbitrary metadata about the parse tree when a completion request is performed, and pass that metadata to a completion provider’s JavaScript handler.

Full documentation of these changes will be provided before the final release of Nova 12, but for now these notes detail the important bits.

“Any” Query Predicates / Directives

A new set of “any” predicates / directives have been implemented for Tree-sitter queries. These are useful when working with captures which might match multiple parse tree nodes, such as on nodes using the regex-style * and + operators.

These will evaluate true if any of the nodes which are captured match, and act as counterparts to the existing “non-any” versions, which only evaluate true if all captured nodes match.

Filter Predicates

Property Set Directives

Query Metadata for Captures

Queries have previously had the capability to set metadata on a matched parse tree node by using the set*! family of directives. Such metadata was, until now, only utilized by the parser’s internals as a way for queries to specify contextual info (such as for symbolication).

Now, metadata can also be set on specific captures of a match. To do this, a capture name can be specified immediately preceding the variable parameter of the directive. For directives which already take a capture parameter to compare (such as #set-if-eq!), the existing parameter is being renamed compareCapture in documentation to clarify. Otherwise, the behavior of these directives remains the same.

For example, using the following directive will set variableName to variableValue on the captured node @myNode, if the text of the node @nodeToCompare is foobar:

(#set-if-eq! @nodeToCompare "foobar" @myNode "variableName" "variableValue")

Completion Provider API for Query Metadata

Additionally, extensions vending a Completion Provider via JavaScript can now access the metadata applied by a language’s “highlights” query during a completion request. This should allow completion provider logic to access much richer parse tree information.

The CompletionContext type has a new matches property, which is an array of ParseTreeMatch objects matched during evaluation of the relevant language’s highlights query when a completion request is made at the cursor’s location.

Each ParseTreeMatch object in the array has two properties: metadata and captures. The metadata is a simple object mapping metadata variable keys to values. The captures is a simple object mapping capture names to ParseTreeCapture objects. Each capture object, in turn, has a metadata property (containing any metadata set on that capture), as well as text (the text captured) and range (the range of the captured node). Note: the text property is the final result which may have been transformed by query directives (such as prefix!); the range is the range of the original text.

For example, taking the directive used above, a completion provider can access the metadata like so:

provideCompletionItems(editor, context) {
    var items = [];
    let matches = context.matches;
    for match of matches {
      let value = match.captures["myNode"].metadata["variableValue"];
      if value == "variableValue" {
        // Do something interesting!
      }
    }
    return items;
}