Skip to content

Build your personal knowledge base with Trilium Notes

feat: add nim syntax highlighting

dirtbolle3d3343f4ca3
diff --git a/packages/codemirror/package.json b/packages/codemirror/package.json
index 8ecece2c1f..d97d637093 100644
--- a/packages/codemirror/package.json
+++ b/packages/codemirror/package.json
@@ -61,7 +61,8 @@
"@triliumnext/commons": "workspace:*",
"codemirror-lang-elixir": "4.0.1",
"codemirror-lang-hcl": "0.1.0",
- "codemirror-lang-mermaid": "0.5.0"
+ "codemirror-lang-mermaid": "0.5.0",
+ "codemirror-lang-nim": "0.1.0"
},
"devDependencies": {
"@types/jquery": "4.0.1"
diff --git a/packages/codemirror/src/syntax_highlighting.ts b/packages/codemirror/src/syntax_highlighting.ts
index ad968ea009..11d48ad647 100644
--- a/packages/codemirror/src/syntax_highlighting.ts
+++ b/packages/codemirror/src/syntax_highlighting.ts
@@ -142,6 +142,7 @@ const byMimeType: Record<SupportedMimeTypes, (() => Promise<StreamParser<unknown
"text/x-mumps": async () => (await import('@codemirror/legacy-modes/mode/mumps')).mumps,
"text/x-mysql": async () => (await import('@codemirror/legacy-modes/mode/sql')).mySQL,
"text/x-nix": async () => (await import('@replit/codemirror-lang-nix')).nix(),
+ "text/x-nim": async () => (await import('codemirror-lang-nim')).nim(),
"text/x-nginx-conf": async () => (await import('@codemirror/legacy-modes/mode/nginx')).nginx,
"text/x-nsis": async () => (await import('@codemirror/legacy-modes/mode/nsis')).nsis,
"text/x-objectivec": async () => (await import('@codemirror/legacy-modes/mode/clike')).objectiveC,
diff --git a/packages/commons/src/lib/mime_type.ts b/packages/commons/src/lib/mime_type.ts
index 793753082b..d09929adde 100644
--- a/packages/commons/src/lib/mime_type.ts
+++ b/packages/commons/src/lib/mime_type.ts
@@ -132,6 +132,7 @@ const MIME_TYPES_DICT_RAW = [
{ title: "MUMPS", mime: "text/x-mumps" },
{ title: "MySQL", mime: "text/x-mysql", mdLanguageCode: "sql", icon: "bx bx-data" },
{ title: "Nix", mime: "text/x-nix", mdLanguageCode: "nix" },
+ { title: "Nim", mime: "text/x-nim", mdLanguageCode: "nim" },
{ title: "Nginx", mime: "text/x-nginx-conf", mdLanguageCode: "nginx" },
{ title: "NSIS", mime: "text/x-nsis", mdLanguageCode: "nsis" },
{ title: "NTriples", mime: "application/n-triples" },
diff --git a/packages/highlightjs/src/syntax_highlighting.ts b/packages/highlightjs/src/syntax_highlighting.ts
index cd46a6f5f6..1335433453 100644
--- a/packages/highlightjs/src/syntax_highlighting.ts
+++ b/packages/highlightjs/src/syntax_highlighting.ts
@@ -108,6 +108,7 @@ export const byMimeType: MimeRecord = {
"text/x-mumps": null,
"text/x-mysql": () => import("highlight.js/lib/languages/sql"),
"text/x-nix": () => import("highlight.js/lib/languages/nix"),
+ "text/x-nim": () => import("highlight.js/lib/languages/nim"),
"text/x-nginx-conf": () => import("highlight.js/lib/languages/nginx"),
"text/x-nsis": () => import("highlight.js/lib/languages/nsis"),
"text/x-objectivec": () => import("highlight.js/lib/languages/objectivec"),
diff --git a/packages/trilium-core/src/services/import/mime.ts b/packages/trilium-core/src/services/import/mime.ts
index 5e2edb3be2..21ae7f1448 100644
--- a/packages/trilium-core/src/services/import/mime.ts
+++ b/packages/trilium-core/src/services/import/mime.ts
@@ -23,6 +23,7 @@ const CODE_MIME_TYPES = new Set([
"text/x-groovy",
"text/x-haskell",
"text/x-java",
+ "text/x-nim",
"text/x-kotlin",
"text/x-lua",
"text/x-markdown",
@@ -69,6 +70,7 @@ const EXTENSION_TO_MIME = new Map<string, string>([
[".http", "message/http"],
[".kt", "text/x-kotlin"],
[".m", "text/x-objectivec"],
+ [".nim", "text/x-nim"],
[".py", "text/x-python"],
[".rb", "text/x-ruby"],
[".scala", "text/x-scala"],
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f00821cf33..e929c44972 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1503,6 +1503,9 @@ importers:
codemirror-lang-mermaid:
specifier: 0.5.0
version: 0.5.0
+ codemirror-lang-nim:
+ specifier: 0.1.0
+ version: 0.1.0
typescript:
specifier: 6.0.3
version: 6.0.3
@@ -7545,6 +7548,9 @@ packages:
resolution: {integrity: sha512-Taw/2gPCyNArQJCxIP/HSUif+3zrvD+6Ugt7KJZ2dUKou/8r3ZhcfG8krNTZfV2iu8AuGnymKuo7bLPFyqsh/A==}
+ resolution: {integrity: sha512-HL++tDpTLx+gmIWl6uMpdREhR9RX74SZ1M3CM/ZDV+GywHjjiiQJ0mVx5wiw3wOghY72DMq8FCRy4S1TmotqCg==}
+
resolution: {integrity: sha512-loKTxY1zCOuG4j9f6EPnuyyYkf58RnhhWTvRoZEokgB+WbdXehfjFviyOVYkqzEWz1Q5kRiZdBYS5SwxbQYwzw==}
@@ -21809,6 +21815,12 @@ snapshots:
'@lezer/highlight': 1.2.3
'@lezer/lr': 1.4.10
+ dependencies:
+ '@codemirror/language': 6.12.4
+ '@lezer/highlight': 1.2.3
+ '@lezer/lr': 1.4.10
+