diff --git a/.github/settings.yml b/.github/settings.yml index 4c6f75f5..fac895ca 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -50,6 +50,9 @@ labels: - name: "language: nickel" color: f8451f description: "Nickel formatting issues" + - name: "language: cfml" + color: f8451f + description: "Cfml formatting issues" - name: "language: Tree-sitter queries" color: f8451f description: "Tree-sitter queries formatting issues" diff --git a/README.md b/README.md index b360ae31..cc6da0d6 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,7 @@ by their individual name). Once included, they can be accessed in Topiary in the usual way. * [Rust] +* [CFML] (ColdFusion Markup Language) by @ghedwards ## Getting Started diff --git a/default.nix b/default.nix index 4a0ac495..fa45d527 100644 --- a/default.nix +++ b/default.nix @@ -9,6 +9,8 @@ # be compatible with Nickel urgently (it is currently blocking for the CI), we # use the tree-sitter-nickel flake directly. , tree-sitter-nickel +# use the tree-sitter-cfml flake directly. +, tree-sitter-cfml # tree-sitter-openscad is not in nixpkgs so use flake directly , tree-sitter-openscad }: @@ -129,6 +131,7 @@ in css="${pkgs.tree-sitter-grammars.tree-sitter-css}/parser" \ json="${pkgs.tree-sitter-grammars.tree-sitter-json}/parser" \ nickel="${tree-sitter-nickel}/parser" \ + cfml="${tree-sitter-cfml}/parser" \ ocaml="${pkgs.tree-sitter-grammars.tree-sitter-ocaml}/parser" \ ocaml_interface="${pkgs.tree-sitter-grammars.tree-sitter-ocaml-interface}/parser" \ openscad="${tree-sitter-openscad}/parser" \ diff --git a/examples/client-app/Cargo.lock b/examples/client-app/Cargo.lock index d18c31f5..436d368f 100644 --- a/examples/client-app/Cargo.lock +++ b/examples/client-app/Cargo.lock @@ -807,6 +807,7 @@ dependencies = [ "tree-sitter-bash", "tree-sitter-json", "tree-sitter-nickel", + "tree-sitter-cfml", "tree-sitter-ocaml", "tree-sitter-ocamllex", "tree-sitter-query", diff --git a/flake.lock b/flake.lock index 6a89b4bc..bb76b584 100644 --- a/flake.lock +++ b/flake.lock @@ -69,6 +69,7 @@ "crane": "crane", "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay", + "tree-sitter-cfml": "tree-sitter-cfml", "tree-sitter-nickel": "tree-sitter-nickel", "tree-sitter-openscad": "tree-sitter-openscad" } @@ -91,6 +92,26 @@ "type": "github" } }, + "tree-sitter-cfml": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1739694114, + "narHash": "sha256-G457KJ418ckkj3N3Sq+8Bncjonuq6MobfgBeb/I/9NY=", + "owner": "cfmleditor", + "repo": "tree-sitter-cfml", + "rev": "979825d2e27ac9e65a217e5132c5c7eef4004b0e", + "type": "github" + }, + "original": { + "owner": "cfmleditor", + "repo": "tree-sitter-cfml", + "type": "github" + } + }, "tree-sitter-nickel": { "inputs": { "nixpkgs": [ diff --git a/flake.nix b/flake.nix index 8c4d0f5e..a427eb81 100644 --- a/flake.nix +++ b/flake.nix @@ -27,6 +27,11 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + tree-sitter-cfml = { + url = "github:cfmleditor/tree-sitter-cfml"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + tree-sitter-openscad = { url = "github:mkatychev/tree-sitter-openscad"; inputs.nixpkgs.follows = "nixpkgs"; @@ -49,7 +54,7 @@ topiaryPkgs = pkgs.callPackage ./default.nix { inherit (inputs) advisory-db crane rust-overlay; - inherit (pkgs.tree-sitter-grammars) tree-sitter-nickel tree-sitter-openscad; + inherit (pkgs.tree-sitter-grammars) tree-sitter-nickel tree-sitter-cfml tree-sitter-openscad; craneLib = inputs.crane.mkLib pkgs; }; @@ -69,6 +74,7 @@ # Nickel *should* have an overlay like this already tree-sitter-grammars = prev.tree-sitter-grammars // { tree-sitter-nickel = inputs.tree-sitter-nickel.packages.${prev.system}.default; + tree-sitter-cfml = inputs.tree-sitter-cfml.packages.${prev.system}.default; tree-sitter-openscad = inputs.tree-sitter-openscad.packages.${prev.system}.default; }; }; diff --git a/topiary-cli/Cargo.toml b/topiary-cli/Cargo.toml index f554f073..2e02f82f 100644 --- a/topiary-cli/Cargo.toml +++ b/topiary-cli/Cargo.toml @@ -79,11 +79,13 @@ contributed = [ # Excluded by default experimental = [ - "rust" + "rust", + "cfml" ] bash = ["topiary-config/bash", "topiary-queries/bash"] css = ["topiary-config/css", "topiary-queries/css"] +cfml = ["topiary-config/cfml", "topiary-queries/cfml"] json = ["topiary-config/json", "topiary-queries/json"] nickel = ["topiary-config/nickel", "topiary-queries/nickel"] ocaml = ["topiary-config/ocaml", "topiary-queries/ocaml"] diff --git a/topiary-cli/src/io.rs b/topiary-cli/src/io.rs index 067fe386..7b28b346 100644 --- a/topiary-cli/src/io.rs +++ b/topiary-cli/src/io.rs @@ -330,6 +330,9 @@ where #[cfg(feature = "css")] "css" => Ok(topiary_queries::css().into()), + #[cfg(feature = "cfml")] + "cfml" => Ok(topiary_queries::cfml().into()), + #[cfg(feature = "json")] "json" => Ok(topiary_queries::json().into()), diff --git a/topiary-cli/tests/sample-tester.rs b/topiary-cli/tests/sample-tester.rs index 4a9f9b0a..250beeed 100644 --- a/topiary-cli/tests/sample-tester.rs +++ b/topiary-cli/tests/sample-tester.rs @@ -9,6 +9,7 @@ fn get_file_extension(language: &str) -> &str { match language { "bash" => "sh", "css" => "css", + "cfml" => "cfm", "json" => "json", "nickel" => "ncl", "ocaml" => "ml", @@ -80,6 +81,7 @@ mod test_fmt { lang_test!( "bash", "css", + "cfml", "json", "nickel", "ocaml", @@ -157,6 +159,7 @@ mod test_coverage { lang_test!( "bash", "css", + "cfml", "json", "nickel", "ocaml", diff --git a/topiary-cli/tests/samples/expected/cfml.cfm b/topiary-cli/tests/samples/expected/cfml.cfm new file mode 100644 index 00000000..a4310801 --- /dev/null +++ b/topiary-cli/tests/samples/expected/cfml.cfm @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/topiary-cli/tests/samples/input/cfml.cfm b/topiary-cli/tests/samples/input/cfml.cfm new file mode 100644 index 00000000..fdbc7a9b --- /dev/null +++ b/topiary-cli/tests/samples/input/cfml.cfm @@ -0,0 +1 @@ + diff --git a/topiary-config/Cargo.toml b/topiary-config/Cargo.toml index 39ae2f18..690b75e4 100644 --- a/topiary-config/Cargo.toml +++ b/topiary-config/Cargo.toml @@ -44,6 +44,7 @@ bash = [] css = [] json = [] nickel = [] +cfml = [] ocaml = [] ocaml_interface = [] ocamllex = [] @@ -60,6 +61,7 @@ all = [ "css", "json", "nickel", + "cfml", "ocaml", "ocaml_interface", "ocamllex", diff --git a/topiary-config/languages.ncl b/topiary-config/languages.ncl index 047518f8..f0a24f49 100644 --- a/topiary-config/languages.ncl +++ b/topiary-config/languages.ncl @@ -47,6 +47,16 @@ }, }, + cfml = { + extensions = ["cfm"], + indent = " ", # 1 tab + grammar.source.git = { + git = "https://github.com/cfmleditor/tree-sitter-cfml.git", + rev = "979825d2e27ac9e65a217e5132c5c7eef4004b0e", + subdir = "cfml", + }, + }, + ocaml = { extensions = ["ml"], grammar.source.git = { diff --git a/topiary-config/languages_nix.ncl b/topiary-config/languages_nix.ncl index a4e85bbc..60180027 100644 --- a/topiary-config/languages_nix.ncl +++ b/topiary-config/languages_nix.ncl @@ -40,6 +40,12 @@ grammar.source.path = "@nickel@", }, + cfml = { + extensions = ["cfm"], + indent = " ", # 1 tab + grammar.source.path = "@cfml@", + }, + ocaml = { extensions = ["ml"], grammar.source.path = "@ocaml@", diff --git a/topiary-queries/Cargo.toml b/topiary-queries/Cargo.toml index bad7a143..f4a003bc 100644 --- a/topiary-queries/Cargo.toml +++ b/topiary-queries/Cargo.toml @@ -17,6 +17,7 @@ description = """ [features] bash = [] css = [] +cfml = [] json = [] nickel = [] ocaml = [] diff --git a/topiary-queries/queries/cfml.scm b/topiary-queries/queries/cfml.scm new file mode 100644 index 00000000..c7175394 --- /dev/null +++ b/topiary-queries/queries/cfml.scm @@ -0,0 +1,22 @@ +(cf_tag_open) @append_hardline +(cf_tag_close) @append_hardline + +( + (cf_tag_open) @append_indent_start + _ + (cf_tag_close) @prepend_indent_end +) + +(cf_set_tag) @append_hardline +(cf_selfclose_tag) @append_hardline + +(cf_var) @prepend_space +(assignment_expression) @prepend_space @append_space + +(assignment_expression "=" @prepend_space @append_space) + +( + (cf_selfclose_tag_end) @prepend_delimiter + (#delimiter! "/") + (#not-match? @prepend_delimiter "/") +) diff --git a/topiary-queries/src/lib.rs b/topiary-queries/src/lib.rs index f0754de1..2baa2cd7 100644 --- a/topiary-queries/src/lib.rs +++ b/topiary-queries/src/lib.rs @@ -10,6 +10,12 @@ pub fn css() -> &'static str { include_str!("../queries/css.scm") } +/// Returns the Topiary-compatible query file for CFML. +#[cfg(feature = "cfml")] +pub fn cfml() -> &'static str { + include_str!("../queries/cfml.scm") +} + /// Returns the Topiary-compatible query file for Json. #[cfg(feature = "json")] pub fn json() -> &'static str { diff --git a/web-playground/public/scripts/tree-sitter-cfml.wasm b/web-playground/public/scripts/tree-sitter-cfml.wasm new file mode 100755 index 00000000..7621fdeb Binary files /dev/null and b/web-playground/public/scripts/tree-sitter-cfml.wasm differ