Documentation
¶
Index ¶
- func NodesToContent(doc Document, nodes []*sitter.Node) string
- func ReadDocument(u uri.URI) (contents []byte, err error)
- func ResolveURI(u uri.URI) (string, error)
- type Document
- type DocumentMap
- type LoadStatement
- type LoadSymbol
- type Manager
- func (m *Manager) Initialize(params *protocol.InitializeParams)
- func (m *Manager) Keys() []uri.URI
- func (m *Manager) Read(ctx context.Context, u uri.URI) (doc Document, err error)
- func (m *Manager) Remove(u uri.URI)
- func (m *Manager) Resolve(u uri.URI) (uri.URI, error)
- func (m *Manager) Write(ctx context.Context, u uri.URI, input []byte) (diags []protocol.Diagnostic, err error)
- type ManagerOpt
- type NewDocumentFunc
- type ReadDocumentFunc
- type ResolveURIFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NodesToContent ¶
func NodesToContent(doc Document, nodes []*sitter.Node) string
Returns the source content for the (assumed neighboring) nodes. If slice is nil or empty, return the entire document.
func ReadDocument ¶
func ReadDocument(u uri.URI) (contents []byte, err error)
Read the document from the given URI and return its contents. This default implementation of a ReadDocumentFunc only handles file: URIs and returns an error otherwise.
func ResolveURI ¶
func ResolveURI(u uri.URI) (string, error)
ResolveURI is the default resolver function used by the manager. It only supports file: URIs.
Types ¶
type Document ¶
type Document interface {
Input() []byte
Content(n *sitter.Node) string
ContentRange(r sitter.Range) string
Tree() *sitter.Tree
Functions() map[string]query.Signature
Symbols() []query.Symbol
Diagnostics() []protocol.Diagnostic
Loads() []LoadStatement
URI() uri.URI
Copy() Document
Close()
}
func NewDocument ¶
func NewDocument(u uri.URI, input []byte, tree *sitter.Tree) Document
type DocumentMap ¶
type DocumentMap map[uri.URI]Document
type LoadStatement ¶
type LoadStatement struct {
File string
Symbols []LoadSymbol
Range protocol.Range
Diagnostics []protocol.Diagnostic
// contains filtered or unexported fields
}
type LoadSymbol ¶
type LoadSymbol struct {
Alias, Name string
Range protocol.Range
}
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provides simplified file read/write operations for the LSP server.
func NewDocumentManager ¶
func NewDocumentManager(opts ...ManagerOpt) *Manager
func (*Manager) Initialize ¶
func (m *Manager) Initialize(params *protocol.InitializeParams)
func (*Manager) Read ¶
func (m *Manager) Read(ctx context.Context, u uri.URI) (doc Document, err error)
Read returns the contents of the file for the given URI.
If no file exists at the path or the URI is of an invalid type, an error is returned.
type ManagerOpt ¶
type ManagerOpt func(manager *Manager)
func WithNewDocumentFunc ¶
func WithNewDocumentFunc(newDocFunc NewDocumentFunc) ManagerOpt
func WithReadDocumentFunc ¶
func WithReadDocumentFunc(readDocFunc ReadDocumentFunc) ManagerOpt
func WithResolveURIFunc ¶
func WithResolveURIFunc(fn ResolveURIFunc) ManagerOpt
type NewDocumentFunc ¶
type NewDocumentFunc func(u uri.URI, input []byte, tree *sitter.Tree) Document
type ReadDocumentFunc ¶
type ReadDocumentFunc func(uri.URI) ([]byte, error)
type ResolveURIFunc ¶
type ResolveURIFunc func(uri.URI) (string, error)
Click to show internal directories.
Click to hide internal directories.