Add Swift and Kotlin language support #10 (#96)

* Add Swift language support

* Add Kotlin language support
This commit is contained in:
Laeyoung 2023-12-31 18:07:21 +09:00 committed by GitHub
parent a1cad5b335
commit b0f3bdd19e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 3 deletions

View File

@ -16,7 +16,7 @@ Available for Mac, Windows, and Linux.
- Block-based
- Syntax highlighting:
C++, C#, Clojure, CSS, Erlang, Go, HTML, Java, JavaScript, JSX, TypeScript, TOML, TSX, JSON, Lezer, Markdown, PHP, Python, Ruby, Rust, Shell, SQL, XML, YAML
C++, C#, Clojure, CSS, Erlang, Go, HTML, Java, JavaScript, JSX, Kotlin, TypeScript, TOML, TSX, JSON, Lezer, Markdown, PHP, Python, Ruby, Rust, Shell, SQL, Swift, XML, YAML
- Language auto-detection
- Auto-formatting

View File

@ -22,6 +22,8 @@ GUESSLANG_LANGUAGES = [
"clj",
"erl",
"toml",
"swift",
"kt",
]
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" | "toml" }
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" | "swift" | "kotlin" }
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#^#_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[#]#x#g#h#d~#{P#T#U$O~$RP#f#g#i~$XP#f#g$[~$_P#`#a$b~$eP#T#U$h~$kP#b#c$n~$qP#Z#[#d~$wP#c#d$[~$}P#h#i%Q~%TP#a#b%W~%ZP#`#a#d~%aQ#T#U%g#g#h&k~%jP#j#k%m~%pP#T#U%s~%xPT~#g#h%{~&OP#V#W&R~&UP#f#g&X~&[P#]#^&_~&bP#d#e&e~&hP#h#i#d~&nQ#c#d&t#l#m#d~&wP#b#c#d~&}P#c#d'Q~'TP#h#i'W~'ZP#`#a'^~'aP#]#^&t~'gP#X#Y'j~'mP#n#o'p~'sP#X#Y'v~'yP#f#g#d~(PP#T#U(S~(VQ#f#g(]#h#i(u~(`P#_#`(c~(fP#W#X(i~(lP#c#d(o~(rP#k#l&t~(xP#[#]#d~)OQ#[#]#i#m#n)U~)XP#h#i)[~)_P#[#])b~)eP#c#d&t~)kP#i#j)n~)qQ#U#V)w#g#h&e~)zP#m#n#d~*QR#[#]*Z#e#f%W#k#l*g~*^P#X#Y*a~*dP#`#a%W~*jP#]#^*m~*pP#Y#Z&e~*vS#X#Y+S#c#d%Q#g#h+Y#m#n+`~+VP#l#m&e~+]P#l#m#d~+cP#d#e+f~+iP#X#Y+l~+oP#g#h%{~+uP#T#U%Q~+{P%&x%&y,O~,RP%&x%&y,U~,ZOY~",
tokenizers: [0, noteContent],
topRules: {"Document":[0,2]},
tokenPrec: 0

View File

@ -21,6 +21,8 @@ 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 { swift } from "@codemirror/legacy-modes/mode/swift"
import { kotlin } from "@codemirror/legacy-modes/mode/clike"
import typescriptPlugin from "prettier/plugins/typescript.mjs"
import babelPrettierPlugin from "prettier/plugins/babel.mjs"
@ -218,6 +220,18 @@ export const LANGUAGES = [
guesslang: null,
prettier: {parser:"typescript", plugins: [typescriptPlugin, prettierPluginEstree]},
}),
new Language({
token: "swift",
name: "Swift",
parser: StreamLanguage.define(swift).parser,
guesslang: "swift",
}),
new Language({
token: "kotlin",
name: "Kotlin",
parser: StreamLanguage.define(kotlin).parser,
guesslang: "kt",
}),
]