Skip to content

Commit

Permalink
add ini language
Browse files Browse the repository at this point in the history
  • Loading branch information
Kl4rry committed May 31, 2024
1 parent 8376f96 commit f05351e
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/ferrite-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ lang-glsl = ["ferrite-tree-sitter/lang-glsl"]
lang-go = ["ferrite-tree-sitter/lang-go"]
lang-html = ["ferrite-tree-sitter/lang-html"]
lang-hyprlang = ["ferrite-tree-sitter/lang-hyprlang"]
lang-ini = ["ferrite-tree-sitter/lang-ini"]
lang-javascript = ["ferrite-tree-sitter/lang-javascript"]
lang-json = ["ferrite-tree-sitter/lang-json"]
lang-md = ["ferrite-tree-sitter/lang-md"]
Expand All @@ -89,6 +90,7 @@ default = [
"lang-go",
"lang-html",
"lang-hyprlang",
"lang-ini",
"lang-json",
"lang-md",
"lang-python",
Expand Down
32 changes: 32 additions & 0 deletions crates/ferrite-core/src/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ static LANGUAGES: Lazy<HashMap<&'static str, OnceCell<LanguageConfig>>> = Lazy::
langs.insert("go", OnceCell::new());
#[cfg(feature = "lang-typescript")]
langs.insert("typescript", OnceCell::new());
#[cfg(feature = "lang-ini")]
langs.insert("ini", OnceCell::new());
langs
});

Expand Down Expand Up @@ -284,6 +286,14 @@ fn get_lang_config(name: &str) -> Option<LanguageConfig> {
include_str!("../../../queries/typescript/injections.scm"),
include_str!("../../../queries/typescript/locals.scm"),
),
#[cfg(feature = "lang-ini")]
"ini" => LanguageConfig::new(
"ini",
ferrite_tree_sitter::tree_sitter_ini::language(),
include_str!("../../../queries/ini/highlights.scm"),
"",
"",
),
_ => return None,
})
}
Expand Down Expand Up @@ -372,6 +382,28 @@ pub fn get_language_from_path(path: impl AsRef<Path>) -> Option<&'static str> {
(Name(".zprofile"), "bash"),
(Name(".zshrc"), "bash"),
(Name("PKGBUILD"), "bash"),
// ini
(Suffix(".ini"), "ini"),
(Suffix(".service"), "ini"),
(Suffix(".automount"), "ini"),
(Suffix(".device"), "ini"),
(Suffix(".mount"), "ini"),
(Suffix(".path"), "ini"),
(Suffix(".service"), "ini"),
(Suffix(".slice"), "ini"),
(Suffix(".socket"), "ini"),
(Suffix(".swap"), "ini"),
(Suffix(".target"), "ini"),
(Suffix(".timer"), "ini"),
(Suffix(".container"), "ini"),
(Suffix(".volume"), "ini"),
(Suffix(".kube"), "ini"),
(Suffix(".network"), "ini"),
(Suffix(".properties"), "ini"),
(Suffix(".cfg"), "ini"),
(Suffix(".directory"), "ini"),
(Name(".editorconfig"), "ini"),
(Name("rclone.conf"), "ini"),
]
});

Expand Down
2 changes: 2 additions & 0 deletions crates/ferrite-tree-sitter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ tree-sitter-glsl = { git = "https://github.com/theHamsta/tree-sitter-glsl", rev
tree-sitter-go = { git = "https://github.com/tree-sitter/tree-sitter-go", rev = "64457ea6b73ef5422ed1687178d4545c3e91334a", optional = true }
tree-sitter-html = { version = "0.19.0", optional = true }
tree-sitter-hyprlang = { git = "https://github.com/tree-sitter-grammars/tree-sitter-hyprlang", rev = "27af9b74acf89fa6bed4fb8cb8631994fcb2e6f3", optional = true }
tree-sitter-ini = { git = "https://github.com/justinmk/tree-sitter-ini", rev = "4d247fb876b4ae6b347687de4a179511bf67fcbc", optional = true }
tree-sitter-javascript = { git = "https://github.com/tree-sitter/tree-sitter-javascript", rev = "f772967f7b7bc7c28f845be2420a38472b16a8ee", optional = true }
tree-sitter-json = { version = "0.19.0", optional = true }
tree-sitter-md = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "272e080bca0efd19a06a7f4252d746417224959e", optional = true }
Expand All @@ -44,6 +45,7 @@ lang-glsl = ["dep:tree-sitter-glsl"]
lang-go = ["dep:tree-sitter-go"]
lang-html = ["dep:tree-sitter-html"]
lang-hyprlang = ["dep:tree-sitter-hyprlang"]
lang-ini = ["dep:tree-sitter-ini"]
lang-javascript = ["dep:tree-sitter-javascript"]
lang-json = ["dep:tree-sitter-json"]
lang-md = ["dep:tree-sitter-md"]
Expand Down
2 changes: 2 additions & 0 deletions crates/ferrite-tree-sitter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub use tree_sitter_go;
pub use tree_sitter_html;
#[cfg(feature = "lang-hyprlang")]
pub use tree_sitter_hyprlang;
#[cfg(feature = "lang-ini")]
pub use tree_sitter_ini;
#[cfg(feature = "lang-javascript")]
pub use tree_sitter_javascript;
#[cfg(feature = "lang-json")]
Expand Down
6 changes: 6 additions & 0 deletions queries/ini/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(section_name) @namespace

(setting_name) @keyword
(setting_value) @string

(comment) @comment
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ fn main() -> Result<ExitCode> {
const GB: u64 = 1_000_000_000;
if log_file.metadata()?.len() > GB {
log_file.set_len(0)?;
tracing::warn!("Log file was truncated as it reached 1Gb in size");
}

let var = args
Expand Down

0 comments on commit f05351e

Please sign in to comment.