{"id":15144198,"url":"https://github.com/valdezfomar/tree-sitter-format-string","last_synced_at":"2025-07-28T14:09:04.260Z","repository":{"id":254405675,"uuid":"846438499","full_name":"ValdezFOmar/tree-sitter-format-string","owner":"ValdezFOmar","description":"Curly brace style string formatting grammar for tree-sitter","archived":false,"fork":false,"pushed_at":"2025-07-13T14:55:21.000Z","size":188,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-13T16:31:21.545Z","etag":null,"topics":["parser","python","rust","tree-sitter","tree-sitter-grammar","tree-sitter-highlight","tree-sitter-parser"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ValdezFOmar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2024-08-23T07:57:01.000Z","updated_at":"2025-06-15T20:21:41.000Z","dependencies_parsed_at":"2024-12-15T15:22:57.274Z","dependency_job_id":"1dc5901f-cd7c-4233-aede-3d126c9fc80b","html_url":"https://github.com/ValdezFOmar/tree-sitter-format-string","commit_stats":{"total_commits":8,"total_committers":3,"mean_commits":"2.6666666666666665","dds":0.375,"last_synced_commit":"4bbcc119e9cf02ac80d4dd2eb227b82512d37f85"},"previous_names":["valdezfomar/tree-sitter-format-string"],"tags_count":2,"template":false,"template_full_name":"tree-sitter-grammars/template","purl":"pkg:github/ValdezFOmar/tree-sitter-format-string","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValdezFOmar%2Ftree-sitter-format-string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValdezFOmar%2Ftree-sitter-format-string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValdezFOmar%2Ftree-sitter-format-string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValdezFOmar%2Ftree-sitter-format-string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ValdezFOmar","download_url":"https://codeload.github.com/ValdezFOmar/tree-sitter-format-string/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValdezFOmar%2Ftree-sitter-format-string/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267527835,"owners_count":24102019,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["parser","python","rust","tree-sitter","tree-sitter-grammar","tree-sitter-highlight","tree-sitter-parser"],"created_at":"2024-09-26T10:22:39.505Z","updated_at":"2025-07-28T14:09:04.221Z","avatar_url":"https://github.com/ValdezFOmar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tree-sitter-format-string\n\n[![CI][ci]](https://github.com/ValdezFOmar/tree-sitter-format-string/actions/workflows/ci.yml)\n[![discord][discord]](https://discord.gg/w7nTvsVJhm)\n[![matrix][matrix]](https://matrix.to/#/#tree-sitter-chat:matrix.org)\n\u003c!-- NOTE: uncomment these if you're publishing packages: --\u003e\n\u003c!-- [![npm][npm]](https://www.npmjs.com/package/tree-sitter-format-string) --\u003e\n\u003c!-- [![crates][crates]](https://crates.io/crates/tree-sitter-format-string) --\u003e\n\u003c!-- [![pypi][pypi]](https://pypi.org/project/tree-sitter-format-string/) --\u003e\n\nA tree-sitter parser for format strings using curly braces (`{}`),\nlike python's `str.format` method or rust's `format!` macro.\n\n## Injections\n\n### Python\n\n\u003cdetails\u003e\n  \u003csummary\u003eQueries\u003c/summary\u003e\n\nPython only uses formatted strings in the `str.format` method, commonly\nused like this:\n\n```python\n'Hello {}'.format('world')\n'{:.4f}'.format(math.pi)\n```\n\nQuery for `tree-sitter-python`'s `injections.scm`:\n\n```query\n((call\n  function: (attribute\n    object: (string\n      (string_content) @injection.content)\n    attribute: (identifier) @_format))\n  (#eq? @_format \"format\")\n  (#set! injection.language \"format_string\"))\n```\n\n\u003c/details\u003e\n\n### Rust\n\n\u003cdetails\u003e\n  \u003csummary\u003eQueries\u003c/summary\u003e\n\nRust uses formatted strings in the following macros:\n\n- `format!`\n- `write!`\n- `writeln!`\n- `print!`\n- `println!`\n- `eprint!`\n- `eprintln!`\n- `format_args!`\n- `assert!`\n- `assert_eq!`\n- `assert_ne!`\n- `assert_matches!`\n- `debug_assert!`\n- `debug_assert_eq!`\n- `debug_assert_ne!`\n- `debug_assert_matches!`\n\nQueries for `tree-sitter-rust`'s `injections.scm`:\n\n```query\n((macro_invocation\n  macro: (identifier) @_macro\n  (token_tree\n    .\n    (string_literal\n      (string_content) @injection.content)))\n  (#any-of? @_macro\n    \"print\"\n    \"println\"\n    \"eprint\"\n    \"eprintln\"\n    \"format\"\n    \"format_args\")\n  (#set! injection.language \"format_string\"))\n\n((macro_invocation\n  macro: (identifier) @_macro\n  (token_tree\n    .\n    (_)\n    .\n    (string_literal\n      (string_content) @injection.content)))\n  (#any-of? @_macro \"write\" \"writeln\" \"assert\" \"debug_assert\")\n  (#set! injection.language \"format_string\"))\n\n((macro_invocation\n  macro: (identifier) @_macro\n  (token_tree\n    .\n    (_)\n    .\n    (_)\n    .\n    (string_literal\n      (string_content) @injection.content)))\n  (#any-of? @_macro\n    \"assert_eq\"\n    \"assert_ne\"\n    \"assert_matches\"\n    \"debug_assert_eq\"\n    \"debug_assert_ne\"\n    \"debug_assert_matches\")\n  (#set! injection.language \"format_string\"))\n```\n\n\u003c/details\u003e\n\n## References\n\n- [Rust format syntax](https://doc.rust-lang.org/std/fmt/#syntax)\n- [Python format syntax](https://docs.python.org/3/library/string.html#format-string-syntax)\n- Other languages?\n\n[ci]: https://img.shields.io/github/actions/workflow/status/ValdezFOmar/tree-sitter-format-string/ci.yml?logo=github\u0026label=CI\n[discord]: https://img.shields.io/discord/1063097320771698699?logo=discord\u0026label=discord\n[matrix]: https://img.shields.io/matrix/tree-sitter-chat%3Amatrix.org?logo=matrix\u0026label=matrix\n[npm]: https://img.shields.io/npm/v/tree-sitter-format-string?logo=npm\n[crates]: https://img.shields.io/crates/v/tree-sitter-format-string?logo=rust\n[pypi]: https://img.shields.io/pypi/v/tree-sitter-format-string?logo=pypi\u0026logoColor=ffd242\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaldezfomar%2Ftree-sitter-format-string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaldezfomar%2Ftree-sitter-format-string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaldezfomar%2Ftree-sitter-format-string/lists"}