{"id":23642473,"url":"https://github.com/sogaiu/ts-clojure","last_synced_at":"2025-08-31T18:32:59.492Z","repository":{"id":142331935,"uuid":"612452352","full_name":"sogaiu/ts-clojure","owner":"sogaiu","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-22T07:56:41.000Z","size":74,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"default","last_synced_at":"2024-05-22T13:03:35.525Z","etag":null,"topics":["babashka","clojure","development","testing","tree-sitter"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sogaiu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-11T01:42:23.000Z","updated_at":"2024-05-28T03:10:48.477Z","dependencies_parsed_at":"2024-05-28T03:10:33.785Z","dependency_job_id":null,"html_url":"https://github.com/sogaiu/ts-clojure","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sogaiu%2Fts-clojure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sogaiu%2Fts-clojure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sogaiu%2Fts-clojure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sogaiu%2Fts-clojure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sogaiu","download_url":"https://codeload.github.com/sogaiu/ts-clojure/tar.gz/refs/heads/default","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231615472,"owners_count":18400983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babashka","clojure","development","testing","tree-sitter"],"created_at":"2024-12-28T10:51:07.631Z","updated_at":"2025-08-31T18:32:59.472Z","avatar_url":"https://github.com/sogaiu.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ts-clojure\n\nTesting and development bits for\n[tree-sitter-clojure](https://github.com/sogaiu/tree-sitter-clojure),\nincluding:\n\n* Fetching and testing of real-world code sample sets\n* Intentional generation of `src/parser.c` and friends\n* Related instructions\n\nSee [here](doc/background.md) for some background.\n\n## Prerequisites\n\nThe prerequisites are what you typically need to work with\ntree-sitter, with the exception of Babashka which is used for task\nautomation:\n\n* [tree-sitter](https://github.com/tree-sitter/tree-sitter) cli\n* [tree-sitter dependencies](https://tree-sitter.github.io/tree-sitter/creating-parsers#dependencies)\n* [babashka](https://github.com/babashka/babashka) - shell completion\n  setup highly recommended: [Option\n  1](https://book.babashka.org/#_terminal_tab_completion), [Option\n  2](https://github.com/babashka/babashka/discussions/1615)\n\nIf you want to test against ClojureDart samples, the `git` cli program\nis needed for fetching the samples.  Perhaps it is likely it's already\navailable for other reasons :)\n\nSee [here](doc/prerequisites.md) for more details.\n\n## Tweak settings\n\nts-clojure's scripts can be configured a bit via the file\n`conf/conf.clj`.\n\nSome included settings are:\n\n* `abi` - ABI number to use when generating `parser.c` from\n  `grammar.js`\n* `grammar-dir` - path to cloned tree-sitter-clojure directory\n* `repos` - which set of source samples to test against\n* `ts-bin-path` - path to or name of `tree-sitter` cli binary\n\nSee [here](doc/tweak-settings.md) for more details.\n\n## Checking the Setup\n\nNote that once Babashka is available, you can repeatedly use:\n\n```\nbb check-setup\n```\n\nas you follow the setup instructions to get some help regarding\nwhether settings are appropriate.\n\n## One-time (Mostly) Setup\n\n### A Brief Warning\n\nConsider working in a new user account.  This is not required, but you\nmight want to read near the end of the document for potential\nconsequences of not doing so.\n\n### A Fork in the Road...Sort Of\n\nIt used to be possible to use ts-clojure in a variety of ways such as:\n\n1. tree-sitter-clojure is a subdirectory of ts-clojure\n2. ts-clojure is a subdirectory of tree-sitter-clojure\n3. no particular parent-child relationship\n\nbut in recent times a specific configuration has come to be favored.\n\nThe currently favored approach is option 1 - i.e. tree-sitter-clojure\nbeing a subdirectory of ts-clojure.\n\nSupport for options 2 and 3 are no longer actively being maintained\nand may or may not work.\n\n### Verify tree-sitter setup\n\nVerify what version of `tree-sitter` you have installed and confirm\nthat you know where it looks to find parser repositories.\n\nSee [here](doc/verify-tree-sitter-setup.md) for more details.\n\n### Prepare source samples\n\nThe source code samples do not come bundled.  To get meaningful\ntesting over real-world code, it's necessary to arrange for some\nsamples.\n\nTo fetch some source code samples:\n\n* For clojars:\n  * Change working directory to the `clojars-samples` subdirectory\n  * Fetch 11 jars by: `bb fetch-jars 11`\n  * Extract the jars by: `bb extract-jars`\n\n* For clojuredart samples:\n  * Change working directory to the `clojuredart-samples` subdirectory\n  * Fetch some clojuredart code by: `bb fetch-samples`\n\n* For core_regression samples:\n  * Change working directory to the `core-regression-samples` subdirectory\n  * Fetch samples by: `bb fetch-samples`\n\n* For test.regression samples:\n  * Change working directory to the `test-regression-samples` subdirectory\n  * Fetch samples by: `bb fetch-samples`\n\nChange the value of `repos` in `conf/conf.clj` to specify which set of\nsamples to test against.\n\nNote that in the case of clojars, if you are serious about testing,\nplease consider getting more jars.\n\nSee [here](doc/prepare-source-samples.md) for more details.\n\n### Final Steps\n\nConsider using the `bb check-setup` task to get a sense of whether\nyour setup has any obvious issues.\n\n## Things You Can Do\n\n### Generate `parser.c`\n\nTo generate tree-sitter-clojure's `src/parser.c` file:\n\n```\nbb generate-parser\n```\n\nThis will invoke `tree-sitter`'s `generate` subcommand:\n\n* using the ABI number specified in `conf/conf.clj` via `abi` and\n* using the `--no-bindings` argument to avoid generating binding code\n\n### Build and Install Shared Library\n\nTo build and install a shared library based on the generated\n`parser.c`:\n\n```\nbb corpus-test\n```\n\nThis will run tree-sitter-clojure's corpus tests via `tree-sitter\ntest`, which has a side-effect that achieves the desired aim.\n\nSee [here](doc/build-and-install-shared-library.md) for more\ndetails.\n\n### Run Real-World Code Tests\n\nTo test the parser on real-world code:\n\n```\nbb parse-samples\n```\n\nThis will invoke `tree-sitter`'s `parse` command across a set of\nsource code samples.\n\nWhich set of samples is tested against can be specified by:\n\n* adjusting the `repos` value in `conf/conf.clj`, or\n* passing an extra argument to the task, e.g. `bb parse-samples clojars`\n\nAssuming the samples have been obtained, the value can be one of:\n\n* `clojars`\n* `clojuredart`\n* `core-regression`\n* `test-regression`\n\nSee [here](doc/run-real-world-code-tests.md) for more\ndetails.\n\n## Misc Notes\n\n### About Being Future-Proof\n\nAt this time, `tree-sitter` cli subcommand backward compatibility does\nnot appear to be a high priority, so it may be good to expect to have\nto adjust some `tree-sitter` invocations in the various Babashka\n(`.clj`) scripts.\n\n### Windows Support\n\nHave not tested yet but might work via mingw-w64 / msys2 or similar.\nNo idea about WSL, not a fan and haven't tested.\n\n### Isolation\n\nI had trouble at various points with `tree-sitter` behavior being\ninfluenced by things that I was unaware of.  I believe this was the\nresult of a combination of:\n\n* testing with different versions of `tree-sitter` (various\n  configuration and operation file paths changed between versions),\n* having multiple versions of grammars under my home directory,\n* not understanding the workings of [tree-sitter's automatic\ncompilation](https://github.com/tree-sitter/tree-sitter/issues/2017)\n\nOne way to avoid some of this kind of thing is to use some kind of\nisolation / simplification mechanism such as a fresh user account.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsogaiu%2Fts-clojure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsogaiu%2Fts-clojure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsogaiu%2Fts-clojure/lists"}