discovery

package
v0.0.51 Latest Latest
Warning

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

Go to latest
Published: May 17, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LanguageServerMap = map[string]ServerInfo{
	"go": {
		Command:    "gopls",
		InstallCmd: "go install golang.org/x/tools/gopls@latest",
	},
	"typescript": {
		Command:    "typescript-language-server",
		Args:       []string{"--stdio"},
		InstallCmd: "npm install -g typescript-language-server typescript",
	},
	"javascript": {
		Command:    "typescript-language-server",
		Args:       []string{"--stdio"},
		InstallCmd: "npm install -g typescript-language-server typescript",
	},
	"python": {
		Command:    "pylsp",
		InstallCmd: "pip install python-lsp-server",
	},
	"rust": {
		Command:    "rust-analyzer",
		InstallCmd: "rustup component add rust-analyzer",
	},
	"java": {
		Command:    "jdtls",
		InstallCmd: "Install Eclipse JDT Language Server",
	},
	"c": {
		Command:    "clangd",
		InstallCmd: "Install clangd from your package manager",
	},
	"cpp": {
		Command:    "clangd",
		InstallCmd: "Install clangd from your package manager",
	},
	"php": {
		Command:    "intelephense",
		Args:       []string{"--stdio"},
		InstallCmd: "npm install -g intelephense",
	},
	"ruby": {
		Command:    "solargraph",
		Args:       []string{"stdio"},
		InstallCmd: "gem install solargraph",
	},
	"lua": {
		Command:    "lua-language-server",
		InstallCmd: "Install lua-language-server from your package manager",
	},
	"html": {
		Command:    "vscode-html-language-server",
		Args:       []string{"--stdio"},
		InstallCmd: "npm install -g vscode-langservers-extracted",
	},
	"css": {
		Command:    "vscode-css-language-server",
		Args:       []string{"--stdio"},
		InstallCmd: "npm install -g vscode-langservers-extracted",
	},
	"json": {
		Command:    "vscode-json-language-server",
		Args:       []string{"--stdio"},
		InstallCmd: "npm install -g vscode-langservers-extracted",
	},
	"yaml": {
		Command:    "yaml-language-server",
		Args:       []string{"--stdio"},
		InstallCmd: "npm install -g yaml-language-server",
	},
}

LanguageServerMap maps language IDs to their corresponding LSP servers

Functions

func ConfigureLSPServers

func ConfigureLSPServers(rootDir string) (map[string]ServerInfo, error)

ConfigureLSPServers detects languages and configures LSP servers

func DetectLanguages

func DetectLanguages(rootDir string) (map[string]LanguageInfo, error)

DetectLanguages scans a directory to identify programming languages used in the project

func GetLanguageIDFromExtension

func GetLanguageIDFromExtension(ext string) string

GetLanguageIDFromExtension returns the language ID for a given file extension

func GetLanguageIDFromPath

func GetLanguageIDFromPath(path string) string

GetLanguageIDFromPath determines the language ID from a file path

func GetLanguageIDFromProtocol

func GetLanguageIDFromProtocol(langKind string) string

GetLanguageIDFromProtocol converts a protocol.LanguageKind to our language ID string

func IntegrateLSPServers

func IntegrateLSPServers(workingDir string) error

IntegrateLSPServers discovers languages and LSP servers and integrates them into the application configuration

Types

type LanguageInfo

type LanguageInfo struct {
	// Language identifier (e.g., "go", "typescript", "python")
	ID string

	// Number of files detected for this language
	FileCount int

	// Project files associated with this language (e.g., go.mod, package.json)
	ProjectFiles []string

	// Whether this is likely a primary language in the project
	IsPrimary bool
}

LanguageInfo stores information about a detected language

type ProjectFile

type ProjectFile struct {
	// File name or pattern to match
	Name string

	// Associated language ID
	LanguageID string

	// Whether this file strongly indicates the language is primary
	IsPrimary bool
}

ProjectFile represents a project configuration file

type ServerInfo

type ServerInfo struct {
	// Command to run the server
	Command string

	// Arguments to pass to the command
	Args []string

	// Command to install the server (for user guidance)
	InstallCmd string

	// Whether this server is available
	Available bool

	// Full path to the executable (if found)
	Path string
}

ServerInfo contains information about an LSP server

func FindLSPServer

func FindLSPServer(languageID string) (ServerInfo, error)

FindLSPServer searches for an LSP server for the given language

Jump to

Keyboard shortcuts

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