Documentation
¶
Index ¶
- type CompletionContext
- type CompletionItem
- type Config
- type Diagnostic
- type Document
- type DocumentManager
- func (dm *DocumentManager) Close(uri string)
- func (dm *DocumentManager) ExtensionFor(uri string) *Extension
- func (dm *DocumentManager) Get(uri string) (*Document, bool)
- func (dm *DocumentManager) IsManaged(uri string) bool
- func (dm *DocumentManager) Open(uri, source string) error
- func (dm *DocumentManager) Update(uri, source string) error
- type Extension
- type HoverContext
- type Mapping
- type Position
- type Proxy
- type SourceMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompletionContext ¶
type CompletionContext struct {
Line int
Column int
Prefix string // text before cursor on current line
Source []byte // full document source
}
CompletionContext provides context for completion requests.
type CompletionItem ¶
type CompletionItem struct {
Label string
Kind int // LSP CompletionItemKind: 14=keyword, 7=class, 3=function
Detail string // short description
InsertText string // text to insert (can be snippet)
}
CompletionItem is a single completion suggestion.
type Config ¶
type Config struct {
GoplsPath string // path to gopls binary (default: "gopls")
ShadowDir string // directory for shadow .go files
Extensions []Extension // registered grammar extensions
Logger *log.Logger
}
Config configures the LSP proxy.
type Diagnostic ¶
type Diagnostic struct {
Line int
Column int
EndLine int
EndCol int
Message string
Severity int // 1=error, 2=warning, 3=info, 4=hint
}
Diagnostic is an additional diagnostic from the extension.
type DocumentManager ¶
type DocumentManager struct {
// contains filtered or unexported fields
}
func NewDocumentManager ¶
func NewDocumentManager(shadowDir string, extensions []Extension) *DocumentManager
func (*DocumentManager) Close ¶
func (dm *DocumentManager) Close(uri string)
func (*DocumentManager) ExtensionFor ¶
func (dm *DocumentManager) ExtensionFor(uri string) *Extension
func (*DocumentManager) IsManaged ¶
func (dm *DocumentManager) IsManaged(uri string) bool
func (*DocumentManager) Open ¶
func (dm *DocumentManager) Open(uri, source string) error
func (*DocumentManager) Update ¶
func (dm *DocumentManager) Update(uri, source string) error
type Extension ¶
type Extension struct {
// Name identifies this extension (e.g., "danmuji", "dingo")
Name string
// FileExtension is the file extension this handles (e.g., ".dmj", ".dingo")
FileExtension string
// Transpile converts source in the custom language to valid Go code.
// This is the only required function.
Transpile func(source []byte) (string, error)
// Completions returns completion items for the given context. Optional.
Completions func(ctx CompletionContext) []CompletionItem
// Hover returns hover documentation for the given context. Optional.
Hover func(ctx HoverContext) string
// Diagnostics returns additional diagnostics beyond what gopls provides. Optional.
Diagnostics func(source []byte) []Diagnostic
}
Extension defines what a grammar extension provides to the LSP proxy. Implement this interface and register it with the proxy to get full IDE support for your grammar's file extension.
type HoverContext ¶
type HoverContext struct {
Line int
Column int
Word string // word under cursor
Source []byte // full document source
}
HoverContext provides context for hover requests.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy sits between the editor and gopls, intercepting DSL files.
func (*Proxy) Run ¶
func (p *Proxy) Run(ctx context.Context, stdin io.ReadCloser, stdout io.WriteCloser) error
type SourceMap ¶
type SourceMap struct {
// contains filtered or unexported fields
}
SourceMap provides bidirectional position mapping between DSL source and generated Go code. Two sorted indices for O(log n) lookup.
func BuildFromDiff ¶
BuildFromDiff builds a source map by comparing source and destination line-by-line.
func NewSourceMap ¶
func NewSourceMap() *SourceMap