{"id":18033364,"url":"https://github.com/ionide/tree-sitter-fsharp","last_synced_at":"2025-04-13T00:49:40.340Z","repository":{"id":109673716,"uuid":"568453533","full_name":"ionide/tree-sitter-fsharp","owner":"ionide","description":"F# grammar for treesitter","archived":false,"fork":false,"pushed_at":"2025-03-28T22:52:20.000Z","size":187315,"stargazers_count":82,"open_issues_count":8,"forks_count":22,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-13T00:49:30.886Z","etag":null,"topics":["fsharp","parser","tree-sitter"],"latest_commit_sha":null,"homepage":"","language":"C","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/ionide.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},"funding":{"open_collective":"ionide"}},"created_at":"2022-11-20T15:28:30.000Z","updated_at":"2025-04-04T15:03:34.000Z","dependencies_parsed_at":"2024-11-06T14:49:20.523Z","dependency_job_id":null,"html_url":"https://github.com/ionide/tree-sitter-fsharp","commit_stats":{"total_commits":305,"total_committers":15,"mean_commits":"20.333333333333332","dds":"0.39344262295081966","last_synced_commit":"971da5ff0266bfe4a6ecfb94616548032d6d1ba0"},"previous_names":["ionide/tree-sitter-fsharp"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ionide%2Ftree-sitter-fsharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ionide%2Ftree-sitter-fsharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ionide%2Ftree-sitter-fsharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ionide%2Ftree-sitter-fsharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ionide","download_url":"https://codeload.github.com/ionide/tree-sitter-fsharp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650436,"owners_count":21139672,"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":["fsharp","parser","tree-sitter"],"created_at":"2024-10-30T11:06:25.682Z","updated_at":"2025-04-13T00:49:40.322Z","avatar_url":"https://github.com/ionide.png","language":"C","funding_links":["https://opencollective.com/ionide"],"categories":[],"sub_categories":[],"readme":"# tree-sitter-fsharp\n\ntree-sitter grammar for F# (still WIP)\nBased on [the 4.1 F# language specification](https://fsharp.org/specs/language-spec/4.1/FSharpSpec-4.1-latest.pdf) (Mostly, Appendix A)\nand the [F# compiler parser](https://github.com/dotnet/fsharp/blob/main/src/Compiler/pars.fsy)\n\n## Getting started\n\nFirst, run `npm install` to install the `tree-sitter cli`.\nNext, the grammar can be build using `npm run build`, or used to parse a file with `npm run parse $file`\n\n### Project structure\n\nThis project defined two parser:\n\n- [./fsharp/grammar.js](./fsharp/grammar.js)`fsharp` grammar.\n- [./fsharp_signature/grammar.js](./fsharp_signature/grammar.js) defines the grammar for signature files\n\nIn addition to the `grammar.js` files each parser depends on a common external scanner found at [./common/scanner.h](./common/scanner.h).\nThe external scanner is responsible for parsing newlines and comments and keeps track of indentation to open and close scopes.\n\neach grammar starts with the `file` node at the beginning of the rules.\n\n### Adding to neovim\n\ntree-sitter-fsharp is supported through the usual installation methods of [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).\n\nInstalling the lastest grammar from this repo involves the following three steps:\n\n1. Update your Neovim config for nvim-treesitter to refer to tree-sitter-fsharp.\n2. Run `:TSInstall fsharp` inside Neovim.\n3. Copy the files from [./queries/](./queries) to the neovim config directory at`$XDG_CONFIG_HOME/nvim/queries/fsharp/` - see [the Adding queries section of the nvim-treesitter README](https://github.com/nvim-treesitter/nvim-treesitter?tab=readme-ov-file#adding-queries).\n\nThe config you need is this (you can use a local path for `url` if you prefer):\n\n```lua\nlocal parser_config = require('nvim-treesitter.parsers').get_parser_configs()\nparser_config.fsharp = {\n  install_info = {\n    url = 'https://github.com/ionide/tree-sitter-fsharp',\n    branch = 'main',\n    files = { 'src/scanner.c', 'src/parser.c' },\n    location = \"fsharp\"\n  },\n  requires_generate_from_grammar = false,\n  filetype = 'fsharp',\n}\n```\n\n## Development\n\nThe `package.json` defines some helpful targets for developing the grammar:\n\n- `npm run generate` rebuilds all parser.\n- `npx tree-sitter test` runs all tests for both parsers.\n- `npx tree-sitter parse $file` run the `fsharp` parser on `$file` and outputs the parse tree.\n- `npx tree-sitter parse -d $file` run the `fsharp` parser on `$file` and prints debug information.\n\n## How to contribute\n\nClone the project and start playing around with it.\nIf you find a code example which fails to parse, please reduce it to a minimal example and added to the corpus (`fsharp/test/corpus/*.txt`) as a test case.\n\nFor an introduction to developing tree-sitter parsers the [official documentation](https://tree-sitter.github.io/tree-sitter/creating-parsers) is a good reference point.\n\nPRs fleshing out the grammar or fixing bugs are welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fionide%2Ftree-sitter-fsharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fionide%2Ftree-sitter-fsharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fionide%2Ftree-sitter-fsharp/lists"}