mirror of
https://github.com/heyman/heynote.git
synced 2024-11-21 15:33:14 +01:00
Add TypeScript, JSX and TSX language support (#64)
* Add language support for TypeScript * Add formatter for TypeScript * Add language autodetection for TypeScript * Add TypeScript to list of featured languages * Add language support for JSX and TSX * Add JSX and TSX to list of featured languages * Remove guesslang token from JSX and TSX * Fix syntax error --------- Co-authored-by: Jonatan Heyman <jonatan@heyman.info>
This commit is contained in:
parent
bb511b868b
commit
475f3465fe
@ -24,6 +24,9 @@ Available for Mac, Windows, and Linux.
|
||||
- HTML
|
||||
- Java
|
||||
- JavaScript
|
||||
- JSX
|
||||
- TypeScript
|
||||
- TSX
|
||||
- JSON
|
||||
- Lezer
|
||||
- Markdown
|
||||
|
@ -4,6 +4,7 @@ GUESSLANG_LANGUAGES = [
|
||||
"json",
|
||||
"py",
|
||||
"js",
|
||||
"ts",
|
||||
"html",
|
||||
"sql",
|
||||
"java",
|
||||
|
@ -11,7 +11,7 @@ NoteDelimiter {
|
||||
|
||||
@tokens {
|
||||
noteDelimiterMark { "∞∞∞" }
|
||||
NoteLanguage { "text" | "math" | "javascript" | "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" }
|
||||
Auto { "-a" }
|
||||
noteDelimiterEnter { "\n" }
|
||||
//NoteContent { String }
|
||||
|
@ -10,7 +10,7 @@ export const parser = LRParser.deserialize({
|
||||
maxTerm: 10,
|
||||
skippedNodes: [0],
|
||||
repeatNodeCount: 1,
|
||||
tokenData: "*c~R`YZ!T}!O!Y#V#W!e#X#Y$R#Z#[$q#[#]$w#^#_%Z#`#a&t#a#b'^#d#e(]#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i$}~%QP#a#b%T~%WP#`#a#a~%^Q#T#U%d#g#h&h~%gP#j#k%j~%mP#T#U%p~%uPT~#g#h%x~%{P#V#W&O~&RP#f#g&U~&XP#]#^&[~&_P#d#e&b~&eP#h#i#a~&kQ#c#d&q#l#m#a~&tP#b#c#a~&zP#X#Y&}~'QP#n#o'T~'WP#X#Y'Z~'^P#f#g#a~'dP#T#U'g~'jQ#f#g'p#h#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~)zR#X#Y*T#g#h*Z#m#n*a~*WP#l#m&b~*^P#l#m#a~*dP#d#e*g~*jP#X#Y*m~*pP#g#h%x~*vP#T#U$}~*|P%&x%&y+P~+SP%&x%&y+V~+[OY~",
|
||||
tokenizers: [0, noteContent],
|
||||
topRules: {"Document":[0,2]},
|
||||
tokenPrec: 0
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { jsonLanguage } from "@codemirror/lang-json"
|
||||
import { pythonLanguage } from "@codemirror/lang-python"
|
||||
import { javascriptLanguage } from "@codemirror/lang-javascript"
|
||||
import { javascriptLanguage, jsxLanguage, tsxLanguage, typescriptLanguage } from "@codemirror/lang-javascript"
|
||||
import { htmlLanguage } from "@codemirror/lang-html"
|
||||
import { StandardSQL } from "@codemirror/lang-sql"
|
||||
import { markdownLanguage } from "@codemirror/lang-markdown"
|
||||
@ -21,6 +21,7 @@ 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 typescriptPlugin from "prettier/plugins/typescript.mjs"
|
||||
import babelPrettierPlugin from "prettier/plugins/babel.mjs"
|
||||
import htmlPrettierPlugin from "prettier/esm/parser-html.mjs"
|
||||
import cssPrettierPlugin from "prettier/esm/parser-postcss.mjs"
|
||||
@ -189,6 +190,27 @@ export const LANGUAGES = [
|
||||
guesslang: "js",
|
||||
prettier: {parser:"babel", plugins: [babelPrettierPlugin, prettierPluginEstree]},
|
||||
}),
|
||||
new Language({
|
||||
token: "jsx",
|
||||
name: "JSX",
|
||||
parser: jsxLanguage.parser,
|
||||
guesslang: null,
|
||||
prettier: {parser:"babel", plugins: [babelPrettierPlugin, prettierPluginEstree]},
|
||||
}),
|
||||
new Language({
|
||||
token: "typescript",
|
||||
name: "TypeScript",
|
||||
parser: typescriptLanguage.parser,
|
||||
guesslang: "ts",
|
||||
prettier: {parser:"typescript", plugins: [typescriptPlugin, prettierPluginEstree]},
|
||||
}),
|
||||
new Language({
|
||||
token: "tsx",
|
||||
name: "TSX",
|
||||
parser: tsxLanguage.parser,
|
||||
guesslang: null,
|
||||
prettier: {parser:"typescript", plugins: [typescriptPlugin, prettierPluginEstree]},
|
||||
}),
|
||||
]
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user