{"id":18995511,"url":"https://github.com/onivim/reason-textmate","last_synced_at":"2025-04-22T13:10:46.127Z","repository":{"id":100513737,"uuid":"206385790","full_name":"onivim/reason-textmate","owner":"onivim","description":"ReasonML native library for working with TextMate grammars","archived":false,"fork":false,"pushed_at":"2020-04-22T00:42:30.000Z","size":614,"stargazers_count":16,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-17T03:05:25.169Z","etag":null,"topics":["highlighting","ocaml","reasonml","syntax","textmate"],"latest_commit_sha":null,"homepage":null,"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/onivim.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}},"created_at":"2019-09-04T18:25:25.000Z","updated_at":"2023-09-07T11:14:27.000Z","dependencies_parsed_at":"2023-05-15T15:15:20.855Z","dependency_job_id":null,"html_url":"https://github.com/onivim/reason-textmate","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/onivim%2Freason-textmate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onivim%2Freason-textmate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onivim%2Freason-textmate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onivim%2Freason-textmate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onivim","download_url":"https://codeload.github.com/onivim/reason-textmate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250246727,"owners_count":21398919,"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":["highlighting","ocaml","reasonml","syntax","textmate"],"created_at":"2024-11-08T17:31:00.170Z","updated_at":"2025-04-22T13:10:46.112Z","avatar_url":"https://github.com/onivim.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# reason-textmate\nReasonML native library for working with TextMate grammars\n\n## Building\n\n- `esy install`\n- `esy build`\n\n### Tests\n\n- `esy '@test' install`\n- `esy '@test' run`\n\n### Benchmarks\n\n- `esy '@bench' install`\n- `esy '@bench' run`\n\n### Documentation\n\nLatest docs are available here: https://onivim.github.io/reason-textmate/textmate/index.html\n\n- `esy '@docs' install`\n- `esy '@docs' build`\n- `esy '@docs' update`\n\n## Performance\n\n| Benchmark | `reason-textmate` | `vscode-textmate` | % diff |\n| --- | --- | --- | --- |\n| jQuery 2.0.3 | 543ms | 618ms | `reason-textmate` is ~12% faster |\n| bootstrap.css | 71 ms | 245 ms | `reason-textmate` is ~71% faster |\n\nBenchmarks were averaged across 3 trials on my Windows 10 dev machine. It's surprising that the CSS is so much faster; it is possible there is a bug, although I compared the highlight output for `bootstrap.css` between VSCode and Onivim 2 using this library, and did not see differences.\n\nThe main bottleneck for performance is running the Oniguruma regular expressions (`onig_search`) - anything that can be done to reduce the number of times we need to run a search can greatly improve performance. There are some other optimizations that could be made, for example, we're not using the [flambda optimizing compiler](https://caml.inria.fr/pub/docs/manual-ocaml/flambda.html) today - and we're doing some wasteful list manipulation and string manipulation for scopes. But this is pretty low overhead compared to the main bottleneck of evaluating the regular expression.\n\n## Roadmap\n\nMost of the textmate grammar syntax is supported, but there are a few missing features we need for full parity:\n\n- While conditions\n- Nested patterns in capture groups\n\n\u003e NOTE: These features are not used by the grammars in the benchmarks\n\n## Usage\n\n```reason\nopen Textmate;\n\n// Create a grammar repository\nlet grammarRepository = GrammarRepository.ofFilePath(\"source.js\", \"/path/to/js-grammar.json\");\n\n// Create a tokenizer\nlet tokenizer = Tokenizer.create(grammarRepository);\n\n// Tokenize a line. Tokenizing returns a scope stack and a set of tokens.\nlet (scopeStack, tokens) = Tokenizer.tokenize(~lineNumber=0, ~scopeStack=None, ~scope=\"source.js\", tokenizer, \"console.log('Hello, world!')\");\n\n// Print tokens:\nList.iter((token) =\u003e print_endline(\"Token: \" ++ Token.show(token), tokens);\n\n\n// Tokenize a second line, using the scope stack from the previous line.\nlet (scopeStack, tokens) = Tokenizer.tokenize(~lineNumber=1, ~scopeStack=Some(scopeStack), ~scopeName, tokenizer, \"console.log('Hello, again!')\");\n```\n\n## Contributing\n\nContributions are welcome! We'd :heart: help implementing the remainder of functionality.\n\nNew changes must:\n- Add test coverage\n- Pass all existing tests (`esy '@test' run)\n\n## License\n\n[MIT License](./LICENSE)\n\nCopyright 2019 Outrun Labs, LLC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonivim%2Freason-textmate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonivim%2Freason-textmate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonivim%2Freason-textmate/lists"}