Skip to content

Various improvements #36

Description

@panoply

Historically, the Fauna team has ignored my questions pertaining to contributions which I'll begin by prefacing:

The reason for referencing these is because ignoring developers requests reflects badly, especially when they are wanting to assist and help. This will be the last time I reach out or bother trying, so it is my hope that some form of communication is had.


This extension is a great starting point but it is definitely lacking in a lot of areas. Firstly, the grammars. Token captures are limited and the vast majority of syntactics of importance are defaulting to source.fql and not asserting the correct name refs. Themes are unable to differentiate between structures given the elementary approach taken on grammars.

fql``

Because Fauna has now rolled out FQL in fql`` template literals, I'm curious as to why the extension is not supporting injections here given the importance literals now apply. The fql language grammar is already passed, an injection grammar can be leveraged. This is a basic and easy to support, e.g:

{
      "name": "string.js.taggedTemplate.literal.js",
      "contentName": "meta.embedded.block.fql",
      "begin": "(\\bfql\\b)(`)",
      "beginCaptures": {
        "1": {
          "name": "entity.name.function.tagged-template.js"
        },
        "2": {
          "name": "punctuation.definition.string.template.begin.js"
        }
      },
      "end": "(`)",
      "patterns": [
        {
          "include": "source.fql"
        },
        {
          "match": "."
        }
      ]
    }

In addition, ensure injectionSelector does not conflict with something like:

{
  "injectionSelector": "L:source.js -comment -(string - meta.embedded), L:source.jsx -comment -(string - meta.embedded), L:source.js.jsx -comment -(string - meta.embedded), L:source.ts -comment -(string - meta.embedded), L:source.tsx -comment -(string - meta.embedded)"
}

From here, you simply need to reference in contributions via package.json

 {
        "injectTo": [
          "source.js",
          "source.js.jsx",
          "source.jsx",
          "source.ts",
          "source.tsx",
          "text.html.basic",
          "text.html.derivative",
          "text.html.markdown"
        ],
        "scopeName": "<SCOPE>",
        "path": "./syntax/<NAME-OF-GRAMMAR>.tmLanguage.json",
        "embeddedLanguages": {
          "meta.embedded.block.fql": "fql"
        }
      },

Of course there is some additional handling imposed, but you get the picture.

Improve scopes

Let's take a quick look at .fsl wherein extension is not applied to textmate scope of variable.other.property

Screenshot 2023-12-08 at 20 45 22

This can be problematic in cases where a developer is leveraging editor.tokenColorCustomizations and wants to target this scope specifically. Such logic can easily be patched by simply ensuring token names always apply .fsl or .fql suffixes. Moving on, the grammars can generally be improved with better captures and matching applied, I'd be happy to provide a list or overhaul.

IntelliSense / FQL Language Server

I've touched on this previously in the linked issues of now deprecates/legacy tooling. The fql-analyzer from what I can tell is responsible for completions and other LSP capabilities like validations (which is great) however the implementation is void of descriptions and hover features. This makes things very difficult given the size of the FQL spec and would be of great value if exposed.

The Fauna Shell via the Dashboard is leveraging CodeMirror, which supports the protocol and by supporting descriptions and additional capabilities (i.e: hovers) both the editor (this extension) and the shell (dashboard) toolings benefit. The documentation already provides good, short and informative texts, and given LSP can digest Markdown descriptions, (which I'd assume the official docs are composed with) can we see about introducing them based on the documentation that already available?

Lastly, the fql`` literal can also benefit from the existing fql-analyzer capabilities. This will require some mild parsing to obtain occurrences within TextDocuments of the editor. Typically lexing is done on the language server, but this can also be done on this client, in any sense are there plans to open source this (https://static-assets.fauna.com/fql-analyzer/index.js) so support can be made available in literals.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions