From 6b8b5f9cb36cfabe787b422695d97536648b1890 Mon Sep 17 00:00:00 2001 From: Jon Shea Date: Tue, 4 Mar 2025 12:02:57 -0500 Subject: [PATCH 1/3] Update CONTRIBUTING.md Some commands previous described in `CONTRIBUTING.md` have been removed, and some of the tree-sitter documentation links are broken. This PR updates `CONTRIBUTING.md` to fix these issues. --- CONTRIBUTING.md | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 76fce85d..99e65c61 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,11 +7,12 @@ tree-sitter. ## Requirements +- [tree-sitter CLI](https://github.com/tree-sitter/tree-sitter/tree/master/cli) - Node.js version 18.0 or greater - C Compiler Refer to the [tree-sitter -documentation](https://tree-sitter.github.io/tree-sitter/creating-parsers#dependencies) +documentation](https://tree-sitter.github.io/tree-sitter/creating-parsers/1-getting-started.html) for more details and specifics. If you use nix you can enter a nix-shell (`nix-shell .`) which will install them @@ -26,15 +27,15 @@ project's dependencies: npm install ``` -The general flow will often start with adding a test case to `./corpus`. You can +The general flow will often start with adding a test case to `./test/corpus`. You can find details on how testing works with tree-sitter -[here](https://tree-sitter.github.io/tree-sitter/creating-parsers#command-test). +[here](https://tree-sitter.github.io/tree-sitter/creating-parsers/5-writing-tests.html). Once you've added your test case you'll want to then make the required changes to `grammar.js`, regenerate and recompile the parser, and run the tests: ```sh -npm run build +tree-sitter generate npm test ``` @@ -48,15 +49,18 @@ Right now the most common use-case for syntax highlight using tree-sitter is [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter), which means much of our testing is in relation to it. You can find the syntax highlighting tests in `test/highlight/*.scala`. You can read more about this -type of testing -[here](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#unit-testing). These test will be automatically ran with `npm run test`. +type of testing +[here](https://tree-sitter.github.io/tree-sitter/3-syntax-highlighting.html#unit-testing). +These test will be run automatically with `npm run test`. ### tree-sitter highlight Another way to test your syntax highlighting locally is to use the `tree-sitter highlight` command. Note that you'll need to have `tree-sitter` installed globally for this to work. Once you have it installed you'll want to follow the -instructions [here](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#per-user-configuration) to setup a local config that points towards this repo to be used as a parser. Once done you can then do the following: +instructions [here](https://tree-sitter.github.io/tree-sitter/3-syntax-highlighting.html#overview) +to setup a local config that points towards this repo to be used as a parser. +Once done you can then do the following: ```sh tree-sitter highlight some/scala/file.scala @@ -102,8 +106,7 @@ Then you can copy your Scala code in a file and pass that file into `npm run parse`: ``` -npm run parse +tree-sitter parse ``` Then the tree will be printed out for you to copy. - From 3eef52e58168aad06aeb7e3480ba0b35d3cf6367 Mon Sep 17 00:00:00 2001 From: Jon Shea Date: Tue, 4 Mar 2025 17:06:41 -0500 Subject: [PATCH 2/3] Change test command from `npm test` to `tree-sitter test`. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 99e65c61..bb8e3957 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,7 +36,7 @@ to `grammar.js`, regenerate and recompile the parser, and run the tests: ```sh tree-sitter generate -npm test +tree-sitter test ``` Then adjust as necessary. Note that depending on your change you may also have From 32b6e0dee7fe375757e94a8d6b7df29443900892 Mon Sep 17 00:00:00 2001 From: Jon Shea Date: Wed, 5 Mar 2025 09:14:19 -0500 Subject: [PATCH 3/3] Clarify that `tree-sitter test` also runs highlight tests --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bb8e3957..67018607 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,7 +51,7 @@ means much of our testing is in relation to it. You can find the syntax highlighting tests in `test/highlight/*.scala`. You can read more about this type of testing [here](https://tree-sitter.github.io/tree-sitter/3-syntax-highlighting.html#unit-testing). -These test will be run automatically with `npm run test`. +These test will be run automatically with `tree-sitter test`. ### tree-sitter highlight