-
-
Notifications
You must be signed in to change notification settings - Fork 342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YAML language support #306
Comments
I'm unlikely to work on this myself, so this'd be a great candidate for a 3rd party implementation. |
Yeah, I expect YAML to be one of the more challenging languages to add support for. For anyone interested in it, this might be of help: https://github.com/yaml/yaml-grammar "Fully comprehending the YAML grammar is quite an undertaking for most mortals. Creating a fully compliant parser has proven almost impossible." |
Hah. That's what I was afraid of. Probably running the CM5 mode in stream-syntax is the least annoying option for the time being. |
Hi there, while searching the web for a browser-based YAML editor, I found your notes here. When looking further, I found an article outlining a Vue YAML code editor component [1], in turn based on With kind regards, |
There is now a stream mode for YAML in the legacy-modes package, which can be used for YAML highlighting. While it'd still be great if someone were to write and distribute a more thorough parser at some point, I don't expect to be working on this myself, so I'm going to close this issue. |
Btw. for anyone curious about using the import * as yamlMode from '@codemirror/legacy-modes/mode/yaml';
import * as streamParser from '@codemirror/stream-parser';
const yaml = new LanguageSupport(streamParser.StreamLanguage.define(yamlMode.yaml)); ...and then you can use |
Hi what library is the LanguageSupport Object from ? |
It's from @codemirror/language. |
I get the error Argument of type ' |
Thank you @marijnh @juliusv =) As for me, a working solution for yml highlighting is.. Install
Then import { basicSetup, EditorView } from 'codemirror'
import * as yamlMode from '@codemirror/legacy-modes/mode/yaml';
import { StreamLanguage, LanguageSupport } from "@codemirror/language"
const yaml = new LanguageSupport(StreamLanguage.define(yamlMode.yaml));
ideInput = new EditorView({
doc: "<here goes default yaml code>",
extensions: [
basicSetup,
yaml
],
parent: document.getElementById("root-div");
}) Omiting the
|
import { LanguageSupport, StreamLanguage } from '@codemirror/language'; |
Question: how can we get collapses like are available for javascript? An extremely important aspect of YAML is the ability (in larger files) is the ability to check indentation? So I'd love to be able to collapse with the > & v symbols, but I don't know how to enable it and I suspect it's due to the implementation with the legacy parser or whatever. What would it take to add this ability? |
This is just to track that there doesn't currently seem to be any YAML language support yet, neither for lezer, nor for CodeMirror Next more generally. YAML being the de-facto standard config language for so many current cloud tools would be great to support at some point.
The text was updated successfully, but these errors were encountered: