acmelsp

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: 29 Imported by: 0

Documentation

Overview

Package acmelsp implements the core of acme-lsp commands.

Index

Constants

This section is empty.

Variables

View Source
var Verbose = false

Functions

func AbsDirs added in v0.8.0

func AbsDirs(dirs []string) ([]string, error)

AbsDirs returns the absolute representation of directories dirs.

func Assist added in v0.6.0

func Assist(sm ServerMatcher, cmd string) error

Assist creates an acme window where output of cmd is written after each cursor position change in acme. Cmd is either "comp", "sig", "hov", or "auto" for completion, signature help, hover, or auto-detection of the former three.

func CodeActionAndFormat added in v0.8.0

func CodeActionAndFormat(ctx context.Context, server FormatServer, doc *protocol.TextDocumentIdentifier, f text.File, actions []protocol.CodeActionKind) error

CodeActionAndFormat runs the given code actions and then formats the file f.

func ListenAndServeProxy added in v0.7.0

func ListenAndServeProxy(ctx context.Context, cfg *config.Config, ss *ServerSet, fm *FileManager) error

func PlumbLocations added in v0.4.0

func PlumbLocations(locations []protocol.Location) error

PlumbLocations sends the locations to the plumber.

func PrintLocations added in v0.8.0

func PrintLocations(w io.Writer, loc []protocol.Location) error

Types

type Client added in v0.8.0

type Client struct {
	protocol.Server
	// contains filtered or unexported fields
}

Client represents a LSP client connection.

func NewClient added in v0.8.0

func NewClient(conn net.Conn, cfg *ClientConfig) (*Client, error)

func (*Client) Close added in v0.11.0

func (c *Client) Close() error

func (*Client) ExecuteCommandOnDocument added in v0.8.0

func (s *Client) ExecuteCommandOnDocument(ctx context.Context, params *proxy.ExecuteCommandOnDocumentParams) (interface{}, error)

ExecuteCommandOnDocument implements proxy.Server.

func (*Client) InitializeResult added in v0.8.0

InitializeResult implements proxy.Server.

func (*Client) Version added in v0.8.0

func (c *Client) Version(context.Context) (int, error)

Version exists only to implement proxy.Server.

func (*Client) WorkspaceFolders added in v0.8.0

func (c *Client) WorkspaceFolders(context.Context) ([]protocol.WorkspaceFolder, error)

WorkspaceFolders exists only to implement proxy.Server.

type ClientConfig added in v0.8.0

type ClientConfig struct {
	*config.Server
	*config.FilenameHandler
	RootDirectory string                     // used to compute RootURI in initialization
	HideDiag      bool                       // don't write diagnostics to DiagWriter
	RPCTrace      bool                       // print LSP rpc trace to stderr
	DiagWriter    DiagnosticsWriter          // notification handler writes diagnostics here
	Workspaces    []protocol.WorkspaceFolder // initial workspace folders
	Logger        *log.Logger
}

ClientConfig contains LSP client configuration values.

type DiagnosticsWriter added in v0.8.0

type DiagnosticsWriter interface {
	WriteDiagnostics(params *protocol.PublishDiagnosticsParams)
}

func NewDiagnosticsWriter added in v0.5.0

func NewDiagnosticsWriter() DiagnosticsWriter

type FileManager added in v0.5.0

type FileManager struct {
	// contains filtered or unexported fields
}

FileManager keeps track of open files in acme. It is used to synchronize text with LSP server.

Note that we can't cache the *acmeutil.Win for the windows because having the ctl file open prevents del event from being delivered to acme/log file.

func NewFileManager added in v0.5.0

func NewFileManager(ss *ServerSet, cfg *config.Config) (*FileManager, error)

NewFileManager creates a new file manager, initialized with files currently open in acme.

func (*FileManager) DidChange added in v0.8.0

func (fm *FileManager) DidChange(winid int) error

func (*FileManager) Run added in v0.8.0

func (fm *FileManager) Run()

Run watches for files opened, closed, saved, or refreshed in acme and tells LSP server about it. It also formats files when it's saved.

type RemoteCmd added in v0.8.0

type RemoteCmd struct {
	Stdout io.Writer
	Stderr io.Writer
	// contains filtered or unexported fields
}

RemoteCmd executes LSP commands in an acme window using the proxy server.

func CurrentWindowRemoteCmd added in v0.8.0

func CurrentWindowRemoteCmd(ss *ServerSet, fm *FileManager) (*RemoteCmd, error)

func NewRemoteCmd added in v0.8.0

func NewRemoteCmd(server proxy.Server, winid int) *RemoteCmd

func WindowRemoteCmd added in v0.8.0

func WindowRemoteCmd(ss *ServerSet, fm *FileManager, winid int) (*RemoteCmd, error)

func (*RemoteCmd) Completion added in v0.8.0

func (rc *RemoteCmd) Completion(ctx context.Context, edit bool) error

func (*RemoteCmd) Definition added in v0.8.0

func (rc *RemoteCmd) Definition(ctx context.Context, print bool) error

func (*RemoteCmd) DidChange added in v0.8.0

func (rc *RemoteCmd) DidChange(ctx context.Context) error

func (*RemoteCmd) DocumentSymbol added in v0.8.0

func (rc *RemoteCmd) DocumentSymbol(ctx context.Context) error

func (*RemoteCmd) Hover added in v0.8.0

func (rc *RemoteCmd) Hover(ctx context.Context) error

func (*RemoteCmd) Implementation added in v0.8.0

func (rc *RemoteCmd) Implementation(ctx context.Context, print bool) error

func (*RemoteCmd) OrganizeImportsAndFormat added in v0.8.0

func (rc *RemoteCmd) OrganizeImportsAndFormat(ctx context.Context) error

func (*RemoteCmd) References added in v0.8.0

func (rc *RemoteCmd) References(ctx context.Context) error

func (*RemoteCmd) Rename added in v0.8.0

func (rc *RemoteCmd) Rename(ctx context.Context, newname string) error

Rename renames the identifier at cursor position to newname.

func (*RemoteCmd) SignatureHelp added in v0.8.0

func (rc *RemoteCmd) SignatureHelp(ctx context.Context) error

func (*RemoteCmd) TypeDefinition added in v0.8.0

func (rc *RemoteCmd) TypeDefinition(ctx context.Context, print bool) error

type Server added in v0.8.0

type Server struct {
	Client *Client
	// contains filtered or unexported fields
}

func (*Server) Close added in v0.8.0

func (s *Server) Close()

type ServerInfo added in v0.8.0

type ServerInfo struct {
	*config.Server
	*config.FilenameHandler

	Re     *regexp.Regexp // filename regular expression
	Logger *log.Logger    // Logger for config.Server.LogFile
	// contains filtered or unexported fields
}

ServerInfo holds information about a LSP server and optionally a connection to it.

type ServerMatcher added in v0.8.0

type ServerMatcher interface {
	ServerMatch(ctx context.Context, filename string) (proxy.Server, bool, error)
}

ServerMatcher represents a set of servers where it's possible to find a matching server based on filename.

type ServerSet added in v0.8.0

type ServerSet struct {
	Data []*ServerInfo
	// contains filtered or unexported fields
}

ServerSet holds information about a set of LSP servers and connection to them, which are created on-demand.

func NewServerSet added in v0.8.0

func NewServerSet(cfg *config.Config, diagWriter DiagnosticsWriter) (*ServerSet, error)

NewServerSet creates a new server set from config.

func (*ServerSet) ClientConfig added in v0.8.0

func (ss *ServerSet) ClientConfig(info *ServerInfo) *ClientConfig

func (*ServerSet) CloseAll added in v0.8.0

func (ss *ServerSet) CloseAll()

func (*ServerSet) DidChangeWorkspaceFolders added in v0.8.0

func (ss *ServerSet) DidChangeWorkspaceFolders(ctx context.Context, added, removed []protocol.WorkspaceFolder) error

DidChangeWorkspaceFolders adds and removes given workspace folders.

func (*ServerSet) MatchFile added in v0.8.0

func (ss *ServerSet) MatchFile(filename string) *ServerInfo

func (*ServerSet) PrintTo added in v0.8.0

func (ss *ServerSet) PrintTo(w io.Writer)

func (*ServerSet) ServerMatch added in v0.8.0

func (ss *ServerSet) ServerMatch(ctx context.Context, filename string) (proxy.Server, bool, error)

func (*ServerSet) StartForFile added in v0.8.0

func (ss *ServerSet) StartForFile(filename string) (*Server, bool, error)

func (*ServerSet) Workspaces added in v0.8.0

func (ss *ServerSet) Workspaces() []protocol.WorkspaceFolder

Workspaces returns a sorted list of current workspace directories.

type UnitServerMatcher added in v0.8.0

type UnitServerMatcher struct {
	proxy.Server
}

UnitServerMatcher implements ServerMatcher using only one server.

func (*UnitServerMatcher) ServerMatch added in v0.8.0

func (sm *UnitServerMatcher) ServerMatch(ctx context.Context, filename string) (proxy.Server, bool, error)

Directories

Path Synopsis
Package config defines LSP tools configuration.
Package config defines LSP tools configuration.

Jump to

Keyboard shortcuts

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