mirror of https://github.com/lapce/lapce.git
Merge pull request #690 from ghishadow/zig_bash_treesitter
add syntax highlighting support for Bash and Zig
This commit is contained in:
commit
e370aa9aab
|
@ -2204,6 +2204,7 @@ dependencies = [
|
|||
"strum_macros 0.24.0",
|
||||
"thiserror",
|
||||
"tree-sitter",
|
||||
"tree-sitter-bash",
|
||||
"tree-sitter-c",
|
||||
"tree-sitter-cpp",
|
||||
"tree-sitter-css",
|
||||
|
@ -2231,6 +2232,7 @@ dependencies = [
|
|||
"tree-sitter-swift",
|
||||
"tree-sitter-toml",
|
||||
"tree-sitter-typescript",
|
||||
"tree-sitter-zig",
|
||||
"xi-rope",
|
||||
]
|
||||
|
||||
|
@ -4548,6 +4550,15 @@ dependencies = [
|
|||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-bash"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/syntacti/tree-sitter-bash?branch=master#ba3adca745943b71b0c84bb4e4977788cc6a867b"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"tree-sitter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-c"
|
||||
version = "0.20.1"
|
||||
|
@ -4806,6 +4817,15 @@ dependencies = [
|
|||
"tree-sitter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-zig"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/maxxnino/tree-sitter-zig?branch=main#8d3224c3bd0890fe08358886ebf54fca2ed448a6"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"tree-sitter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "try-lock"
|
||||
version = "0.2.3"
|
||||
|
|
|
@ -42,6 +42,9 @@ tree-sitter-scss = { git = "https://github.com/VixieTSQ/tree-sitter-scss", versi
|
|||
tree-sitter-hare = { version = "0.20.7", optional = true }
|
||||
# switch to upstream version after this is merged https://github.com/tree-sitter/tree-sitter-css/pull/22
|
||||
tree-sitter-css = { git = "https://github.com/syntacti/tree-sitter-css", branch = "master", optional = true }
|
||||
tree-sitter-zig = { git = "https://github.com/maxxnino/tree-sitter-zig", branch = "main", optional = true }
|
||||
# switch to upstream version after this is merged https://github.com/tree-sitter/tree-sitter-bash/pull/120
|
||||
tree-sitter-bash = { git = "https://github.com/syntacti/tree-sitter-bash", branch = "master", optional = true }
|
||||
lsp-types = { version = "0.89.2", features = ["proposed"] }
|
||||
xi-rope = { git = "https://github.com/lapce/xi-editor", features = ["serde"] }
|
||||
lapce-rpc = { path = "../lapce-rpc" }
|
||||
|
@ -77,3 +80,5 @@ lang-hcl = ["dep:tree-sitter-hcl"]
|
|||
lang-scss = ["dep:tree-sitter-scss"]
|
||||
lang-hare = ["dep:tree-sitter-hare"]
|
||||
lang-css = ["dep:tree-sitter-css"]
|
||||
lang-zig = ["dep:tree-sitter-zig"]
|
||||
lang-bash = ["dep:tree-sitter-bash"]
|
||||
|
|
|
@ -154,6 +154,10 @@ pub enum LapceLanguage {
|
|||
Hare,
|
||||
#[cfg(feature = "lang-css")]
|
||||
Css,
|
||||
#[cfg(feature = "lang-zig")]
|
||||
Zig,
|
||||
#[cfg(feature = "lang-bash")]
|
||||
Bash,
|
||||
}
|
||||
|
||||
// NOTE: Elements in the array must be in the same order as the enum variants of
|
||||
|
@ -472,6 +476,26 @@ pub enum LapceLanguage {
|
|||
code_lens: (DEFAULT_CODE_LENS_LIST, DEFAULT_CODE_LENS_IGNORE_LIST),
|
||||
extensions: &["css"],
|
||||
},
|
||||
#[cfg(feature = "lang-zig")]
|
||||
SyntaxProperties {
|
||||
id: LapceLanguage::Zig,
|
||||
language: tree_sitter_zig::language,
|
||||
highlight: tree_sitter_zig::HIGHLIGHTS_QUERY,
|
||||
comment: "//",
|
||||
indent: " ",
|
||||
code_lens: (DEFAULT_CODE_LENS_LIST, DEFAULT_CODE_LENS_IGNORE_LIST),
|
||||
extensions: &["zig"],
|
||||
},
|
||||
#[cfg(feature = "lang-bash")]
|
||||
SyntaxProperties {
|
||||
id: LapceLanguage::Bash,
|
||||
language: tree_sitter_bash::language,
|
||||
highlight: tree_sitter_bash::HIGHLIGHTS_QUERY,
|
||||
comment: "#",
|
||||
indent: " ",
|
||||
code_lens: (DEFAULT_CODE_LENS_LIST, DEFAULT_CODE_LENS_IGNORE_LIST),
|
||||
extensions: &["sh", "bash"],
|
||||
},
|
||||
];
|
||||
|
||||
impl LapceLanguage {
|
||||
|
@ -739,4 +763,12 @@ fn test_hare_lang() {
|
|||
fn test_css_lang() {
|
||||
assert_language(LapceLanguage::Css, &["css"]);
|
||||
}
|
||||
#[cfg(feature = "lang-zig")]
|
||||
fn test_zig_lang() {
|
||||
assert_language(LapceLanguage::Zig, &["zig"]);
|
||||
}
|
||||
#[cfg(feature = "lang-bash")]
|
||||
fn test_bash_lang() {
|
||||
assert_language(LapceLanguage::Bash, &["sh", "bash"]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,8 +87,9 @@ all-languages = [
|
|||
"lang-hcl",
|
||||
"lang-scss",
|
||||
"lang-hare",
|
||||
"lang-css"
|
||||
|
||||
"lang-css",
|
||||
"lang-zig",
|
||||
"lang-bash",
|
||||
]
|
||||
|
||||
lang-rust = ["lapce-core/lang-rust"]
|
||||
|
@ -116,4 +117,6 @@ lang-haxe = ["lapce-core/lang-haxe"]
|
|||
lang-hcl = ["lapce-core/lang-hcl"]
|
||||
lang-scss = ["lapce-core/lang-scss"]
|
||||
lang-hare = ["lapce-core/lang-hare"]
|
||||
lang-css = ["lapce-core/lang-css"]
|
||||
lang-css = ["lapce-core/lang-css"]
|
||||
lang-zig = ["lapce-core/lang-zig"]
|
||||
lang-bash = ["lapce-core/lang-bash"]
|
||||
|
|
Loading…
Reference in New Issue