language

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 7 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 FilterDisabled added in v0.2.0

func FilterDisabled(languages, disabled []string) []string

FilterDisabled removes disabled languages from the list.

func GetDisplayName

func GetDisplayName(id string) string

GetDisplayName returns the display name for a language ID.

func HasUserContent added in v0.2.0

func HasUserContent(content string) bool

HasUserContent checks if a markdown file contains user-added content beyond just headings and HTML comments. This is used to skip "empty" personal language files that were created but not yet customized.

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). Personal and project files without user content (just headings/comments) are skipped.

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