npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tree-sitter-fsharp

v0.1.0

Published

tree-sitter grammar for F# (still WIP) Based on [the 4.1 F# language specification](https://fsharp.org/specs/language-spec/4.1/FSharpSpec-4.1-latest.pdf) (Mostly, Appendix A) and the [F# compiler parser](https://github.com/dotnet/fsharp/blob/main/src/Comp

Downloads

4

Readme

tree-sitter-fsharp

tree-sitter grammar for F# (still WIP) Based on the 4.1 F# language specification (Mostly, Appendix A) and the F# compiler parser

Getting started

First, run npm install to install the tree-sitter cli. Next, the grammar can be build using npm run build, or used to parse a file with npm run parse $file

Project structure

This project defined two parser:

In addition to the grammar.js files each parser depends on a common external scanner found at ./common/scanner.h. The external scanner is responsible for parsing newlines and comments and keeps track of indentation to open and close scopes.

each grammar starts with the file node at the beginning of the rules.

Adding to neovim

tree-sitter-fsharp isn't supported out-of-the box by nvim-treesitter. However, nvim-treesitter has instructions for how to manually add unsupported parsers.

For tree-sitter-fsharp, this involves three steps:

  1. Update your Neovim config for nvim-treesitter to refer to tree-sitter-fsharp.
  2. Run :TSInstall fsharp inside Neovim.
  3. Copy the files from ./queries/ to the neovim config directory at$XDG_CONFIG_HOME/nvim/queries/fsharp/ - see the Adding queries section of the nvim-treesitter README.

The config you need is this (you can use a local path for url if you prefer):

local parser_config = require('nvim-treesitter.parsers').get_parser_configs()
parser_config.fsharp = {
  install_info = {
    url = 'https://github.com/ionide/tree-sitter-fsharp',
    branch = 'main',
    files = { 'src/scanner.c', 'src/parser.c' },
    location = "fsharp"
  },
  requires_generate_from_grammar = false,
  filetype = 'fsharp',
}

Development

The package.json defines some helpful targets for developing the grammar:

  • npm run build rebuilds all parser.
  • npm test runs all tests for both parsers.
  • npm run parse $file run the fsharp parser on $file and outputs the parse tree.
  • npm run debug $file run the fsharp parser on $file and prints debug information.

How to contribute

Clone the project and start playing around with it. If 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.

For an introduction to developing tree-sitter parsers the official documentation is a good reference point.

PRs fleshing out the grammar or fixing bugs are welcome!