nanangp / vscode-wireviz-preview

A simple extension for Visual Studio Code to preview WireViz YAML files
https://marketplace.visualstudio.com/items?itemName=NanangP.vscode-wireviz-preview
GNU General Public License v3.0
5 stars 1 forks source link

Linking the WireViz output messages to the YAML input #7

Open martinrieder opened 4 months ago

martinrieder commented 4 months ago

This issue depends on the actual implementation of #5 moving the STDOUT/STDERR outputs to console.

If there was a way to have a link of the error output to the YAML input, this would highly improve the usability.

See usernamehw/vscode-error-lens as a reference implementation.

@nanangp see also https://github.com/wireviz/WireViz/issues/305#issuecomment-1925291637

@martinrieder in https://github.com/wireviz/WireViz/issues/207#issuecomment-2116255383

martinrieder commented 4 months ago

Copying https://github.com/wireviz/WireViz/issues/223#issuecomment-2122002142

For anyone who wants to dive a bit deeper into the topic, I recommend reading the following document:

https://eemeli.org/yaml/#parsing-yaml

This comes from the library that is used to provide syntax highlighting and error checking in https://github.com/redhat-developer/YAML-language-server for VScode. It is not programmed in Python, but we might take advantage of the CLI that it provides: It relies on parsing YAML into a CST as an intermediate step to provide an AST. This is a unique approach that other libraries do not take, but seems to be just what we need here.

Side note: Graphviz dot is also supported in VScode through https://github.com/nikeee/dot-language-server

martinrieder commented 4 months ago

@nanangp I am considering to create a schema definition for the WireViz syntax. This would allow the language server to do some live checks while editing.

From https://github.com/redhat-developer/yaml-language-server :

Associating a schema in the YAML file It is possible to specify a yaml schema using a modeline. Schema url can be a relative path. If a relative path is specified, it is calculated from yaml file path, not from workspace root path

# yaml-language-server: $schema=<urlToTheSchema>

I created wireviz/WireViz#348 to have a compatibility check, but realized that schema validation might be what is truly needed.

martinrieder commented 4 months ago

I propose that another method should be used for assigning the schema besides the Modeline. See here for details on the extension API that might be used for this: https://github.com/redhat-developer/vscode-yaml/wiki/Extension-API#register-contributor

This is not a true solution to what the original issue text describes, but it would definitely be helpful if it were possible to have validation while editing.

martinrieder commented 3 months ago

I propose that another method should be used for assigning the schema besides the Modeline. See here for details on the extension API that might be used for this: https://github.com/redhat-developer/vscode-yaml/wiki/Extension-API#register-contributor

This is not a true solution to what the original issue text describes, but it would definitely be helpful if it were possible to have validation while editing.

@nanangp please see the JSON Schema file I uploaded into wireviz/WireViz#348 and validate your files with this. jsonschema.json

I would love to see this added into the Vscode extension, so the schema gets assigned once you generate or edit a WireViz file.

martinrieder commented 3 months ago

If there was a way to have a link of the error output to the YAML input, this would highly improve the usability.

See here for a possible solution, once the WireViz output provides an output that is machine readable: