diff --git a/CHANGELOG.md b/CHANGELOG.md
index 740e4fdcf..565e75dd3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
### Parsing
+Updated Zig parser.
+
File detection is now stricter with Windows-1252 (Latin 1) encoded
text. Windows-1252 was added in 0.63 and some binary files
(e.g. Brotli compressed files) were incorrectly treated as this
diff --git a/Cargo.lock b/Cargo.lock
index 0c7c8a2a9..aed1d103e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -305,6 +305,7 @@ dependencies = [
"tree-sitter-verilog",
"tree-sitter-xml",
"tree-sitter-yaml",
+ "tree-sitter-zig",
"tree_magic_mini",
"typed-arena",
"unicode-width",
@@ -1323,6 +1324,16 @@ dependencies = [
"tree-sitter-language",
]
+[[package]]
+name = "tree-sitter-zig"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ab11fc124851b0db4dd5e55983bbd9631192e93238389dcd44521715e5d53e28"
+dependencies = [
+ "cc",
+ "tree-sitter-language",
+]
+
[[package]]
name = "tree_magic_mini"
version = "3.1.6"
diff --git a/Cargo.toml b/Cargo.toml
index de967c4c8..af25d6c9b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -105,6 +105,7 @@ tree-sitter-typescript = "0.23.2"
tree-sitter-verilog = "1.0.3"
tree-sitter-xml = "0.7.0"
tree-sitter-yaml = "0.7.0"
+tree-sitter-zig = "1.1.2"
[target.'cfg(not(target_env = "msvc"))'.dependencies]
tikv-jemallocator = "0.6"
diff --git a/build.rs b/build.rs
index f6fb75820..af5ca03ec 100644
--- a/build.rs
+++ b/build.rs
@@ -207,11 +207,6 @@ fn main() {
src_dir: "vendored_parsers/tree-sitter-vhdl-src",
extra_files: vec![],
},
- TreeSitterParser {
- name: "tree-sitter-zig",
- src_dir: "vendored_parsers/tree-sitter-zig-src",
- extra_files: vec![],
- },
];
// Only rerun if relevant files in the vendored_parsers/ directory change.
diff --git a/manual/src/languages_supported.md b/manual/src/languages_supported.md
index 559e5f8cb..46cd2253e 100644
--- a/manual/src/languages_supported.md
+++ b/manual/src/languages_supported.md
@@ -40,7 +40,7 @@ with `difft --list-languages`.
| Nix | [nix-community/tree-sitter-nix](https://github.com/nix-community/tree-sitter-nix) |
| Objective-C | [amaanq/tree-sitter-objc](https://github.com/amaanq/tree-sitter-objc) |
| OCaml | [tree-sitter/tree-sitter-ocaml](https://github.com/tree-sitter/tree-sitter-ocaml) |
-| Pascal | [Isopod/tree-sitter-pascal](https://github.com/Isopod/tree-sitter-pascal) |
+| Pascal | [Isopod/tree-sitter-pascal](https://github.com/Isopod/tree-sitter-pascal) |
| Perl | [ganezdragon/tree-sitter-perl](https://github.com/ganezdragon/tree-sitter-perl) |
| PHP | [tree-sitter/tree-sitter-php](https://github.com/tree-sitter/tree-sitter-php) |
| Python | [tree-sitter/tree-sitter-python](https://github.com/tree-sitter/tree-sitter-python) |
@@ -58,6 +58,7 @@ with `difft --list-languages`.
| TypeScript, TSX | [tree-sitter/tree-sitter-typescript](https://github.com/tree-sitter/tree-sitter-typescript) |
| Verilog | [tree-sitter/tree-sitter-verilog](https://github.com/tree-sitter/tree-sitter-verilog) |
| VHDL | [JLeemaster/tree-sitter-vhdl](https://github.com/JLeemaster/tree-sitter-vhdl) |
+| VHDL | [tree-sitter-grammars/tree-sitter-zig](https://github.com/tree-sitter-grammars/tree-sitter-zig) |
| Zig | [maxxnino/tree-sitter-zig](https://github.com/maxxnino/tree-sitter-zig) |
## Structured Text Formats
diff --git a/src/parse/tree_sitter_parser.rs b/src/parse/tree_sitter_parser.rs
index 9ec2c3647..6ed94f282 100644
--- a/src/parse/tree_sitter_parser.rs
+++ b/src/parse/tree_sitter_parser.rs
@@ -97,7 +97,6 @@ extern "C" {
fn tree_sitter_solidity() -> ts::Language;
fn tree_sitter_sql() -> ts::Language;
fn tree_sitter_vhdl() -> ts::Language;
- fn tree_sitter_zig() -> ts::Language;
}
// TODO: begin/end and object/end.
@@ -1134,7 +1133,9 @@ pub(crate) fn from_language(language: guess::Language) -> TreeSitterConfig {
}
}
Zig => {
- let language = unsafe { tree_sitter_zig() };
+ let language_fn = tree_sitter_zig::LANGUAGE;
+ let language = tree_sitter::Language::new(language_fn);
+
TreeSitterConfig {
language: language.clone(),
atom_nodes: ["STRINGLITERALSINGLE", "BUILTINIDENTIFIER"]
@@ -1143,11 +1144,8 @@ pub(crate) fn from_language(language: guess::Language) -> TreeSitterConfig {
delimiter_tokens: vec![("{", "}"), ("[", "]"), ("(", ")")]
.into_iter()
.collect(),
- highlight_query: ts::Query::new(
- &language,
- include_str!("../../vendored_parsers/highlights/zig.scm"),
- )
- .unwrap(),
+ highlight_query: ts::Query::new(&language, tree_sitter_zig::HIGHLIGHTS_QUERY)
+ .unwrap(),
sub_languages: vec![],
}
}
diff --git a/translation/zh-CN/manual-zh-CN/src/languages_supported.md b/translation/zh-CN/manual-zh-CN/src/languages_supported.md
index 4edef2dcd..b8d71a8f3 100644
--- a/translation/zh-CN/manual-zh-CN/src/languages_supported.md
+++ b/translation/zh-CN/manual-zh-CN/src/languages_supported.md
@@ -4,7 +4,7 @@
## 编程语言
-| 语言 | 使用的解析器 |
+| 语言 | 使用的解析器 |
|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Bash | [tree-sitter/tree-sitter-bash](https://github.com/tree-sitter/tree-sitter-bash) |
| Apex | [aheber/tree-sitter-sfapex](https://github.com/aheber/tree-sitter-sfapex) |
diff --git a/vendored_parsers/highlights/zig.scm b/vendored_parsers/highlights/zig.scm
deleted file mode 120000
index 8d63196fa..000000000
--- a/vendored_parsers/highlights/zig.scm
+++ /dev/null
@@ -1 +0,0 @@
-../tree-sitter-zig/queries/highlights.scm
\ No newline at end of file
diff --git a/vendored_parsers/tree-sitter-zig-src b/vendored_parsers/tree-sitter-zig-src
deleted file mode 120000
index 08e356603..000000000
--- a/vendored_parsers/tree-sitter-zig-src
+++ /dev/null
@@ -1 +0,0 @@
-tree-sitter-zig/src
\ No newline at end of file
diff --git a/vendored_parsers/tree-sitter-zig/Cargo.toml b/vendored_parsers/tree-sitter-zig/Cargo.toml
deleted file mode 100644
index 93ceca4c6..000000000
--- a/vendored_parsers/tree-sitter-zig/Cargo.toml
+++ /dev/null
@@ -1,26 +0,0 @@
-[package]
-name = "tree-sitter-zig"
-description = "zig grammar for the tree-sitter parsing library"
-version = "0.0.1"
-keywords = ["incremental", "parsing", "zig"]
-categories = ["parsing", "text-editors"]
-repository = "https://github.com/tree-sitter/tree-sitter-zig"
-edition = "2018"
-license = "MIT"
-
-build = "bindings/rust/build.rs"
-include = [
- "bindings/rust/*",
- "grammar.js",
- "queries/*",
- "src/*",
-]
-
-[lib]
-path = "bindings/rust/lib.rs"
-
-[dependencies]
-tree-sitter = "~0.20"
-
-[build-dependencies]
-cc = "1.0"
diff --git a/vendored_parsers/tree-sitter-zig/LICENSE b/vendored_parsers/tree-sitter-zig/LICENSE
deleted file mode 100644
index 955bef653..000000000
--- a/vendored_parsers/tree-sitter-zig/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2022 maxxnino
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/vendored_parsers/tree-sitter-zig/README.md b/vendored_parsers/tree-sitter-zig/README.md
deleted file mode 100644
index 6d1e6402a..000000000
--- a/vendored_parsers/tree-sitter-zig/README.md
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
Tree Sitter For Zig
-
-
-
-
->Check [Gallery](https://github.com/maxxnino/tree-sitter-zig/wiki/Gallery) for more images
->
-
diff --git a/vendored_parsers/tree-sitter-zig/assets/fold.png b/vendored_parsers/tree-sitter-zig/assets/fold.png
deleted file mode 100644
index a8ae2a91a..000000000
Binary files a/vendored_parsers/tree-sitter-zig/assets/fold.png and /dev/null differ
diff --git a/vendored_parsers/tree-sitter-zig/assets/highlight.png b/vendored_parsers/tree-sitter-zig/assets/highlight.png
deleted file mode 100644
index 9496ec1c7..000000000
Binary files a/vendored_parsers/tree-sitter-zig/assets/highlight.png and /dev/null differ
diff --git a/vendored_parsers/tree-sitter-zig/binding.gyp b/vendored_parsers/tree-sitter-zig/binding.gyp
deleted file mode 100644
index 5e0b271f7..000000000
--- a/vendored_parsers/tree-sitter-zig/binding.gyp
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "targets": [
- {
- "target_name": "tree_sitter_zig_binding",
- "include_dirs": [
- "
-#include "nan.h"
-
-using namespace v8;
-
-extern "C" TSLanguage * tree_sitter_zig();
-
-namespace {
-
-NAN_METHOD(New) {}
-
-void Init(Local