Add TOML support

This commit is contained in:
Jonatan Heyman 2023-12-26 01:31:36 +01:00
parent 475f3465fe
commit 60caac45ab
6 changed files with 27 additions and 2 deletions

View File

@ -26,6 +26,7 @@ Available for Mac, Windows, and Linux.
- JavaScript
- JSX
- TypeScript
- TOML
- TSX
- JSON
- Lezer

View File

@ -21,6 +21,7 @@ GUESSLANG_LANGUAGES = [
"go",
"clj",
"erl",
"toml",
]
const guessLang = new self.GuessLang()

View File

@ -11,7 +11,7 @@ NoteDelimiter {
@tokens {
noteDelimiterMark { "∞∞∞" }
NoteLanguage { "text" | "math" | "javascript" | "typescript" | "jsx" | "tsx" | "json" | "python" | "html" | "sql" | "markdown" | "java" | "php" | "css" | "xml" | "cpp" | "rust" | "csharp" | "ruby" | "shell" | "yaml" | "golang" | "clojure" | "erlang" | "lezer" }
NoteLanguage { "text" | "math" | "javascript" | "typescript" | "jsx" | "tsx" | "json" | "python" | "html" | "sql" | "markdown" | "java" | "php" | "css" | "xml" | "cpp" | "rust" | "csharp" | "ruby" | "shell" | "yaml" | "golang" | "clojure" | "erlang" | "lezer" | "toml" }
Auto { "-a" }
noteDelimiterEnter { "\n" }
//NoteContent { String }

View File

@ -10,7 +10,7 @@ export const parser = LRParser.deserialize({
maxTerm: 10,
skippedNodes: [0],
repeatNodeCount: 1,
tokenData: "+[~R`YZ!T}!O!Y#V#W!e#X#Y$R#Z#[$q#[#]$w#^#_%Z#`#a&w#a#b'a#d#e(`#f#g({#g#h)b#h#i)w#l#m$}#m#n*s%&x%&y*y~!YOX~~!]P#T#U!`~!eOU~~!hR#`#a!q#d#e#f#g#h#l~!tP#c#d!w~!zP#^#_!}~#QP#i#j#T~#WP#f#g#Z~#^P#X#Y#a~#fOT~~#iP#d#e#a~#oQ#[#]#u#g#h#a~#xP#T#U#{~$OP#f#g#f~$UP#f#g$X~$[P#`#a$_~$bP#T#U$e~$hP#b#c$k~$nP#Z#[#a~$tP#c#d$X~$zP#h#i$}~%QP#a#b%T~%WP#`#a#a~%^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i(Y~'sP#_#`'v~'yP#W#X'|~(PP#c#d(S~(VP#k#l&q~(]P#[#]#a~(cQ#[#]#f#m#n(i~(lP#h#i(o~(rP#[#](u~(xP#c#d&q~)OP#i#j)R~)UQ#U#V)[#g#h&b~)_P#m#n#a~)eQ#[#])k#e#f%T~)nP#X#Y)q~)tP#`#a%T~)zS#X#Y*W#c#d$}#g#h*^#m#n*d~*ZP#l#m&b~*aP#l#m#a~*gP#d#e*j~*mP#X#Y*p~*sP#g#h%x~*yP#T#U$}~+PP%&x%&y+S~+VP%&x%&y+Y~+_OY~",
tokenizers: [0, noteContent],
topRules: {"Document":[0,2]},
tokenPrec: 0

View File

@ -20,6 +20,7 @@ import { yaml } from "@codemirror/legacy-modes/mode/yaml"
import { go } from "@codemirror/legacy-modes/mode/go"
import { clojure } from "@codemirror/legacy-modes/mode/clojure"
import { erlang } from "@codemirror/legacy-modes/mode/erlang"
import { toml } from "@codemirror/legacy-modes/mode/toml"
import typescriptPlugin from "prettier/plugins/typescript.mjs"
import babelPrettierPlugin from "prettier/plugins/babel.mjs"
@ -165,6 +166,12 @@ export const LANGUAGES = [
guesslang: "yaml",
prettier: {parser:"yaml", plugins: [yamlPrettierPlugin]},
}),
new Language({
token: "toml",
name: "TOML",
parser: StreamLanguage.define(toml).parser,
guesslang: "toml",
}),
new Language({
token: "golang",
name: "Go",

View File

@ -37,3 +37,19 @@ print('The solution are {0} and {1}'.format(sol1,sol2))
`)
await expect(page.locator("css=.status .status-block.lang")).toHaveText("Python (auto)")
})
test("TOML detection", async ({ page }) => {
await page.locator("body").pressSequentially(`
[build-system]
requires = ["setuptools>=61", "wheel", "setuptools_scm>=6.2"]
build-backend = "setuptools.build_meta"
[project]
name = "locust"
license = { text = "MIT" }
description = "Developer friendly load testing framework"
dynamic = ["version"]
requires-python = ">=3.8"
`)
await expect(page.locator("css=.status .status-block.lang")).toHaveText("TOML (auto)")
})