Skip to content

Feature Request: Native Tree-sitter Support for R #2116

Closed

Description

@lennon-li

Summary

Graphify currently recognizes .R files but relies on semantic/LLM-based extraction rather than deterministic AST parsing. This limits the accuracy and reproducibility of the generated graph for R projects, particularly CRAN-style packages.

I would like to contribute native Tree-sitter-based support for R.

Motivation

R remains a major language in statistics, data science, epidemiology, and bioinformatics, with tens of thousands of open-source packages on CRAN and many active research codebases.

While semantic extraction provides a useful high-level understanding, a native parser would provide:

  • Deterministic extraction
  • Fully local analysis (no model required)
  • Better reproducibility
  • More accurate symbol and call relationships
  • Faster indexing
  • Improved support for large repositories

Proposed Scope (Initial PR)

To keep the implementation manageable, I propose starting with core language support only.

The initial implementation would extract:

  • Function definitions (<- function() and = function())
  • Function calls
  • Package-qualified calls (pkg::fun, pkg:::fun)
  • library() and require() imports
  • Source locations
  • File/function relationships

The goal is to produce the same core graph entities available for other Tree-sitter-backed languages.

Future Enhancements

Once the core extractor is stable, additional R-specific features could be added incrementally, for example:

  • DESCRIPTION parsing
  • NAMESPACE parsing
  • Roxygen metadata
  • Exported vs internal functions
  • testthat relationships
  • S3 generic/method links
  • S4 support
  • R6 classes
  • Vignettes and package structure

These would likely be separate follow-up PRs rather than part of the initial implementation.

Questions

Before starting implementation, I'd like to confirm:

  1. Would maintainers be interested in native Tree-sitter support for R?
  2. Is there any preferred architecture or extractor pattern I should follow beyond the existing language extractors?
  3. Are there any planned changes to the extraction pipeline that I should be aware of before beginning work?

If there is interest, I'd be happy to work on the initial implementation and submit a PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions