Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add experimental CFML support #873

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e16c4c4
Add basic tree-sitter-cfml config
ghedwards Feb 12, 2025
5a43667
Create tree-sitter-cfml.wasm
ghedwards Feb 12, 2025
60b9e27
Build cfml.yml
ghedwards Feb 12, 2025
27b40d6
Revert "Build cfml.yml"
ghedwards Feb 12, 2025
def3a35
Merge pull request #1 from cfmleditor/cfml
ghedwards Feb 12, 2025
237e5e6
Fix package for tree-sitter-cfml
ghedwards Feb 12, 2025
0d12100
Update tree-sitter-cfml
ghedwards Feb 12, 2025
0ca6aff
Fix new line at the bottom of cfml.scm ( otherwise test was failing )
ghedwards Feb 12, 2025
5f315b4
Rollback version update
ghedwards Feb 12, 2025
ff724c9
Rollback Cargo version updates
ghedwards Feb 12, 2025
7a33e8f
Rollback flake.lock
ghedwards Feb 12, 2025
654a2fe
Wasm build was missing cfml path
ghedwards Feb 12, 2025
c4ffe3a
try get ci.yml working on github
ghedwards Feb 13, 2025
58961d4
Fix formatting issue ( line at end of file causing ci.yml to fail
ghedwards Feb 14, 2025
18501ff
Basic input / output test
ghedwards Feb 14, 2025
9925bbd
Fix cfml.scm format
ghedwards Feb 16, 2025
745ca05
CFML formatting improvements ( still early days )
ghedwards Feb 16, 2025
4421dd9
Try restore playground / wasm to flake.nix
ghedwards Feb 16, 2025
1f5b823
Default indents for CFML to tabs
ghedwards Feb 17, 2025
596411c
Update README.md
ghedwards Feb 20, 2025
f8b94e4
Revert topiary.png to 37883aa57ccd481b74f9b66ce65557e83b2422c7
ghedwards Feb 20, 2025
55cef1c
Revert topiary_logo.png to 37883aa57ccd481b74f9b66ce65557e83b2422c7
ghedwards Feb 20, 2025
b6f7977
Revert favicon-32x32.png to ec0e71584b4f8f9b6d408d1f75df6ed0ff46f89b
ghedwards Feb 20, 2025
68b893d
Revert .wasm files
ghedwards Feb 20, 2025
a828d06
Remove cfml references where not required
ghedwards Feb 20, 2025
079b059
Merge branch 'tweag:main' into main
ghedwards Feb 20, 2025
0609ec5
Merge branch 'tweag:main' into main
ghedwards Feb 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ by their individual name). Once included, they can be accessed in
Topiary in the usual way.

* [Rust]
* [Cfml]

## Getting Started

Expand Down
13 changes: 13 additions & 0 deletions bin/update-wasm-grammars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ nickel() {
echo -e "${GREEN}Nickel: Done${NC}"
}

cfml() {
echo -e "${BLUE}CFML: Fetching${NC}"
REPO=$(repo_for_language "cfml")
git clone "${REPO}" "${WORKDIR}/tree-sitter-cfml" &> /dev/null
REV=$(ref_for_language "cfml")
pushd "${WORKDIR}/tree-sitter-cfml" &> /dev/null
git checkout "$REV" &> /dev/null
popd &> /dev/null
echo -e "${ORANGE}CFML: Building${NC}"
tree-sitter build --wasm "${WORKDIR}/tree-sitter-cfml/cfml"
echo -e "${GREEN}CFML: Done${NC}"
}

ocaml() {
echo -e "${BLUE}OCaml: Fetching${NC}"
REPO=$(repo_for_language "ocaml")
Expand Down
3 changes: 3 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
}:
Expand Down Expand Up @@ -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" \
Expand Down
10 changes: 10 additions & 0 deletions examples/client-app/Cargo.lock

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

21 changes: 21 additions & 0 deletions flake.lock

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

8 changes: 7 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
};

Expand All @@ -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;
};
};
Expand Down
5 changes: 4 additions & 1 deletion topiary-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ topiary-tree-sitter-facade.workspace = true
# tree-sitter-toml = { workspace = true, optional = true }
# tree-sitter-bash = { workspace = true, optional = true }
# tree-sitter-nickel = { workspace = true, optional = true }
# tree-sitter-cfml = { workspace = true, optional = true }
# tree-sitter-query = { workspace = true, optional = true }
# tree-sitter-ocaml = { workspace = true, optional = true }
# tree-sitter-ocamllex = { workspace = true, optional = true }
Expand Down Expand Up @@ -78,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"]
Expand Down
3 changes: 3 additions & 0 deletions topiary-cli/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),

Expand Down
3 changes: 3 additions & 0 deletions topiary-cli/tests/sample-tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -79,6 +80,7 @@ mod test_fmt {
lang_test!(
"bash",
"css",
"cfml",
"json",
"nickel",
"ocaml",
Expand Down Expand Up @@ -155,6 +157,7 @@ mod test_coverage {
lang_test!(
"bash",
"css",
"cfml",
"json",
"nickel",
"ocaml",
Expand Down
8 changes: 8 additions & 0 deletions topiary-cli/tests/samples/expected/cfml.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<cfcomponent>
<cffunction>
<cfargument/>
<cfset var test = "test" />
<cfset test2 = "" />
<cfset test3 = "" />
</cffunction>
</cfcomponent>
1 change: 1 addition & 0 deletions topiary-cli/tests/samples/input/cfml.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<cfcomponent><cffunction><cfargument><cfset var test = "test"/><cfset test2 = ""><cfset test3 = ""></cffunction></cfcomponent>
2 changes: 2 additions & 0 deletions topiary-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ bash = []
css = []
json = []
nickel = []
cfml = []
ocaml = []
ocaml_interface = []
ocamllex = []
Expand All @@ -59,6 +60,7 @@ all = [
"css",
"json",
"nickel",
"cfml",
"ocaml",
"ocaml_interface",
"ocamllex",
Expand Down
10 changes: 10 additions & 0 deletions topiary-config/languages.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
6 changes: 6 additions & 0 deletions topiary-config/languages_nix.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -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@",
Expand Down
1 change: 1 addition & 0 deletions topiary-queries/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ description = """
[features]
bash = []
css = []
cfml = []
json = []
nickel = []
ocaml = []
Expand Down
22 changes: 22 additions & 0 deletions topiary-queries/queries/cfml.scm
Original file line number Diff line number Diff line change
@@ -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 "/")
)
6 changes: 6 additions & 0 deletions topiary-queries/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Binary file modified web-playground/public/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified web-playground/public/scripts/tree-sitter-bash.wasm
Binary file not shown.
Binary file not shown.
Binary file modified web-playground/public/scripts/tree-sitter-javascript.wasm
Binary file not shown.
Binary file modified web-playground/public/scripts/tree-sitter-nickel.wasm
Binary file not shown.
Binary file modified web-playground/public/scripts/tree-sitter-ocaml.wasm
Binary file not shown.
Binary file modified web-playground/public/scripts/tree-sitter-ocaml_interface.wasm
Binary file not shown.
Binary file modified web-playground/public/scripts/tree-sitter-ocamllex.wasm
Binary file not shown.
Binary file modified web-playground/public/scripts/tree-sitter-rust.wasm
Binary file not shown.
Binary file modified web-playground/public/scripts/tree-sitter-toml.wasm
Binary file not shown.
Binary file modified web-playground/public/scripts/tree-sitter.wasm
Binary file not shown.
2 changes: 2 additions & 0 deletions web-playground/src/components/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ function toMode(language: string) {
case "nickel":
// Missing highlighting for Nickel, but we know.
return "plain_text";
case "cfml":
return "cfml";
case "rust":
return "rust";
case "toml":
Expand Down
Binary file modified website/images/topiary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified website/images/topiary_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading