language

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package language provides language detection and configuration loading.

Index

Constants

This section is empty.

Variables

View Source
var SupportedLanguages = []Language{
	{ID: "python", DisplayName: "Python", Markers: []string{"pyproject.toml", "setup.py", "requirements.txt", "Pipfile", "poetry.lock"}},
	{ID: "go", DisplayName: "Go", Markers: []string{"go.mod"}},
	{ID: "typescript", DisplayName: "TypeScript", Markers: []string{"tsconfig.json"}},
	{ID: "javascript", DisplayName: "JavaScript", Markers: []string{"package.json"}},
	{ID: "rust", DisplayName: "Rust", Markers: []string{"Cargo.toml"}},
	{ID: "java", DisplayName: "Java", Markers: []string{"pom.xml", "build.gradle", "build.gradle.kts"}},
	{ID: "ruby", DisplayName: "Ruby", Markers: []string{"Gemfile"}},
	{ID: "csharp", DisplayName: "C#", Markers: []string{"*.csproj", "*.sln"}},
	{ID: "swift", DisplayName: "Swift", Markers: []string{"Package.swift"}},
	{ID: "kotlin", DisplayName: "Kotlin", Markers: []string{"build.gradle.kts"}},
}

SupportedLanguages lists all languages staghorn can detect.

Functions

func Detect

func Detect(projectRoot string) ([]string, error)

Detect scans projectRoot for language marker files. Returns a sorted list of detected language IDs.

func GetDisplayName

func GetDisplayName(id string) string

GetDisplayName returns the display name for a language ID.

func ListAvailableLanguages

func ListAvailableLanguages(teamDir, personalDir, projectDir string) ([]string, error)

ListAvailableLanguages returns all language IDs that have files in any of the given directories.

func LoadLanguageFiles

func LoadLanguageFiles(languages []string, teamDir, personalDir, projectDir string) (map[string][]*LanguageFile, error)

LoadLanguageFiles loads language configs from all layers for given languages. Returns a map of language ID to a slice of LanguageFiles (one per layer where found).

func Resolve

func Resolve(cfg *LanguageConfig, projectRoot string) ([]string, error)

Resolve determines final language list from config + detection.

Types

type Language

type Language struct {
	ID          string   // "python", "go", "typescript"
	DisplayName string   // "Python", "Go", "TypeScript"
	Markers     []string // Detection marker files
}

Language represents a supported programming language.

func GetLanguage

func GetLanguage(id string) *Language

GetLanguage returns the Language struct for a given ID.

type LanguageConfig

type LanguageConfig struct {
	AutoDetect bool     `yaml:"auto_detect"`
	Enabled    []string `yaml:"enabled,omitempty"`
	Disabled   []string `yaml:"disabled,omitempty"`
}

LanguageConfig contains language-specific settings.

type LanguageFile

type LanguageFile struct {
	Language string // Language ID (e.g., "python")
	Content  string // File contents
	Source   string // "team", "personal", or "project"
	Path     string // Full path to the file
}

LanguageFile represents a loaded language config file.

Jump to

Keyboard shortcuts

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