-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4dc3065
Showing
8 changed files
with
207 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Trigger CI | ||
on: push | ||
|
||
jobs: | ||
build: | ||
name: Dispatch to main repo | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Emit repository_dispatch | ||
uses: mvasigh/dispatch-action@main | ||
with: | ||
# You should create a personal access token and store it in your repository | ||
token: ${{ secrets.DISPATCH_AUTH }} | ||
repo: dev | ||
owner: codemirror | ||
event_type: push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/node_modules | ||
package-lock.json | ||
/dist | ||
/test/*.js | ||
/test/*.d.ts | ||
/test/*.d.ts.map | ||
.tern-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/src | ||
/test | ||
/node_modules | ||
.tern-* | ||
rollup.config.js | ||
tsconfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (C) 2024 by Marijn Haverbeke <marijn@haverbeke.berlin> and others | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!-- NOTE: README.md is generated from src/README.md --> | ||
|
||
# @codemirror/lang-yaml [](https://www.npmjs.org/package/@codemirror/lang-yaml) | ||
|
||
[ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lang-yaml/blob/main/CHANGELOG.md) ] | ||
|
||
This package implements YAML language support for the | ||
[CodeMirror](https://codemirror.net/) code editor. | ||
|
||
The [project page](https://codemirror.net/) has more information, a | ||
number of [examples](https://codemirror.net/examples/) and the | ||
[documentation](https://codemirror.net/docs/). | ||
|
||
This code is released under an | ||
[MIT license](https://github.com/codemirror/lang-yaml/tree/main/LICENSE). | ||
|
||
We aim to be an inclusive, welcoming community. To make that explicit, | ||
we have a [code of | ||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies | ||
to communication around the project. | ||
|
||
## API Reference | ||
|
||
<dl> | ||
<dt id="user-content-yaml"> | ||
<code><strong><a href="#user-content-yaml">yaml</a></strong>() → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt> | ||
|
||
<dd><p>Language support for YAML.</p> | ||
</dd> | ||
<dt id="user-content-yamllanguage"> | ||
<code><strong><a href="#user-content-yamllanguage">yamlLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt> | ||
|
||
<dd><p>A language provider based on the <a href="https://github.com/lezer-parser/yaml">Lezer YAML | ||
parser</a>, extended with | ||
highlighting and indentation information.</p> | ||
</dd> | ||
</dl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "@codemirror/lang-yaml", | ||
"version": "6.2.1", | ||
"description": "YAML language support for the CodeMirror code editor", | ||
"scripts": { | ||
"test": "cm-runtests", | ||
"prepare": "cm-buildhelper src/yaml.ts" | ||
}, | ||
"keywords": [ | ||
"editor", | ||
"code" | ||
], | ||
"author": { | ||
"name": "Marijn Haverbeke", | ||
"email": "marijn@haverbeke.berlin", | ||
"url": "http://marijnhaverbeke.nl" | ||
}, | ||
"type": "module", | ||
"main": "dist/index.cjs", | ||
"exports": { | ||
"import": "./dist/index.js", | ||
"require": "./dist/index.cjs" | ||
}, | ||
"types": "dist/index.d.ts", | ||
"module": "dist/index.js", | ||
"sideEffects": false, | ||
"license": "MIT", | ||
"dependencies": { | ||
"@codemirror/autocomplete": "^6.0.0", | ||
"@codemirror/language": "^6.0.0", | ||
"@codemirror/state": "^6.0.0", | ||
"@lezer/common": "^1.0.2", | ||
"@lezer/yaml": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"@codemirror/buildhelper": "^1.0.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/codemirror/lang-yaml.git" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!-- NOTE: README.md is generated from src/README.md --> | ||
|
||
# @codemirror/lang-yaml [](https://www.npmjs.org/package/@codemirror/lang-yaml) | ||
|
||
[ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lang-yaml/blob/main/CHANGELOG.md) ] | ||
|
||
This package implements YAML language support for the | ||
[CodeMirror](https://codemirror.net/) code editor. | ||
|
||
The [project page](https://codemirror.net/) has more information, a | ||
number of [examples](https://codemirror.net/examples/) and the | ||
[documentation](https://codemirror.net/docs/). | ||
|
||
This code is released under an | ||
[MIT license](https://github.com/codemirror/lang-yaml/tree/main/LICENSE). | ||
|
||
We aim to be an inclusive, welcoming community. To make that explicit, | ||
we have a [code of | ||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies | ||
to communication around the project. | ||
|
||
## API Reference | ||
|
||
@yaml | ||
|
||
@yamlLanguage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import {parser} from "@lezer/yaml" | ||
import {LRLanguage, delimitedIndent, indentNodeProp, | ||
foldNodeProp, foldInside, LanguageSupport} from "@codemirror/language" | ||
import {SyntaxNode} from "@lezer/common" | ||
|
||
/// A language provider based on the [Lezer YAML | ||
/// parser](https://github.com/lezer-parser/yaml), extended with | ||
/// highlighting and indentation information. | ||
export const yamlLanguage = LRLanguage.define({ | ||
name: "yaml", | ||
parser: parser.configure({ | ||
props: [ | ||
indentNodeProp.add({ | ||
Stream: cx => { | ||
for (let before = cx.node.resolve(cx.pos, -1) as SyntaxNode | null; | ||
before && before.to >= cx.pos; before = before.parent) { | ||
if (before.name == "BlockLiteralContent" && before.from < before.to) | ||
return cx.baseIndentFor(before) | ||
if (before.name == "BlockLiteral") | ||
return cx.baseIndentFor(before) + cx.unit | ||
if (before.name == "BlockSequence" || before.name == "BlockMapping") | ||
return cx.column(before.from, 1) | ||
if (before.name == "QuotedLiteral") | ||
return null | ||
if (before.name == "Literal") { | ||
let col = cx.column(before.from, 1) | ||
if (col == cx.lineIndent(before.from, 1)) return col // Start on own line | ||
if (before.to > cx.pos) return null | ||
} | ||
} | ||
return null | ||
}, | ||
FlowMapping: delimitedIndent({closing: "}"}), | ||
FlowSequence: delimitedIndent({closing: "]"}), | ||
}), | ||
foldNodeProp.add({ | ||
"FlowMapping FlowSequence": foldInside, | ||
"BlockSequence BlockMapping BlockLiteral": | ||
(node, state) => ({from: state.doc.lineAt(node.from).to, to: node.to}) | ||
}) | ||
] | ||
}), | ||
languageData: { | ||
commentTokens: {line: "#"}, | ||
indentOnInput: /^\s*[\]\}]$/, | ||
} | ||
}) | ||
|
||
/// Language support for YAML. | ||
export function yaml() { | ||
return new LanguageSupport(yamlLanguage) | ||
} |