Documentation
¶
Index ¶
- Constants
- Variables
- func NewClient(server Process) (Client, Diagnostics)
- func PathToURI(path string) protocol.DocumentUri
- type Client
- type ClientImpl
- func (c *ClientImpl) GetDocumentSymbols(ctx context.Context, params protocol.DocumentSymbolParams) ([]protocol.DocumentSymbol, error)
- func (c *ClientImpl) GetWorkspaceSymbols(ctx context.Context, params protocol.WorkspaceSymbolParams) ([]protocol.SymbolInformation, error)
- func (c *ClientImpl) Initialize(ctx context.Context, params protocol.InitializeParams) (protocol.InitializeResult, error)
- func (c *ClientImpl) NotifyDidClose(ctx context.Context, params protocol.DidCloseTextDocumentParams) error
- func (c *ClientImpl) NotifyDidOpen(ctx context.Context, params protocol.DidOpenTextDocumentParams) error
- func (c *ClientImpl) NotifyInitialized(ctx context.Context) error
- func (c *ClientImpl) Shutdown(ctx context.Context) error
- type ClientPool
- type ClientPoolImpl
- func (c *ClientPoolImpl) Delete(projectId ProjectId, languageId LanguageId)
- func (c *ClientPoolImpl) DeleteAllForProject(projectId ProjectId)
- func (c *ClientPoolImpl) Get(projectId ProjectId, languageId LanguageId) (Client, bool)
- func (c *ClientPoolImpl) GetAllForProject(projectId ProjectId) (map[LanguageId]Client, bool)
- func (c *ClientPoolImpl) Set(projectId ProjectId, languageId LanguageId, client Client)
- type Command
- type Connection
- type ConnectionImpl
- type Diagnostics
- type DiagnosticsStore
- type DocumentOutline
- type DocumentSymbol
- type LanguageDetector
- type LanguageDetectorImpl
- type LanguageId
- type LanguageNotSupportedError
- type LanguageServerAlreadyExistsError
- type LanguageServerNotFoundError
- type Location
- type LspClientStore
- type LspDiagnostics
- type Position
- type Process
- type ProcessImpl
- type ProjectId
- type ProjectRoot
- type Range
- type Service
- type ServiceImpl
- func (s *ServiceImpl) CleanupProject(ctx context.Context, projectId ProjectId) error
- func (s *ServiceImpl) GetDiagnostics(ctx context.Context, file model.File) ([]protocol.Diagnostic, error)
- func (s *ServiceImpl) GetDocumentOutline(ctx context.Context, file model.File) (DocumentOutline, error)
- func (s *ServiceImpl) GetWorkspaceSymbols(ctx context.Context, query string, symbolFilter SymbolFilter) ([]SymbolInfo, error)
- func (s *ServiceImpl) NotifyDidClose(ctx context.Context, file model.File) error
- func (s *ServiceImpl) NotifyDidOpen(ctx context.Context, file model.File) error
- func (s *ServiceImpl) StartServer(ctx context.Context, languageId LanguageId) error
- func (s *ServiceImpl) StopServer(ctx context.Context, languageId LanguageId) error
- type SymbolFilter
- type SymbolInfo
Constants ¶
View Source
const ( Go = LanguageId("Go") JavaScript = LanguageId("JavaScript") Python = LanguageId("Python") TypeScript = LanguageId("TypeScript") )
Language IDs based on https://github.com/go-enry/go-enry For reference see https://github.com/go-enry/go-enry/blob/master/data/languageInfo.go
Variables ¶
View Source
var LspServerExecutables = map[LanguageId]Command{ Go: NewCommand("gopls", []string{}), Python: NewCommand("pyright-langserver", []string{"--stdio"}), JavaScript: NewCommand("typescript-language-server", []string{"--stdio"}), TypeScript: NewCommand("typescript-language-server", []string{"--stdio"}), }
Functions ¶
func NewClient ¶
func NewClient(server Process) (Client, Diagnostics)
func PathToURI ¶
func PathToURI(path string) protocol.DocumentUri
Types ¶
type Client ¶
type Client interface { GetWorkspaceSymbols(ctx context.Context, params protocol.WorkspaceSymbolParams) ([]protocol.SymbolInformation, error) GetDocumentSymbols(ctx context.Context, params protocol.DocumentSymbolParams) ([]protocol.DocumentSymbol, error) Initialize(ctx context.Context, params protocol.InitializeParams) (protocol.InitializeResult, error) NotifyInitialized(ctx context.Context) error NotifyDidOpen(ctx context.Context, params protocol.DidOpenTextDocumentParams) error NotifyDidClose(ctx context.Context, params protocol.DidCloseTextDocumentParams) error // TODO: check if any LSP server supports this // PullDiagnostics(ctx context.Context, params DocumentDiagnosticParams) (DocumentDiagnosticReport, error) Shutdown(ctx context.Context) error }
type ClientImpl ¶
type ClientImpl struct {
// contains filtered or unexported fields
}
func (*ClientImpl) GetDocumentSymbols ¶ added in v0.5.0
func (c *ClientImpl) GetDocumentSymbols(ctx context.Context, params protocol.DocumentSymbolParams) ([]protocol.DocumentSymbol, error)
func (*ClientImpl) GetWorkspaceSymbols ¶
func (c *ClientImpl) GetWorkspaceSymbols(ctx context.Context, params protocol.WorkspaceSymbolParams) ([]protocol.SymbolInformation, error)
func (*ClientImpl) Initialize ¶
func (c *ClientImpl) Initialize(ctx context.Context, params protocol.InitializeParams) (protocol.InitializeResult, error)
func (*ClientImpl) NotifyDidClose ¶
func (c *ClientImpl) NotifyDidClose(ctx context.Context, params protocol.DidCloseTextDocumentParams) error
func (*ClientImpl) NotifyDidOpen ¶
func (c *ClientImpl) NotifyDidOpen(ctx context.Context, params protocol.DidOpenTextDocumentParams) error
func (*ClientImpl) NotifyInitialized ¶
func (c *ClientImpl) NotifyInitialized(ctx context.Context) error
type ClientPool ¶
type ClientPool interface { Get(projectId ProjectId, languageId LanguageId) (Client, bool) GetAllForProject(projectId ProjectId) (map[LanguageId]Client, bool) Set(projectId ProjectId, languageId LanguageId, client Client) Delete(projectId ProjectId, languageId LanguageId) DeleteAllForProject(projectId ProjectId) }
type ClientPoolImpl ¶
type ClientPoolImpl struct {
// contains filtered or unexported fields
}
In memory store for clients. Applies mutex locking for concurrent access.
func NewClientPool ¶
func NewClientPool() *ClientPoolImpl
func (*ClientPoolImpl) Delete ¶
func (c *ClientPoolImpl) Delete(projectId ProjectId, languageId LanguageId)
func (*ClientPoolImpl) DeleteAllForProject ¶
func (c *ClientPoolImpl) DeleteAllForProject(projectId ProjectId)
func (*ClientPoolImpl) Get ¶
func (c *ClientPoolImpl) Get(projectId ProjectId, languageId LanguageId) (Client, bool)
func (*ClientPoolImpl) GetAllForProject ¶
func (c *ClientPoolImpl) GetAllForProject(projectId ProjectId) (map[LanguageId]Client, bool)
func (*ClientPoolImpl) Set ¶
func (c *ClientPoolImpl) Set(projectId ProjectId, languageId LanguageId, client Client)
type Connection ¶
type Connection interface { Call(ctx context.Context, method string, params interface{}, result interface{}) error Notify(ctx context.Context, method string, params interface{}) error }
func NewConnection ¶
func NewConnection(ctx context.Context, rwc io.ReadWriteCloser, handler jsonrpc2.Handler) Connection
type ConnectionImpl ¶
type ConnectionImpl struct {
// contains filtered or unexported fields
}
type Diagnostics ¶ added in v0.5.0
type Diagnostics <-chan protocol.PublishDiagnosticsParams
type DiagnosticsStore ¶
type DiagnosticsStore struct {
// contains filtered or unexported fields
}
In memory store for diagnostics. Applies mutex locking for concurrent access.
func NewDiagnosticsStore ¶
func NewDiagnosticsStore() *DiagnosticsStore
func (*DiagnosticsStore) DeleteAllForProject ¶
func (d *DiagnosticsStore) DeleteAllForProject(projectId ProjectId)
func (*DiagnosticsStore) Get ¶
func (d *DiagnosticsStore) Get(projectId ProjectId, uri protocol.DocumentUri) ([]protocol.Diagnostic, bool)
func (*DiagnosticsStore) Set ¶
func (d *DiagnosticsStore) Set(projectId ProjectId, uri protocol.DocumentUri, diagnostics []protocol.Diagnostic)
type DocumentOutline ¶ added in v0.5.0
type DocumentOutline struct { Path string `json:"path"` DocumentSymbols []DocumentSymbol `json:"document_symbols"` }
type DocumentSymbol ¶ added in v0.5.0
type DocumentSymbol struct { Name string `json:"name"` Detail string `json:"detail"` Kind string `json:"kind"` Range Range `json:"range"` Children []DocumentSymbol `json:"children,omitempty"` }
type LanguageDetector ¶
type LanguageDetector interface { DetectLanguage(file *model.File) string DetectLanguages(files []*model.File) map[string]int DetectMainLanguage(files []*model.File) string }
func NewLanguageDetector ¶
func NewLanguageDetector() LanguageDetector
type LanguageDetectorImpl ¶
type LanguageDetectorImpl struct{}
LanguageDetectorImpl implements LanguageDetector using https://github.com/go-enry/go-enry
func (LanguageDetectorImpl) DetectLanguage ¶
func (ld LanguageDetectorImpl) DetectLanguage(file *model.File) LanguageId
func (LanguageDetectorImpl) DetectLanguages ¶
func (ld LanguageDetectorImpl) DetectLanguages(files []*model.File) map[string]int
func (LanguageDetectorImpl) DetectMainLanguage ¶
func (ld LanguageDetectorImpl) DetectMainLanguage(files []*model.File) string
type LanguageId ¶
type LanguageId = string
type LanguageNotSupportedError ¶
type LanguageNotSupportedError struct {
// contains filtered or unexported fields
}
func NewLanguageNotSupportedError ¶
func NewLanguageNotSupportedError(languageId LanguageId) *LanguageNotSupportedError
func (LanguageNotSupportedError) Error ¶
func (e LanguageNotSupportedError) Error() string
type LanguageServerAlreadyExistsError ¶
type LanguageServerAlreadyExistsError struct { ProjectId ProjectId LanguageId LanguageId }
func NewLanguageServerAlreadyExistsError ¶
func NewLanguageServerAlreadyExistsError(projectId ProjectId, languageId LanguageId) *LanguageServerAlreadyExistsError
func (LanguageServerAlreadyExistsError) Error ¶
func (e LanguageServerAlreadyExistsError) Error() string
type LanguageServerNotFoundError ¶
type LanguageServerNotFoundError struct { ProjectId ProjectId LanguageId LanguageId }
func NewLanguageServerNotFoundError ¶
func NewLanguageServerNotFoundError(projectId ProjectId, languageId LanguageId) *LanguageServerNotFoundError
func (LanguageServerNotFoundError) Error ¶
func (e LanguageServerNotFoundError) Error() string
type LspClientStore ¶
type LspClientStore = map[ProjectId]map[LanguageId]Client
type LspDiagnostics ¶
type LspDiagnostics = map[ProjectId]map[protocol.DocumentUri][]protocol.Diagnostic
type Process ¶
type Process interface { Start() error Stop() error ReadWriteCloser() io.ReadWriteCloser Wait() error }
func NewProcess ¶
type ProcessImpl ¶
type ProcessImpl struct {
// contains filtered or unexported fields
}
func (*ProcessImpl) ReadWriteCloser ¶
func (p *ProcessImpl) ReadWriteCloser() io.ReadWriteCloser
func (*ProcessImpl) Start ¶
func (p *ProcessImpl) Start() error
func (*ProcessImpl) Stop ¶
func (p *ProcessImpl) Stop() error
func (*ProcessImpl) Wait ¶
func (p *ProcessImpl) Wait() error
type ProjectRoot ¶
type ProjectRoot = string
type Service ¶
type Service interface { StartServer(ctx context.Context, languageId LanguageId) error StopServer(ctx context.Context, languageId LanguageId) error GetWorkspaceSymbols(ctx context.Context, query string, symbolFilter SymbolFilter) ([]SymbolInfo, error) GetDocumentOutline(ctx context.Context, file model.File) (DocumentOutline, error) NotifyDidOpen(ctx context.Context, file model.File) error NotifyDidClose(ctx context.Context, file model.File) error // TODO: check if any LSP server supports this // PullDiagnostics(ctx context.Context, params DocumentDiagnosticParams) (DocumentDiagnosticReport, error) GetDiagnostics(ctx context.Context, file model.File) ([]protocol.Diagnostic, error) CleanupProject(ctx context.Context, projectId ProjectId) error }
func NewService ¶
func NewService(languageDetector LanguageDetector, lspServerExecutables map[LanguageId]Command, diagnosticsStore *DiagnosticsStore, clientPool ClientPool) Service
type ServiceImpl ¶
type ServiceImpl struct {
// contains filtered or unexported fields
}
func (*ServiceImpl) CleanupProject ¶
func (s *ServiceImpl) CleanupProject(ctx context.Context, projectId ProjectId) error
func (*ServiceImpl) GetDiagnostics ¶
func (s *ServiceImpl) GetDiagnostics(ctx context.Context, file model.File) ([]protocol.Diagnostic, error)
func (*ServiceImpl) GetDocumentOutline ¶ added in v0.5.0
func (s *ServiceImpl) GetDocumentOutline(ctx context.Context, file model.File) (DocumentOutline, error)
func (*ServiceImpl) GetWorkspaceSymbols ¶
func (s *ServiceImpl) GetWorkspaceSymbols(ctx context.Context, query string, symbolFilter SymbolFilter) ([]SymbolInfo, error)
func (*ServiceImpl) NotifyDidClose ¶
NotifyDidClose implements Service.
func (*ServiceImpl) NotifyDidOpen ¶
NotifyDidOpen implements Service.
func (*ServiceImpl) StartServer ¶
func (s *ServiceImpl) StartServer(ctx context.Context, languageId LanguageId) error
StartServer implements Service.
func (*ServiceImpl) StopServer ¶
func (s *ServiceImpl) StopServer(ctx context.Context, languageId LanguageId) error
type SymbolFilter ¶
type SymbolFilter struct {
// contains filtered or unexported fields
}
func NewExcludeSymbolFilter ¶
func NewExcludeSymbolFilter(exclude ...protocol.SymbolKind) SymbolFilter
func NewIncludeSymbolFilter ¶
func NewIncludeSymbolFilter(include ...protocol.SymbolKind) SymbolFilter
type SymbolInfo ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.