Skip to content

Commit

Permalink
Improve, add example.
Browse files Browse the repository at this point in the history
  • Loading branch information
Romain Beauxis committed Oct 26, 2023
1 parent e276ec7 commit 26d1b04
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 58 deletions.
1 change: 1 addition & 0 deletions examples/dist
40 changes: 40 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<html>
<head>
<meta charset="UTF-8" />
<script type="importmap">
{
"imports": {
"codemirror": "https://esm.sh/[email protected]",
"@codemirror/state": "https://esm.sh/@codemirror/[email protected]",
"@uiw/codemirror-theme-github": "https://esm.sh/@uiw/[email protected]",
"@codemirror/language": "https://esm.sh/@codemirror/[email protected]",
"@lezer/highlight": "https://esm.sh/@lezer/[email protected]",
"@lezer/lr": "https://esm.sh/@lezer/[email protected]",
"codemirror-lang-liquidsoap": "./dist/index.js"
}
}
</script>
<script type="module">
import { basicSetup, EditorView } from "codemirror";
import { githubLight } from "@uiw/codemirror-theme-github";
import { liquidsoap } from "codemirror-lang-liquidsoap";

new EditorView({
doc: `# ✨ Welcome to liquidsoap's test editor! ✨
# Write your code here:
`,
extensions: [
basicSetup,
liquidsoap(),
githubLight
],
parent: document.getElementById("editor")
});

</script>
</head>
<body>
<div id="editor"></div>
</body>
</html>
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codemirror-lang-liquidsoap",
"version": "0.1.0",
"version": "0.2.0",
"description": "Liquidsoap language support for prosemirror",
"main": "dist/index.cjs",
"bin": {
Expand All @@ -17,6 +17,8 @@
"license": "MIT",
"devDependencies": {
"@lezer/generator": "^1.0.0",
"codemirror": "^6.0.1",
"prettier": "^3.0.3",
"rollup": "^2.60.2",
"rollup-plugin-dts": "^4.0.1",
"rollup-plugin-preserve-shebang": "^1.0.1",
Expand All @@ -41,6 +43,7 @@
"scripts": {
"build": "lezer-generator src/liquidsoap.grammar -o src/parser && rollup -c && chmod +x dist/cli.js",
"test": "./tests/run.sh",
"format": "pnpm prettier -w src/*.ts src/*.js",
"prepare": "npm run build"
}
}
73 changes: 67 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 21 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,39 @@ export const LiquidsoapLanguage = LRLanguage.define({
props: [
styleTags({
Var: t.variableName,
Type: t.typeName,
"Type/...": t.typeName,
Bool: t.bool,
String: t.string,
Method: t.propertyName,
LabeledArgument: t.labelName,
"Method/...": t.propertyName,
"LabeledArgument/...": t.labelName,
Integer: t.integer,
Float: t.float,
Regexp: t.regexp,
EscapedChar: t.escape,
Op: t.operatorKeyword,
"LetDecoration/...": t.modifier,
"Defined/Var": t.definition(t.variableName),
"Defined/Varlpar": t.definition(t.function(t.variableName)),
"Defined/Subfield/*/Var": t.definition(t.propertyName),
"Defined/SubfieldLpar/*/Varlpar": t.definition(
t.function(t.propertyName),
),
"SubfieldLpar/*/Varlpar": t.function(t.propertyName),
Varlpar: t.function(t.variableName),
LineComment: t.lineComment,
BlockComment: t.blockComment,
ControlKeyword: t.controlKeyword,
Keyword: t.keyword,
DefinitionKeyword: t.definitionKeyword,
LogicOperator: t.logicOperator,
CompareOperator: t.compareOperator,
ArithmeticOperator: t.arithmeticOperator,
DocComment: t.docComment,
"ControlKeyword/...": t.controlKeyword,
"Keyword/...": t.keyword,
"DefinitionKeyword/...": t.definitionKeyword,
"LogicOperator/...": t.logicOperator,
"CompareOperator/...": t.compareOperator,
"ArithmeticOperator/...": t.arithmeticOperator,
DerefOp: t.derefOperator,
UpdateOp: t.updateOperator,
"( )": t.paren,
"[ ]": t.bracket,
"{ }": t.brace,
"[ ]": t.squareBracket,
}),
],
}),
Expand Down
Loading

0 comments on commit 26d1b04

Please sign in to comment.