Documentation ¶
Index ¶
- type Client
- func (p Client) ApplyEdit(ctx context.Context, params *lsp.ApplyWorkspaceEditParams) (result *lsp.ApplyWorkspaceEditResponse, err error)
- func (p Client) Configuration(ctx context.Context, params *lsp.ConfigurationParams) (result []interface{}, err error)
- func (p Client) LogMessage(ctx context.Context, params *lsp.LogMessageParams) (err error)
- func (p Client) Progress(ctx context.Context, params *lsp.ProgressParams) (err error)
- func (p Client) PublishDiagnostics(ctx context.Context, params *lsp.PublishDiagnosticsParams) (err error)
- func (p Client) RegisterCapability(ctx context.Context, params *lsp.RegistrationParams) (err error)
- func (p Client) ShowMessage(ctx context.Context, params *lsp.ShowMessageParams) (err error)
- func (p Client) ShowMessageRequest(ctx context.Context, params *lsp.ShowMessageRequestParams) (result *lsp.MessageActionItem, err error)
- func (p Client) Telemetry(ctx context.Context, params interface{}) (err error)
- func (p Client) UnregisterCapability(ctx context.Context, params *lsp.UnregistrationParams) (err error)
- func (p Client) WorkDoneProgressCreate(ctx context.Context, params *lsp.WorkDoneProgressCreateParams) (err error)
- func (p Client) WorkspaceFolders(ctx context.Context) (result []lsp.WorkspaceFolder, err error)
- type DiagnosticCache
- type Document
- func (d *Document) Apply(r *lsp.Range, with string)
- func (d *Document) Delete(fromLine, fromCol, toLine, toCol int)
- func (d *Document) DeleteLines(i, j int)
- func (d *Document) Insert(line, col int, lines []string)
- func (d *Document) InsertLines(i int, withLines []string)
- func (d *Document) Len() (line, col int)
- func (d *Document) LineLengths() (lens []int)
- func (d *Document) Overwrite(fromLine, fromCol, toLine, toCol int, lines []string)
- func (d *Document) Replace(with string)
- func (d *Document) String() string
- type DocumentContents
- func (dc *DocumentContents) Apply(uri string, changes []lsp.TextDocumentContentChangeEvent) (d *Document, err error)
- func (dc *DocumentContents) Delete(uri string)
- func (dc *DocumentContents) Get(uri string) (d *Document, ok bool)
- func (dc *DocumentContents) Set(uri string, d *Document)
- func (dc *DocumentContents) URIs() (uris []string)
- type Server
- func (p *Server) CodeAction(ctx context.Context, params *lsp.CodeActionParams) (result []lsp.CodeAction, err error)
- func (p *Server) CodeLens(ctx context.Context, params *lsp.CodeLensParams) (result []lsp.CodeLens, err error)
- func (p *Server) CodeLensRefresh(ctx context.Context) (err error)
- func (p *Server) CodeLensResolve(ctx context.Context, params *lsp.CodeLens) (result *lsp.CodeLens, err error)
- func (p *Server) ColorPresentation(ctx context.Context, params *lsp.ColorPresentationParams) (result []lsp.ColorPresentation, err error)
- func (p *Server) Completion(ctx context.Context, params *lsp.CompletionParams) (result *lsp.CompletionList, err error)
- func (p *Server) CompletionResolve(ctx context.Context, params *lsp.CompletionItem) (result *lsp.CompletionItem, err error)
- func (p *Server) Declaration(ctx context.Context, params *lsp.DeclarationParams) (result []lsp.Location, err error)
- func (p *Server) Definition(ctx context.Context, params *lsp.DefinitionParams) (result []lsp.Location, err error)
- func (p *Server) DidChange(ctx context.Context, params *lsp.DidChangeTextDocumentParams) (err error)
- func (p *Server) DidChangeConfiguration(ctx context.Context, params *lsp.DidChangeConfigurationParams) (err error)
- func (p *Server) DidChangeWatchedFiles(ctx context.Context, params *lsp.DidChangeWatchedFilesParams) (err error)
- func (p *Server) DidChangeWorkspaceFolders(ctx context.Context, params *lsp.DidChangeWorkspaceFoldersParams) (err error)
- func (p *Server) DidClose(ctx context.Context, params *lsp.DidCloseTextDocumentParams) (err error)
- func (p *Server) DidCreateFiles(ctx context.Context, params *lsp.CreateFilesParams) (err error)
- func (p *Server) DidDeleteFiles(ctx context.Context, params *lsp.DeleteFilesParams) (err error)
- func (p *Server) DidOpen(ctx context.Context, params *lsp.DidOpenTextDocumentParams) (err error)
- func (p *Server) DidRenameFiles(ctx context.Context, params *lsp.RenameFilesParams) (err error)
- func (p *Server) DidSave(ctx context.Context, params *lsp.DidSaveTextDocumentParams) (err error)
- func (p *Server) DocumentColor(ctx context.Context, params *lsp.DocumentColorParams) (result []lsp.ColorInformation, err error)
- func (p *Server) DocumentHighlight(ctx context.Context, params *lsp.DocumentHighlightParams) (result []lsp.DocumentHighlight, err error)
- func (p *Server) DocumentLink(ctx context.Context, params *lsp.DocumentLinkParams) (result []lsp.DocumentLink, err error)
- func (p *Server) DocumentLinkResolve(ctx context.Context, params *lsp.DocumentLink) (result *lsp.DocumentLink, err error)
- func (p *Server) DocumentSymbol(ctx context.Context, params *lsp.DocumentSymbolParams) (result []interface{}, err error)
- func (p *Server) ExecuteCommand(ctx context.Context, params *lsp.ExecuteCommandParams) (result interface{}, err error)
- func (p *Server) Exit(ctx context.Context) (err error)
- func (p *Server) FoldingRanges(ctx context.Context, params *lsp.FoldingRangeParams) (result []lsp.FoldingRange, err error)
- func (p *Server) Formatting(ctx context.Context, params *lsp.DocumentFormattingParams) (result []lsp.TextEdit, err error)
- func (p *Server) Hover(ctx context.Context, params *lsp.HoverParams) (result *lsp.Hover, err error)
- func (p *Server) Implementation(ctx context.Context, params *lsp.ImplementationParams) (result []lsp.Location, err error)
- func (p *Server) IncomingCalls(ctx context.Context, params *lsp.CallHierarchyIncomingCallsParams) (result []lsp.CallHierarchyIncomingCall, err error)
- func (p *Server) Initialize(ctx context.Context, params *lsp.InitializeParams) (result *lsp.InitializeResult, err error)
- func (p *Server) Initialized(ctx context.Context, params *lsp.InitializedParams) (err error)
- func (p *Server) LinkedEditingRange(ctx context.Context, params *lsp.LinkedEditingRangeParams) (result *lsp.LinkedEditingRanges, err error)
- func (p *Server) LogTrace(ctx context.Context, params *lsp.LogTraceParams) (err error)
- func (p *Server) Moniker(ctx context.Context, params *lsp.MonikerParams) (result []lsp.Moniker, err error)
- func (p *Server) OnTypeFormatting(ctx context.Context, params *lsp.DocumentOnTypeFormattingParams) (result []lsp.TextEdit, err error)
- func (p *Server) OutgoingCalls(ctx context.Context, params *lsp.CallHierarchyOutgoingCallsParams) (result []lsp.CallHierarchyOutgoingCall, err error)
- func (p *Server) PrepareCallHierarchy(ctx context.Context, params *lsp.CallHierarchyPrepareParams) (result []lsp.CallHierarchyItem, err error)
- func (p *Server) PrepareRename(ctx context.Context, params *lsp.PrepareRenameParams) (result *lsp.Range, err error)
- func (p *Server) RangeFormatting(ctx context.Context, params *lsp.DocumentRangeFormattingParams) (result []lsp.TextEdit, err error)
- func (p *Server) References(ctx context.Context, params *lsp.ReferenceParams) (result []lsp.Location, err error)
- func (p *Server) Rename(ctx context.Context, params *lsp.RenameParams) (result *lsp.WorkspaceEdit, err error)
- func (p *Server) Request(ctx context.Context, method string, params interface{}) (result interface{}, err error)
- func (p *Server) SemanticTokensFull(ctx context.Context, params *lsp.SemanticTokensParams) (result *lsp.SemanticTokens, err error)
- func (p *Server) SemanticTokensFullDelta(ctx context.Context, params *lsp.SemanticTokensDeltaParams) (result interface{}, err error)
- func (p *Server) SemanticTokensRange(ctx context.Context, params *lsp.SemanticTokensRangeParams) (result *lsp.SemanticTokens, err error)
- func (p *Server) SemanticTokensRefresh(ctx context.Context) (err error)
- func (p *Server) SetTrace(ctx context.Context, params *lsp.SetTraceParams) (err error)
- func (p *Server) ShowDocument(ctx context.Context, params *lsp.ShowDocumentParams) (result *lsp.ShowDocumentResult, err error)
- func (p *Server) Shutdown(ctx context.Context) (err error)
- func (p *Server) SignatureHelp(ctx context.Context, params *lsp.SignatureHelpParams) (result *lsp.SignatureHelp, err error)
- func (p *Server) Symbols(ctx context.Context, params *lsp.WorkspaceSymbolParams) (result []lsp.SymbolInformation, err error)
- func (p *Server) TypeDefinition(ctx context.Context, params *lsp.TypeDefinitionParams) (result []lsp.Location, err error)
- func (p *Server) WillCreateFiles(ctx context.Context, params *lsp.CreateFilesParams) (result *lsp.WorkspaceEdit, err error)
- func (p *Server) WillDeleteFiles(ctx context.Context, params *lsp.DeleteFilesParams) (result *lsp.WorkspaceEdit, err error)
- func (p *Server) WillRenameFiles(ctx context.Context, params *lsp.RenameFilesParams) (result *lsp.WorkspaceEdit, err error)
- func (p *Server) WillSave(ctx context.Context, params *lsp.WillSaveTextDocumentParams) (err error)
- func (p *Server) WillSaveWaitUntil(ctx context.Context, params *lsp.WillSaveTextDocumentParams) (result []lsp.TextEdit, err error)
- func (p *Server) WorkDoneProgressCancel(ctx context.Context, params *lsp.WorkDoneProgressCancelParams) (err error)
- type SourceMapCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Log *zap.Logger Target lsp.Client SourceMapCache *SourceMapCache DiagnosticCache *DiagnosticCache }
Client is responsible for rewriting messages that are originated from gopls, and are sent to the client.
Since `gopls` is working on Go files, and this is the `templ` LSP, the job of this code is to rewrite incoming requests to adjust the file name from `*_templ.go` to `*.templ`, and to remap the char positions where required.
func NewClient ¶
func NewClient(log *zap.Logger, cache *SourceMapCache, diagnosticCache *DiagnosticCache) (c *Client, init func(lsp.Client))
func (Client) ApplyEdit ¶
func (p Client) ApplyEdit(ctx context.Context, params *lsp.ApplyWorkspaceEditParams) (result *lsp.ApplyWorkspaceEditResponse, err error)
func (Client) Configuration ¶
func (Client) LogMessage ¶
func (Client) PublishDiagnostics ¶
func (Client) RegisterCapability ¶
func (Client) ShowMessage ¶
func (Client) ShowMessageRequest ¶
func (p Client) ShowMessageRequest(ctx context.Context, params *lsp.ShowMessageRequestParams) (result *lsp.MessageActionItem, err error)
func (Client) UnregisterCapability ¶
func (Client) WorkDoneProgressCreate ¶
func (Client) WorkspaceFolders ¶
type DiagnosticCache ¶ added in v0.2.501
type DiagnosticCache struct {
// contains filtered or unexported fields
}
func NewDiagnosticCache ¶ added in v0.2.501
func NewDiagnosticCache() *DiagnosticCache
func (*DiagnosticCache) AddGoDiagnostics ¶ added in v0.2.501
func (dc *DiagnosticCache) AddGoDiagnostics(uri string, templDiagnostics []lsp.Diagnostic) []lsp.Diagnostic
func (*DiagnosticCache) AddTemplDiagnostics ¶ added in v0.2.501
func (dc *DiagnosticCache) AddTemplDiagnostics(uri string, goDiagnostics []lsp.Diagnostic) []lsp.Diagnostic
func (*DiagnosticCache) ClearTemplDiagnostics ¶ added in v0.2.501
func (dc *DiagnosticCache) ClearTemplDiagnostics(uri string)
type Document ¶
func (*Document) DeleteLines ¶ added in v0.2.232
func (*Document) InsertLines ¶ added in v0.2.232
func (*Document) LineLengths ¶ added in v0.2.232
type DocumentContents ¶ added in v0.2.198
type DocumentContents struct {
// contains filtered or unexported fields
}
func (*DocumentContents) Apply ¶ added in v0.2.198
func (dc *DocumentContents) Apply(uri string, changes []lsp.TextDocumentContentChangeEvent) (d *Document, err error)
Apply changes to the document from the client, and return a list of change requests to send back to the client.
func (*DocumentContents) Delete ¶ added in v0.2.198
func (dc *DocumentContents) Delete(uri string)
Delete a document from memory.
func (*DocumentContents) Get ¶ added in v0.2.198
func (dc *DocumentContents) Get(uri string) (d *Document, ok bool)
Get the contents of a document.
func (*DocumentContents) Set ¶ added in v0.2.198
func (dc *DocumentContents) Set(uri string, d *Document)
Set the contents of a document.
func (*DocumentContents) URIs ¶ added in v0.2.198
func (dc *DocumentContents) URIs() (uris []string)
type Server ¶
type Server struct { Log *zap.Logger Target lsp.Server SourceMapCache *SourceMapCache DiagnosticCache *DiagnosticCache TemplSource *DocumentContents GoSource map[string]string }
Server is responsible for rewriting messages that are originated from the text editor, and need to be sent to gopls.
Since the editor is working on `templ` files, and `gopls` works on Go files, the job of this code is to rewrite incoming requests to adjust the file names from `*.templ` to `*_templ.go` and to remap the line/character positions in the `templ` files to their corresponding locations in the Go file.
This allows gopls to operate as usual.
This code also rewrites the responses back from gopls to do the inverse operation - to put the file names back, and readjust any character positions.
func NewServer ¶
func NewServer(log *zap.Logger, target lsp.Server, cache *SourceMapCache, diagnosticCache *DiagnosticCache) (s *Server)
func (*Server) CodeAction ¶
func (p *Server) CodeAction(ctx context.Context, params *lsp.CodeActionParams) (result []lsp.CodeAction, err error)
func (*Server) CodeLensResolve ¶
func (*Server) ColorPresentation ¶
func (p *Server) ColorPresentation(ctx context.Context, params *lsp.ColorPresentationParams) (result []lsp.ColorPresentation, err error)
func (*Server) Completion ¶
func (p *Server) Completion(ctx context.Context, params *lsp.CompletionParams) (result *lsp.CompletionList, err error)
func (*Server) CompletionResolve ¶
func (p *Server) CompletionResolve(ctx context.Context, params *lsp.CompletionItem) (result *lsp.CompletionItem, err error)
func (*Server) Declaration ¶
func (*Server) Definition ¶
func (*Server) DidChangeConfiguration ¶
func (*Server) DidChangeWatchedFiles ¶
func (*Server) DidChangeWorkspaceFolders ¶
func (*Server) DidCreateFiles ¶
func (*Server) DidDeleteFiles ¶
func (*Server) DidRenameFiles ¶
func (*Server) DocumentColor ¶
func (p *Server) DocumentColor(ctx context.Context, params *lsp.DocumentColorParams) (result []lsp.ColorInformation, err error)
func (*Server) DocumentHighlight ¶
func (p *Server) DocumentHighlight(ctx context.Context, params *lsp.DocumentHighlightParams) (result []lsp.DocumentHighlight, err error)
func (*Server) DocumentLink ¶
func (p *Server) DocumentLink(ctx context.Context, params *lsp.DocumentLinkParams) (result []lsp.DocumentLink, err error)
func (*Server) DocumentLinkResolve ¶
func (p *Server) DocumentLinkResolve(ctx context.Context, params *lsp.DocumentLink) (result *lsp.DocumentLink, err error)
func (*Server) DocumentSymbol ¶
func (*Server) ExecuteCommand ¶
func (*Server) FoldingRanges ¶
func (p *Server) FoldingRanges(ctx context.Context, params *lsp.FoldingRangeParams) (result []lsp.FoldingRange, err error)
func (*Server) Formatting ¶
func (*Server) Implementation ¶
func (*Server) IncomingCalls ¶
func (p *Server) IncomingCalls(ctx context.Context, params *lsp.CallHierarchyIncomingCallsParams) (result []lsp.CallHierarchyIncomingCall, err error)
func (*Server) Initialize ¶
func (p *Server) Initialize(ctx context.Context, params *lsp.InitializeParams) (result *lsp.InitializeResult, err error)
func (*Server) Initialized ¶
func (*Server) LinkedEditingRange ¶
func (p *Server) LinkedEditingRange(ctx context.Context, params *lsp.LinkedEditingRangeParams) (result *lsp.LinkedEditingRanges, err error)
func (*Server) OnTypeFormatting ¶
func (*Server) OutgoingCalls ¶
func (p *Server) OutgoingCalls(ctx context.Context, params *lsp.CallHierarchyOutgoingCallsParams) (result []lsp.CallHierarchyOutgoingCall, err error)
func (*Server) PrepareCallHierarchy ¶
func (p *Server) PrepareCallHierarchy(ctx context.Context, params *lsp.CallHierarchyPrepareParams) (result []lsp.CallHierarchyItem, err error)
func (*Server) PrepareRename ¶
func (*Server) RangeFormatting ¶
func (*Server) References ¶
func (*Server) Rename ¶
func (p *Server) Rename(ctx context.Context, params *lsp.RenameParams) (result *lsp.WorkspaceEdit, err error)
func (*Server) SemanticTokensFull ¶
func (p *Server) SemanticTokensFull(ctx context.Context, params *lsp.SemanticTokensParams) (result *lsp.SemanticTokens, err error)
func (*Server) SemanticTokensFullDelta ¶
func (*Server) SemanticTokensRange ¶
func (p *Server) SemanticTokensRange(ctx context.Context, params *lsp.SemanticTokensRangeParams) (result *lsp.SemanticTokens, err error)
func (*Server) SemanticTokensRefresh ¶
func (*Server) ShowDocument ¶
func (p *Server) ShowDocument(ctx context.Context, params *lsp.ShowDocumentParams) (result *lsp.ShowDocumentResult, err error)
func (*Server) SignatureHelp ¶
func (p *Server) SignatureHelp(ctx context.Context, params *lsp.SignatureHelpParams) (result *lsp.SignatureHelp, err error)
func (*Server) Symbols ¶
func (p *Server) Symbols(ctx context.Context, params *lsp.WorkspaceSymbolParams) (result []lsp.SymbolInformation, err error)
func (*Server) TypeDefinition ¶
func (*Server) WillCreateFiles ¶
func (p *Server) WillCreateFiles(ctx context.Context, params *lsp.CreateFilesParams) (result *lsp.WorkspaceEdit, err error)
func (*Server) WillDeleteFiles ¶
func (p *Server) WillDeleteFiles(ctx context.Context, params *lsp.DeleteFilesParams) (result *lsp.WorkspaceEdit, err error)
func (*Server) WillRenameFiles ¶
func (p *Server) WillRenameFiles(ctx context.Context, params *lsp.RenameFilesParams) (result *lsp.WorkspaceEdit, err error)
func (*Server) WillSaveWaitUntil ¶
func (*Server) WorkDoneProgressCancel ¶
type SourceMapCache ¶
type SourceMapCache struct {
// contains filtered or unexported fields
}
SourceMapCache is a cache of .templ file URIs to the source map.
func NewSourceMapCache ¶
func NewSourceMapCache() *SourceMapCache
NewSourceMapCache creates a cache of .templ file URIs to the source map.
func (*SourceMapCache) Delete ¶
func (fc *SourceMapCache) Delete(uri string)
func (*SourceMapCache) Get ¶
func (fc *SourceMapCache) Get(uri string) (m *parser.SourceMap, ok bool)
func (*SourceMapCache) Set ¶
func (fc *SourceMapCache) Set(uri string, m *parser.SourceMap)
func (*SourceMapCache) URIs ¶ added in v0.2.198
func (fc *SourceMapCache) URIs() (uris []string)