Skip to content

Commit 025aeb6

Browse files
unhappychoiceclaude
andcommitted
feat: add Nix syntax highlighting support
Closes #132 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e76953e commit 025aeb6

5 files changed

Lines changed: 27 additions & 1 deletion

File tree

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ tree-sitter-json = "0.24"
5959
tree-sitter-kotlin-ng = "1.0"
6060
tree-sitter-lua = "0.5"
6161
tree-sitter-md = "0.5"
62+
tree-sitter-nix = "0.3"
6263
tree-sitter-php = "0.24"
6364
tree-sitter-python = "0.25"
6465
tree-sitter-ruby = "0.23"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ See the [Configuration Guide](docs/configuration.md) for full options and exampl
180180

181181
## Supported Languages
182182

183-
Astro, Bash, C, C#, C++, Clojure, CSS, Dart, Elixir, Erlang, Go, Haskell, HTML, Java, JavaScript, JSON, Kotlin, Lua, Markdown, PHP, Python, Ruby, Rust, Scala, Svelte, Swift, TypeScript, XML, YAML, Zig
183+
Astro, Bash, C, C#, C++, Clojure, CSS, Dart, Elixir, Erlang, Go, Haskell, HTML, Java, JavaScript, JSON, Kotlin, Lua, Markdown, Nix, PHP, Python, Ruby, Rust, Scala, Svelte, Swift, TypeScript, XML, YAML, Zig
184184

185185
## Documentation
186186

src/syntax/languages/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub mod json;
1717
pub mod kotlin;
1818
pub mod lua;
1919
pub mod markdown;
20+
pub mod nix;
2021
pub mod php;
2122
pub mod python;
2223
pub mod ruby;
@@ -146,6 +147,11 @@ fn by_name(raw: &str) -> Option<LanguageSupport> {
146147
highlight_query: markdown::HIGHLIGHT_QUERY,
147148
injection_query: Some(markdown::INJECTION_QUERY),
148149
}),
150+
"nix" => Some(LanguageSupport {
151+
language: nix::language(),
152+
highlight_query: nix::HIGHLIGHT_QUERY,
153+
injection_query: Some(nix::INJECTION_QUERY),
154+
}),
149155
"php" => Some(LanguageSupport {
150156
language: php::language(),
151157
highlight_query: php::HIGHLIGHT_QUERY,
@@ -227,6 +233,7 @@ fn canonicalize(raw: &str) -> Option<&'static str> {
227233
"kt" | "kts" | "kotlin" => Some("kotlin"),
228234
"lua" => Some("lua"),
229235
"md" | "markdown" => Some("markdown"),
236+
"nix" => Some("nix"),
230237
"php" | "php3" | "php4" | "php5" | "phtml" => Some("php"),
231238
"py" | "pyw" | "python" => Some("python"),
232239
"rb" | "rbw" | "rake" | "gemspec" | "ruby" => Some("ruby"),

src/syntax/languages/nix.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pub fn language() -> tree_sitter::Language {
2+
tree_sitter_nix::LANGUAGE.into()
3+
}
4+
5+
pub const HIGHLIGHT_QUERY: &str = tree_sitter_nix::HIGHLIGHTS_QUERY;
6+
7+
pub const INJECTION_QUERY: &str = tree_sitter_nix::INJECTIONS_QUERY;

0 commit comments

Comments
 (0)