config

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package config defines LSP tools configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UserConfigDir

func UserConfigDir() (string, error)

UserConfigDir returns the default root directory to use for user-specific configuration data. Users should create their own application-specific subdirectory within this one and use that.

On Unix systems, it returns $XDG_CONFIG_HOME as specified by https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html if non-empty, else $HOME/.config. On Darwin, it returns $HOME/Library/Application Support. On Windows, it returns %AppData%. On Plan 9, it returns $home/lib.

If the location cannot be determined (for example, $HOME is not defined), then it will return an error.

func Write

func Write(w io.Writer, cfg *Config) error

Write writes Config to writer w.

Types

type Config

type Config struct {
	File

	// Show current configuration and exit
	ShowConfig bool

	// Print more messages to stderr
	Verbose bool
	// contains filtered or unexported fields
}

Config configures acme-lsp and L.

func Default

func Default() *Config

Default returns the default Config.

func Load

func Load() (*Config, error)

Load loads Config from file system. It first looks at ACME_LSP_CONFIG environment variable for location of configuration file and loads it if it is set. If the environment variable is not set, it'll use UserConfigDir/acme-lsp/config.toml if it exists. Otherwise, it'll falling back to a default configuration.

func (*Config) ParseFlags

func (cfg *Config) ParseFlags(flags Flags, f *flag.FlagSet, arguments []string) error

ParseFlags parses command line flags and updates Config.

type File

type File struct {
	// Network and address used for communication between acme-lsp and L.
	// Only required on systems without unix domain socket.
	ProxyNetwork, ProxyAddress string

	// Network and address where acme is serving 9P file server.
	// Only required on systems without unix domain socket.
	AcmeNetwork, AcmeAddress string

	// Initial set of workspace directories.
	WorkspaceDirectories []string

	// Root directory used for LSP initialization.
	RootDirectory string

	// Don't show diagnostics sent by the LSP server.
	HideDiagnostics bool

	// Format file when Put is executed in a window.
	FormatOnPut bool

	// Print to stderr the full rpc trace in lsp inspector format
	RPCTrace bool

	// LSP code actions to run when Put is executed in a window.
	CodeActionsOnPut []protocol.CodeActionKind

	// LSP servers keyed by a user provided name.
	Servers map[string]*Server

	// Servers determined by regular expression match on filename,
	// as supplied by -server and -dial flags.
	FilenameHandlers []FilenameHandler
}

File represents user configuration file for acme-lsp and L.

type FilenameHandler

type FilenameHandler struct {
	// Pattern is a regular expression that matches filename.
	Pattern string

	// Language identifier (e.g. "go" or "python")
	// See list of languages here:
	// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentItem
	LanguageID string

	// ServerKey is the key in Config.File.Servers.
	ServerKey string
}

FilenameHandler contains a regular expression pattern that matches a filename and the associated server key.

type Flags

type Flags uint

Flags represent a set of command line flags.

const (
	// LangServerFlags include flags that configure LSP servers.
	LangServerFlags Flags = 1 << iota

	// ProxyFlags include flags that configure how to connect to proxy server.
	ProxyFlags
)

type Server

type Server struct {
	// Command that speaks LSP on stdin/stdout.
	// Can be empty if Address is given.
	Command []string

	// Dial address for LSP server. Ignored if Command is not empty.
	Address string

	// Write stderr of Command to this file.
	// If it's not an absolute path, it'll become relative to the cache directory.
	StderrFile string

	// Write log messages (window/logMessage notifications) sent by LSP server
	// to this file instead of stderr.
	// If it's not an absolute path, it'll become relative to the cache directory.
	LogFile string

	// Options contain server-specific settings that are passed as-is to the LSP server.
	Options interface{}
}

Server describes a LSP server.

Jump to

Keyboard shortcuts

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