Skip to content

Commit 0f760e3

Browse files
committed
feat: add Swift language highlighting.
1 parent 3acb991 commit 0f760e3

File tree

5 files changed

+9
-1
lines changed

5 files changed

+9
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
CodeMirror
3434
===
3535

36+
![CodeMirror for macOS/iOS](https://github.com/user-attachments/assets/2d25564c-bb2b-4297-a4c5-1db03d13a5ce)
37+
3638
SwiftUI wrapper for CodeMirror 6.
3739

3840
## Features

Sources/CodeMirror/CodeMirrorVM.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public enum Language: String, CaseIterable, Hashable {
2929
case pgsql
3030
case liquid
3131
case wast
32+
case swift
3233
case txt
3334
}
3435

Sources/CodeMirror/html/codemirror.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as CodeMirror from "codemirror";
22
import { Compartment, EditorState } from "@codemirror/state";
33
import { EditorView } from "@codemirror/view";
44
import { indentWithTab } from "@codemirror/commands";
5+
import { StreamLanguage } from '@codemirror/language';
56
import { javascript } from "@codemirror/lang-javascript";
67
import { html } from "@codemirror/lang-html";
78
import { json } from "@codemirror/lang-json";
@@ -20,6 +21,8 @@ import { vue } from '@codemirror/lang-vue';
2021
import { java } from '@codemirror/lang-java';
2122
import { sql, MySQL, PostgreSQL } from '@codemirror/lang-sql';
2223
import { python } from '@codemirror/lang-python';
24+
import { swift } from '@codemirror/legacy-modes/mode/swift';
25+
2326
import { oneDark } from "@codemirror/theme-one-dark";
2427

2528
import { abcdef } from '@uiw/codemirror-theme-abcdef';
@@ -116,6 +119,7 @@ const SUPPORTED_LANGUAGES_MAP = {
116119
pgsql: () => sql({ dialect: PostgreSQL }),
117120
liquid,
118121
wast,
122+
swift: () => StreamLanguage.define(swift),
119123
txt: () => [],
120124
};
121125

Sources/CodeMirror/html/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@codemirror/lang-sql": "^6.0.0",
2121
"@codemirror/lang-xml": "^6.0.0",
2222
"@codemirror/language-data": "^6.0.0",
23+
"@codemirror/legacy-modes": "^6.5.1",
2324
"@codemirror/theme-one-dark": "^6.0.0",
2425
"@rollup/plugin-node-resolve": "^15.0.2",
2526
"@rollup/plugin-terser": "^0.4.0",

Sources/CodeMirror/html/web.bundle/codemirror.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)