Skip to content

Build your personal knowledge base with Trilium Notes

feat(code): add Nix language

Elian Doran2b192eb1b9dd
diff --git a/apps/client/src/services/mime_type_definitions.ts b/apps/client/src/services/mime_type_definitions.ts
index 1094e50071..546900c4d7 100644
--- a/apps/client/src/services/mime_type_definitions.ts
+++ b/apps/client/src/services/mime_type_definitions.ts
@@ -107,6 +107,7 @@ export const MIME_TYPES_DICT: readonly MimeTypeDefinition[] = Object.freeze([
{ title: "msgenny", mime: "text/x-msgenny" },
{ title: "MUMPS", mime: "text/x-mumps" },
{ title: "MySQL", mime: "text/x-mysql", highlightJs: "sql" },
+ { title: "Nix", mime: "text/x-nix" },
{ title: "Nginx", mime: "text/x-nginx-conf", highlightJs: "nginx" },
{ title: "NSIS", mime: "text/x-nsis", highlightJs: "nsis" },
{ title: "NTriples", mime: "application/n-triples" },
diff --git a/apps/server/src/services/import/mime_type_definitions.ts b/apps/server/src/services/import/mime_type_definitions.ts
index 55029914b5..b58bd8311d 100644
--- a/apps/server/src/services/import/mime_type_definitions.ts
+++ b/apps/server/src/services/import/mime_type_definitions.ts
@@ -107,6 +107,7 @@ export const MIME_TYPES_DICT: readonly MimeTypeDefinition[] = Object.freeze([
{ title: "msgenny", mime: "text/x-msgenny" },
{ title: "MUMPS", mime: "text/x-mumps" },
{ title: "MySQL", mime: "text/x-mysql", highlightJs: "sql" },
+ { title: "Nix", mime: "text/x-nix" },
{ title: "Nginx", mime: "text/x-nginx-conf", highlightJs: "nginx" },
{ title: "NSIS", mime: "text/x-nsis", highlightJs: "nsis" },
{ title: "NTriples", mime: "application/n-triples" },
diff --git a/docs/Release Notes/Release Notes/v0.94.0.md b/docs/Release Notes/Release Notes/v0.94.0.md
index a54b7e855f..78b68c32c5 100644
--- a/docs/Release Notes/Release Notes/v0.94.0.md
+++ b/docs/Release Notes/Release Notes/v0.94.0.md
@@ -29,6 +29,7 @@
* Code notes:
* Updated to a new generation of CodeMirror. Since it's a significant update, bug reports are welcome.
* Added the GDScript (Godot) language.
+ * Added the Nix language.
* Mermaid diagrams: basic syntax highlight (not all diagram types are supported) and code folding.
## 📖 Documentation
diff --git a/packages/codemirror/package.json b/packages/codemirror/package.json
index 244b513ed3..fa237956af 100644
--- a/packages/codemirror/package.json
+++ b/packages/codemirror/package.json
@@ -31,6 +31,7 @@
"@codemirror/legacy-modes": "6.5.1",
"@codemirror/search": "6.5.10",
"@codemirror/view": "6.36.7",
+ "@replit/codemirror-lang-nix": "6.0.1",
"@replit/codemirror-vim": "6.3.0",
"@ssddanbrown/codemirror-lang-smarty": "1.0.0",
"@ssddanbrown/codemirror-lang-twig": "1.0.0",
diff --git a/packages/codemirror/src/syntax_highlighting.ts b/packages/codemirror/src/syntax_highlighting.ts
index eb04b4955a..9fffa31b30 100644
--- a/packages/codemirror/src/syntax_highlighting.ts
+++ b/packages/codemirror/src/syntax_highlighting.ts
@@ -127,6 +127,7 @@ const byMimeType: Record<string, (() => Promise<StreamParser<unknown> | Language
"text/x-mssql": async () => (await import('@codemirror/legacy-modes/mode/sql')).msSQL,
"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-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/pnpm-lock.yaml b/pnpm-lock.yaml
index e2d16b2d4f..14493dcadb 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1187,6 +1187,9 @@ importers:
'@codemirror/view':
specifier: 6.36.7
version: 6.36.7
+ '@replit/codemirror-lang-nix':
+ specifier: 6.0.1
+ version: 6.0.1(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@lezer/[email protected])(@lezer/[email protected])(@lezer/[email protected])
'@replit/codemirror-vim':
specifier: 6.3.0
version: 6.3.0(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])
@@ -4298,6 +4301,17 @@ packages:
'@radix-ui/[email protected]':
resolution: {integrity: sha512-A9+lCBZoaMJlVKcRBz2YByCG+Cp2t6nAnMnNba+XiWxnj6r4JUFqfsgwocMBZU9LPtdxC6wB56ySYpc7LQIoJg==}
+ '@replit/[email protected]':
+ resolution: {integrity: sha512-lvzjoYn9nfJzBD5qdm3Ut6G3+Or2wEacYIDJ49h9+19WSChVnxv4ojf+rNmQ78ncuxIt/bfbMvDLMeMP0xze6g==}
+ peerDependencies:
+ '@codemirror/autocomplete': ^6.0.0
+ '@codemirror/language': ^6.0.0
+ '@codemirror/state': ^6.0.0
+ '@codemirror/view': ^6.0.0
+ '@lezer/common': ^1.0.0
+ '@lezer/highlight': ^1.0.0
+ '@lezer/lr': ^1.0.0
+
'@replit/[email protected]':
resolution: {integrity: sha512-aTx931ULAMuJx6xLf7KQDOL7CxD+Sa05FktTDrtLaSy53uj01ll3Zf17JdKsriER248oS55GBzg0CfCTjEneAQ==}
peerDependencies:
@@ -19411,6 +19425,16 @@ snapshots:
'@radix-ui/[email protected]': {}
+ '@replit/[email protected](@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@lezer/[email protected])(@lezer/[email protected])(@lezer/[email protected])':
+ dependencies:
+ '@codemirror/autocomplete': 6.18.6
+ '@codemirror/language': 6.11.0
+ '@codemirror/state': 6.5.2
+ '@codemirror/view': 6.36.7
+ '@lezer/common': 1.2.3
+ '@lezer/highlight': 1.2.1
+ '@lezer/lr': 1.4.2
+
'@replit/[email protected](@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])':
dependencies:
'@codemirror/commands': 6.8.1