Documentation ¶
Overview ¶
Package acmelsp implements the core of acme-lsp commands.
Index ¶
- Variables
- func AbsDirs(dirs []string) ([]string, error)
- func Assist(sm ServerMatcher, cmd string) error
- func CodeActionAndFormat(ctx context.Context, server FormatServer, doc *protocol.TextDocumentIdentifier, ...) error
- func ListenAndServeProxy(ctx context.Context, cfg *config.Config, ss *ServerSet, fm *FileManager) error
- func PlumbLocations(locations []protocol.Location) error
- func PrintLocations(w io.Writer, loc []protocol.Location) error
- type Client
- func (c *Client) Close() error
- func (s *Client) ExecuteCommandOnDocument(ctx context.Context, params *proxy.ExecuteCommandOnDocumentParams) (interface{}, error)
- func (c *Client) InitializeResult(context.Context, *protocol.TextDocumentIdentifier) (*protocol.InitializeResult, error)
- func (c *Client) Version(context.Context) (int, error)
- func (c *Client) WorkspaceFolders(context.Context) ([]protocol.WorkspaceFolder, error)
- type ClientConfig
- type CompletionKind
- type DiagnosticsWriter
- type FileManager
- type FormatServer
- type RemoteCmd
- func (rc *RemoteCmd) Completion(ctx context.Context, kind CompletionKind) error
- func (rc *RemoteCmd) Definition(ctx context.Context, print bool) error
- func (rc *RemoteCmd) DidChange(ctx context.Context) error
- func (rc *RemoteCmd) DocumentSymbol(ctx context.Context) error
- func (rc *RemoteCmd) Hover(ctx context.Context) error
- func (rc *RemoteCmd) Implementation(ctx context.Context, print bool) error
- func (rc *RemoteCmd) OrganizeImportsAndFormat(ctx context.Context) error
- func (rc *RemoteCmd) References(ctx context.Context) error
- func (rc *RemoteCmd) Rename(ctx context.Context, newname string) error
- func (rc *RemoteCmd) SignatureHelp(ctx context.Context) error
- func (rc *RemoteCmd) TypeDefinition(ctx context.Context, print bool) error
- type Server
- type ServerInfo
- type ServerMatcher
- type ServerSet
- func (ss *ServerSet) ClientConfig(info *ServerInfo) *ClientConfig
- func (ss *ServerSet) CloseAll()
- func (ss *ServerSet) DidChangeWorkspaceFolders(ctx context.Context, added, removed []protocol.WorkspaceFolder) error
- func (ss *ServerSet) MatchFile(filename string) *ServerInfo
- func (ss *ServerSet) PrintTo(w io.Writer)
- func (ss *ServerSet) ServerMatch(ctx context.Context, filename string) (proxy.Server, bool, error)
- func (ss *ServerSet) StartForFile(filename string) (*Server, bool, error)
- func (ss *ServerSet) Workspaces() []protocol.WorkspaceFolder
- type UnitServerMatcher
Constants ¶
This section is empty.
Variables ¶
var Verbose = false
Functions ¶
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 PlumbLocations ¶
PlumbLocations sends the locations to the plumber.
Types ¶
type Client ¶
Client represents a LSP client connection.
func (*Client) ExecuteCommandOnDocument ¶
func (s *Client) ExecuteCommandOnDocument(ctx context.Context, params *proxy.ExecuteCommandOnDocumentParams) (interface{}, error)
ExecuteCommandOnDocument implements proxy.Server.
func (*Client) InitializeResult ¶
func (c *Client) InitializeResult(context.Context, *protocol.TextDocumentIdentifier) (*protocol.InitializeResult, error)
InitializeResult implements proxy.Server.
func (*Client) WorkspaceFolders ¶
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 FormatServer ¶
type FormatServer interface { InitializeResult(context.Context, *protocol.TextDocumentIdentifier) (*protocol.InitializeResult, error) DidChange(context.Context, *protocol.DidChangeTextDocumentParams) error Formatting(context.Context, *protocol.DocumentFormattingParams) ([]protocol.TextEdit, error) CodeAction(context.Context, *protocol.CodeActionParams) ([]protocol.CodeAction, error) ExecuteCommandOnDocument(context.Context, *proxy.ExecuteCommandOnDocumentParams) (interface{}, error) }
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 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 (*RemoteCmd) Implementation ¶
func (*RemoteCmd) OrganizeImportsAndFormat ¶
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) 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) ServerMatch ¶
func (*ServerSet) StartForFile ¶
func (*ServerSet) Workspaces ¶
func (ss *ServerSet) Workspaces() []protocol.WorkspaceFolder
Workspaces returns a sorted list of current workspace directories.
type UnitServerMatcher ¶
UnitServerMatcher implements ServerMatcher using only one server.