8000 A tera2 LSP to provide context-aware editor support? Request for comments · Issue #67 · Keats/tera2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
A tera2 LSP to provide context-aware editor support? Request for comments #67
Open
@asimpletune

Description

@asimpletune

This project I've been working on has gotten me thinking about maybe trying to improve tooling around tera, perhaps in the form of an improved plugin (LSP) for tera2?

For context, I don't think many templating languages have great editor support. The tera1 vscode plugin is a good start, but I think something that's more context aware would be very helpful, so I just wanted to start that conversation here.

By "context-aware" I mean somehow allowing users to to get feedback as they work on their templates that's aware of the context their templates will be rendered in. It could check for references to variables and filters that don't exist or are used incorrectly.

I think there are two types of contexts: explicit and implicit.

The user's own files are explicit, since everything originates from a literal.

Implicit context, like in Zola, is more difficult.. There's the __tera_context variable, but I don't think that could really be leveraged, since the tooling wouldn't have the same __tera_context as the Zola app.

Probably the easiest way would be to allow the user to tell the editor what the implicit context is. For example, one way to do this would be with a comment directive, where they can specify a URL to a schema that defines the context. For example:

{# context: https://getzola.org/schemas/0.19.2/zola.schema.json #}
<! -- or maybe -->
{# context: https://getzola.org/schemas/0.19.2/page.schema.json #}

Then the plugin would cache the schema and check any functions, filters, or variables referenced outside the explicit and implicit contexts. Probably it could be implemented as an LSP.

Anyways, it's just an idea. I'm sure others have already given the question plenty of thought, so I'd like to hear what anyone else may have to think.

For my project users define templates describing how comments received via email should be rendered as a comment file that their static site can later compile. To help with debugging I made a small CLI that can simulate an email and the resulting comment, but probably the best experience would be improved tooling for tera2 in general, which would benefit other projects too, like Zola.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0