acmelsp

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 30 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

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

AbsDirs returns the absolute representation of directories dirs.

func Assist

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

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

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

func PlumbLocations

func PlumbLocations(locations []protocol.Location) error

PlumbLocations sends the locations to the plumber.

func PrintLocations

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

Types

type Client

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

Client represents a LSP client connection.

func NewClient

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

func (*Client) Close

func (c *Client) Close() error

func (*Client) ExecuteCommandOnDocument

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

ExecuteCommandOnDocument implements proxy.Server.

func (*Client) InitializeResult

InitializeResult implements proxy.Server.

func (*Client) Version

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

Version exists only to implement proxy.Server.

func (*Client) WorkspaceFolders

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

WorkspaceFolders exists only to implement proxy.Server.

type ClientConfig

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 CompletionKind

type CompletionKind int
const (
	CompleteNoEdit CompletionKind = iota
	CompleteInsertOnlyMatch
	CompleteInsertFirstMatch
)

type DiagnosticsWriter

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

func NewDiagnosticsWriter

func NewDiagnosticsWriter() DiagnosticsWriter

type FileManager

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

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

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

func (*FileManager) Run

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

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

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

func NewRemoteCmd

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

func WindowRemoteCmd

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

func (*RemoteCmd) Completion

func (rc *RemoteCmd) Completion(ctx context.Context, kind CompletionKind) error

func (*RemoteCmd) Definition

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

func (*RemoteCmd) DidChange

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

func (*RemoteCmd) DocumentSymbol

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

func (*RemoteCmd) Hover

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

func (*RemoteCmd) Implementation

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

func (*RemoteCmd) OrganizeImportsAndFormat

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

func (*RemoteCmd) References

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

func (*RemoteCmd) Rename

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

Rename renames the identifier at cursor position to newname.

func (*RemoteCmd) SignatureHelp

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

func (*RemoteCmd) TypeDefinition

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

type Server

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

func (*Server) Close

func (s *Server) Close()

type ServerInfo

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

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

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

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

NewServerSet creates a new server set from config.

func (*ServerSet) ClientConfig

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

func (*ServerSet) CloseAll

func (ss *ServerSet) CloseAll()

func (*ServerSet) DidChangeWorkspaceFolders

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

DidChangeWorkspaceFolders adds and removes given workspace folders.

func (*ServerSet) MatchFile

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

func (*ServerSet) PrintTo

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

func (*ServerSet) ServerMatch

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

func (*ServerSet) StartForFile

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

func (*ServerSet) Workspaces

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

Workspaces returns a sorted list of current workspace directories.

type UnitServerMatcher

type UnitServerMatcher struct {
	proxy.Server
}

UnitServerMatcher implements ServerMatcher using only one server.

func (*UnitServerMatcher) ServerMatch

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