Documentation ¶
Index ¶
- Constants
- func Max[T protocol.UInteger | int](a, b T) T
- func Min[T protocol.UInteger | int](a, b T) T
- func Overlap(rangea, rangeb protocol.Range) bool
- func RunServe(cli *cli.Context) error
- func ServeFlags() []cli.Flag
- type CodeDiagnostic
- type CodeFix
- type CodeSuggesion
- type Coordinate
- type CursorContext
- type DocumentAction
- type FeedBackProvider
- type LspServer
- type LspServerConfiguration
- type Severity
Constants ¶
View Source
const ( SeverityHigh = iota SeverityMedium SeverityLow )
View Source
const ( DocumentOpen = iota DocumentSave DocumentChange )
View Source
const ( LangSrvNameParamName = "name" LangSrvNameEnvVarName = "LANGSRV_NAME" LangSrvHostParamName = "host" LangSrvHostEnvVarName = "LANGSRV_HOST" LangSrvSrcDirParamName = "srcdir" LangSrvSrcDirEnvVarName = "LANGSRV_SRC_DIR" LangSrvGitLabAPITokenParamName = "gitlab-api-token" LangSrvGitLabAPITokenEnvVarName = "LANGSRV_GITLAB_API_TOKEN" LangSrvPortParamName = "port" LangSrvPortEnvVarName = "LANGSRV_PORT" )
Variables ¶
This section is empty.
Functions ¶
func ServeFlags ¶
func ServeFlags() []cli.Flag
Types ¶
type CodeDiagnostic ¶
type CodeDiagnostic struct { Origin, Message, File string // the file that contains the issue Severity Severity // severity of the issue (most IDEs will provide color codes) Coordinate Coordinate // source code coordiates of the issue Fix *CodeFix // Fix (Optional) }
CodeDiagnostic objects are useful to highlight issues in the IDE. If you know how to fix an issue, you can provide a Fix with the Diagnostic.
func (*CodeDiagnostic) ToCodeAction ¶
func (feedback *CodeDiagnostic) ToCodeAction() protocol.CodeAction
func (*CodeDiagnostic) ToLspDiagnostic ¶
func (feedback *CodeDiagnostic) ToLspDiagnostic() protocol.Diagnostic
type CodeFix ¶
type CodeFix struct { Hint string // A small description to describe the fix. Replacement string // The actual replacement for the code captured by the Diagnostic. }
CodeFix describes a fix for a given issue and is, hence, always attached to a CodeDiagnostic object.
type CodeSuggesion ¶
CodeSuggesion objects are useful to provide code suggestions in the IDE. Most IDEs will provide a drop-down menu from which the user can make a selection.
func NewCodeSuggestion ¶
func NewCodeSuggestion(label, content, description string) *CodeSuggesion
func (*CodeSuggesion) ToCompletionItem ¶
func (s *CodeSuggesion) ToCompletionItem() protocol.CompletionItem
type Coordinate ¶
type Coordinate struct {
StartLine, EndLine, StartCol, EndCol int
}
Coordinate describes the position of a finding
type CursorContext ¶
type CursorContext struct {
Before, After string
}
CursorContext defines the text before and after the cursors the window width
func (*CursorContext) Empty ¶
func (c *CursorContext) Empty() bool
func (*CursorContext) String ¶
func (c *CursorContext) String() string
type DocumentAction ¶
type DocumentAction int
type FeedBackProvider ¶
type FeedBackProvider interface { // Set the client name and version to be used in user-agent string SetClientNameAndVersion(clientName, clientVersion string) // ProvideDiagnosticsForFile is a callback to pass diagnostics to the // language server. The results will be highlighted in the IDE. ProvideDiagnosticsForFile(file string, action DocumentAction) ([]*CodeDiagnostic, error) // ProvideDiagnosticsForContent is identical to // ProvideDiagnosticsForFile with the only difference that it runs on // the content and captures in-memory change. ProvideDiagnosticsForContent(filePath, content string, action DocumentAction) ([]*CodeDiagnostic, error) ProvideCodeSuggesions(filePath string, context *CursorContext) ([]*CodeSuggesion, error) }
FeedBackProvider is the (only) interface new language servers have to implement.
type LspServer ¶
type LspServer struct { Configuration *LspServerConfiguration Actions []protocol.CodeAction FeedbackProvider map[string]FeedBackProvider CursorContext *CursorContext }
func NewLspServer ¶
func NewLspServer(cfg *LspServerConfiguration) *LspServer
func (*LspServer) AddFeedbackProvider ¶
func (s *LspServer) AddFeedbackProvider(name string, provider FeedBackProvider)
func (*LspServer) CodeActionReset ¶
func (s *LspServer) CodeActionReset()
func (*LspServer) UpdateCursorContext ¶
type LspServerConfiguration ¶
type LspServerConfiguration struct { Stdio bool SrcDir, Token, Name, URL string Port, CursorWindowWidthBefore, CursorWindowWidthAfter uint }
func NewLspServerConfiguration ¶
func NewLspServerConfiguration(name, srcDir, url, token string, cursorBefore, cursorAfter, port uint) (*LspServerConfiguration, error)
func (*LspServerConfiguration) ServerURL ¶
func (cfg *LspServerConfiguration) ServerURL() string
func (*LspServerConfiguration) String ¶
func (cfg *LspServerConfiguration) String() string
type Severity ¶
type Severity int
func (Severity) ToLspSeverity ¶
func (severity Severity) ToLspSeverity() protocol.DiagnosticSeverity
Click to show internal directories.
Click to hide internal directories.