treesitter

package
v3.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package treesitter wires the vdb-manager language identifiers used in x_treeSitterQueries.language to concrete tree-sitter grammars bundled via github.com/smacker/go-tree-sitter.

The CLI links every supported grammar statically through CGo. Cross- compilation requires a C toolchain capable of targeting each GOOS/GOARCH (see justfile: `zig cc`).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Extensions

func Extensions(id LanguageID) []string

Extensions returns the file extensions associated with a language. The dot is included (e.g. ".py"). Returned slices must not be mutated.

func Grammar

func Grammar(id LanguageID) *sitter.Language

Grammar resolves a vdb-manager language identifier to a tree-sitter grammar. Returns nil if the language is not bundled.

Types

type LanguageID

type LanguageID string

LanguageID is the canonical identifier emitted by vdb-manager in the TreeSitterQuery.Language field. The set is fixed; new languages must be added in both vdb-manager and here.

const (
	LangJavaScript LanguageID = "javascript"
	LangTypeScript LanguageID = "typescript"
	LangTSX        LanguageID = "tsx"
	LangPython     LanguageID = "python"
	LangGo         LanguageID = "go"
	LangJava       LanguageID = "java"
	LangRuby       LanguageID = "ruby"
	LangRust       LanguageID = "rust"
	LangC          LanguageID = "c"
	LangCPP        LanguageID = "cpp"
	LangCSharp     LanguageID = "c-sharp"
	LangPHP        LanguageID = "php"
	LangSwift      LanguageID = "swift"
	LangKotlin     LanguageID = "kotlin"
	LangScala      LanguageID = "scala"
	LangBash       LanguageID = "bash"
	LangLua        LanguageID = "lua"
)

func All

func All() []LanguageID

All returns every bundled language identifier in declaration order.

func LanguageForPath

func LanguageForPath(path string) LanguageID

LanguageForPath returns the language ID a path's extension maps to, or empty if no bundled grammar handles it. Casing is normalised.

func Normalise

func Normalise(raw string) LanguageID

Normalise accepts user/server identifiers in any of the several spellings used in the wild (golang vs go, c-sharp vs csharp, etc.) and returns the canonical LanguageID, or empty if unknown.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL