Skip to content

feat: add F# language support (tree-sitter + FsAutoComplete) #168

@jafreck

Description

@jafreck

Summary

Add F# support via tree-sitter + LSP enrichment, complementing existing C# support in the .NET ecosystem.

Tooling

Component Tool Notes
Tree-sitter grammar tree-sitter-fsharp Ionide project, actively maintained
LSP server FsAutoComplete Community standard, mature
SCIP indexer None (scip-dotnet covers C#/VB but not F#) N/A

What to implement

  • Add tree-sitter-fsharp as an npm dependency
  • Create src/indexer/extractors/fsharp.ts:
    • Extract let funcName args = body as function symbols
    • Extract type TypeName = ... as type symbols (discriminated unions, records, classes)
    • Extract module ModuleName as module symbols
    • Extract member this.MethodName(args) as method symbols
    • Extract function application (funcName arg1 arg2) as call refs
    • Extract pipe chains (x |> f |> g) — each piped function is a call ref
    • Extract open Module.Path as imports
  • Register fsharp in SourceIndexStage EXTRACTORS map and ParserPool LANG_PACKAGES
  • Add fsautocomplete to src/indexer/lsp/registry.ts: { command: 'fsautocomplete', args: ['--adaptive-lsp-server-enabled'] }
  • Add file extensions .fs, .fsi, .fsx to walker
  • Add test fixtures in tests/fixtures/fsharp/
  • Add extractor tests

Language notes

  • F# uses significant whitespace (indentation-based scoping, like Python)
  • Function application is by juxtaposition (f x y), not parentheses — the extractor must recognize this pattern
  • Pipe operator |> is idiomatic: data |> List.map transform |> List.filter pred — each function in the chain is a call edge
  • .fsi files are signature files (like .d.ts for TypeScript) — should be indexed in declaration mode
  • Discriminated unions (type Shape = Circle of float | Rectangle of float * float) are key type declarations
  • Computation expressions (async { ... }, task { ... }) contain call-like constructs

Context

Complements existing C# support. F# and C# co-exist in .NET solutions and interop freely. Finance and data-heavy .NET projects increasingly use F#.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions