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 DiagnosticsWriter
- type FileManager
- type FormatServer
- type RemoteCmd
- func (rc *RemoteCmd) Completion(ctx context.Context, edit bool) 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 ¶ 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 PlumbLocations ¶ added in v0.4.0
PlumbLocations sends the locations to the plumber.
Types ¶
type Client ¶ added in v0.8.0
Client represents a LSP client connection.
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
func (c *Client) InitializeResult(context.Context, *protocol.TextDocumentIdentifier) (*protocol.InitializeResult, error)
InitializeResult implements proxy.Server.
func (*Client) WorkspaceFolders ¶ added in v0.8.0
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 FormatServer ¶ added in v0.8.0
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 ¶ 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 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 (*RemoteCmd) Definition ¶ added in v0.8.0
func (*RemoteCmd) DocumentSymbol ¶ added in v0.8.0
func (*RemoteCmd) Implementation ¶ added in v0.8.0
func (*RemoteCmd) OrganizeImportsAndFormat ¶ added in v0.8.0
func (*RemoteCmd) References ¶ added in v0.8.0
func (*RemoteCmd) Rename ¶ added in v0.8.0
Rename renames the identifier at cursor position to newname.
func (*RemoteCmd) SignatureHelp ¶ added in v0.8.0
type Server ¶ added in v0.8.0
type Server struct { Client *Client // contains filtered or unexported fields }
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) 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) ServerMatch ¶ added in v0.8.0
func (*ServerSet) StartForFile ¶ added in v0.8.0
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
UnitServerMatcher implements ServerMatcher using only one server.