protocol

package
v7.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package protocol 协议内容的定义

Index

Constants

View Source
const (
	FoldingRangeKindComment = "comment" // Folding range for a comment
	FoldingRangeKindImports = "imports" // Folding range for a imports or includes
	FoldingRangeKindRegion  = "region"  // Folding range for a region (e.g. `#region`)
)

代码关折叠块的种类

View Source
const (
	TraceValueOff     = "off"
	TraceValueMessage = "message"
	TraceValueVerbose = "verbose"
)

SetTraceParams.Value 可用的值

View Source
const (
	TokenFormatRelative = "relative"
)

TokenFormat支持的常量

Variables

This section is empty.

Functions

func IsValidTraceValue added in v7.2.0

func IsValidTraceValue(v string) bool

IsValidTraceValue 是否是一个有效的 TraceValue

Types

type API added in v7.2.0

type API struct {
	Location   core.Location `json:"location"`
	Method     string        `json:"method"`
	Path       string        `json:"path"`
	Tags       []string      `json:"tags,omitempty"`
	Servers    []string      `json:"servers,omitempty"`
	Deprecated string        `json:"deprecated,omitempty"`
	Summary    string        `json:"summary,omitempty"`
}

API 描述单个 API 的信息

type APIDocDetectParams added in v7.2.1

type APIDocDetectParams struct {
	// The text document.
	TextDocument TextDocumentIdentifier `json:"textDocument"`

	// Recursive 是否检测子目录的内容
	Recursive bool `json:"recursive,omitempty"`
}

APIDocDetectParams apidoc/detect 的请求参数

type APIDocDetectResult added in v7.2.1

type APIDocDetectResult struct {
	Error string `json:"error,omitempty"` // 如果生成配置文件有误,返回此字段。
}

APIDocDetectResult apidoc/detect 的返回参数

type APIDocOutline added in v7.2.0

type APIDocOutline struct {
	WorkspaceFolder

	Err      string `json:"err,omitempty"`      // 表示项目解析出问题,此值不为空,则除去 WorkspaceFolder 和 Err 之外的字段都是无意义的。
	NoConfig bool   `json:"noConfig,omitempty"` // 没有配置文件的相关信息

	Location core.Location   `json:"location,omitempty"`
	Title    string          `json:"title,omitempty"`
	Version  string          `json:"version,omitempty"`
	Tags     []*APIDocTag    `json:"tags,omitempty"`
	Servers  []*APIDocServer `json:"servers,omitempty"`

	APIs []*API `json:"apis,omitempty"`
}

APIDocOutline 传递给客户端的文档摘要

这不是一个标准的 LSP 数据结构,由 apidoc 自定义, 用户由服务端向客户端发送当前的文档结构信息。

func BuildAPIDocOutline added in v7.2.0

func BuildAPIDocOutline(f WorkspaceFolder, doc *ast.APIDoc) *APIDocOutline

BuildAPIDocOutline 根据 ast.APIDoc 构建 APIDoc

如果 doc 不是一个有效的文档内容,比如是零值,则返回 nil。 如果是 doc.APIs 中的某一个元素的 path 未必须,则会忽略此记录的显示。

type APIDocServer added in v7.2.0

type APIDocServer struct {
	ID  string `json:"id"`
	URL string `json:"url"`
}

APIDocServer 文档支持的服务器

type APIDocTag added in v7.2.0

type APIDocTag struct {
	ID    string `json:"id"`
	Title string `json:"title"`
}

APIDocTag 文档支持的标签属性

type CancelParams

type CancelParams struct {
	// The request id to cancel.
	ID *jsonrpc.ID
}

CancelParams The base protocol offers support for request cancellation

https://microsoft.github.io/language-server-protocol/specifications/specification-current/#cancelRequest

type ClientCapabilities

type ClientCapabilities struct {
	// Workspace specific client capabilities.
	Workspace *WorkspaceClientCapabilities `json:"workspace,omitempty"`

	// Text document specific client capabilities.
	TextDocument TextDocumentClientCapabilities `json:"textDocument,omitempty"`

	// Experimental client capabilities.
	Experimental interface{} `json:"experimental,omitempty"`
}

ClientCapabilities 客户端的兼容列表

type Command added in v7.1.0

type Command struct {
	// Title of the command, like `save`.
	Title string `json:"title"`

	// The identifier of the actual command handler.
	Command string `json:"command"`

	// Arguments that the command handler should be invoked with.
	Arguments []interface{} `json:"arguments,omitempty"`
}

Command represents a reference to a command

Provides a title which will be used to represent a command in the UI. Commands are identified by a string identifier. The recommended way to handle commands is to implement their execution on the server side if the client and server provides the corresponding capabilities. Alternatively the tool extension code could handle the command. The protocol currently doesn’t specify a set of well-known commands.

type CompletionClientCapabilities added in v7.1.0

type CompletionClientCapabilities struct {
	// Whether completion supports dynamic registration.
	DynamicRegistration bool `json:"dynamicRegistration,omitempty"`

	// The client supports the following `CompletionItem` specific
	// capabilities.
	CompletionItem struct {
		// The client supports snippets as insert text.
		//
		// A snippet can define tab stops and placeholders with `$1`, `$2`
		// and `${3:foo}`. `$0` defines the final tab stop, it defaults to
		// the end of the snippet. Placeholders with equal identifiers are linked,
		// that is typing in one will update others too.
		SnippetSupport bool `json:"snippetSupport,omitempty"`

		// The client supports commit characters on a completion item.
		CommitCharactersSupport bool `json:"commitCharactersSupport,omitempty"`

		// The client supports the following content formats for the documentation
		// property. The order describes the preferred format of the client.
		DocumentationFormat []MarkupKind `json:"documentationFormat,omitempty"`

		// The client supports the deprecated property on a completion item.
		DeprecatedSupport bool `json:"deprecatedSupport,omitempty"`

		// The client supports the preselect property on a completion item.
		PreselectSupport bool `json:"preselectSupport,omitempty"`

		// Client supports the tag property on a completion item. Clients supporting
		// tags have to handle unknown tags gracefully. Clients especially need to
		// preserve unknown tags when sending a completion item back to the server in
		// a resolve call.
		//
		// @since 3.15.0
		TagSupport *struct {
			// The tags supported by the client.
			ValueSet []CompletionItemTag `json:"valueSet"`
		} `json:"tagSupport,omitempty"`

		// Client support insert replace edit to control different behavior if a
		// completion item is inserted in the text or should replace text.
		//
		// @since 3.16.0 - Proposed state
		InsertReplaceSupport bool `json:"insertReplaceSupport,omitempty"`

		// Client supports to resolve `additionalTextEdits` in the `completionItem/resolve`
		// request. So servers can postpone computing them.
		//
		// @since 3.16.0 - Proposed state
		ResolveAdditionalTextEditsSupport bool `json:"resolveAdditionalTextEditsSupport,omitempty"`
	} `json:"completionItem,omitempty"`

	CompletionItemKind struct {
		// The completion item kind values the client supports. When this
		// property exists the client also guarantees that it will
		// handle values outside its set gracefully and falls back
		// to a default value when unknown.
		//
		// If this property is not present the client only supports
		// the completion items kinds from `Text` to `Reference` as defined in
		// the initial version of the protocol.
		ValueSet []CompletionItemKind `json:"valueSet,omitempty"`
	} `json:"completionItemKind,omitempty"`

	// The client supports to send additional context information for a
	// `textDocument/completion` request.
	ContextSupport bool `json:"contextSupport,omitempty"`
}

CompletionClientCapabilities 客户端有关自动完成所支持的功能定义

type CompletionContext added in v7.1.0

type CompletionContext struct {
	// How the completion was triggered.
	TriggerKind CompletionTriggerKind `json:"triggerKind"`

	// The trigger character (a single character) that has trigger code complete.
	// Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`
	TriggerCharacter string `json:"triggerCharacter,omitempty"`
}

CompletionContext contains additional information about the context in which a completion request is triggered.

type CompletionItem added in v7.1.0

type CompletionItem struct {
	// The label of this completion item. By default also the text that is
	// inserted when selecting this completion.
	Label string `json:"label"`

	// The kind of this completion item. Based of the kind
	// an icon is chosen by the editor. The standardized set
	// of available values is defined in `CompletionItemKind`.
	Kind CompletionItemKind `json:"kind,omitempty"`

	// Tags for this completion item.
	//
	// @since 3.15.0
	Tags []CompletionItemTag `json:"tags,omitempty"`

	// A human-readable string with additional information
	// about this item, like type or symbol information.
	Detail string `json:"detail,omitempty"`

	// A human-readable string that represents a doc-comment.
	Documentation *MarkupContent `json:"documentation,omitempty"`

	// Select this item when showing.
	//
	// *Note* that only one completion item can be selected and that the
	// tool / client decides which item that is. The rule is that the *first*
	// item of those that match best is selected.
	Preselect bool `json:"preselect,omitempty"`

	// A string that should be used when comparing this item
	// with other items. When `falsy` the label is used.
	SortText string `json:"sortText,omitempty"`

	// A string that should be used when filtering a set of
	// completion items. When `falsy` the label is used.
	FilterText string `json:"filterText,omitempty"`

	// A string that should be inserted into a document when selecting
	// this completion. When `falsy` the label is used.
	//
	// The `insertText` is subject to interpretation by the client side.
	// Some tools might not take the string literally. For example
	// VS Code when code complete is requested in this example `con<cursor position>`
	// and a completion item with an `insertText` of `console` is provided it
	// will only insert `sole`. Therefore it is recommended to use `textEdit` instead
	// since it avoids additional client side interpretation.
	InsertText string `json:"insertText,omitempty"`

	// The format of the insert text. The format applies to both the `insertText` property
	// and the `newText` property of a provided `textEdit`. If omitted defaults to
	// `InsertTextFormat.PlainText`.
	InsertTextFormat InsertTextFormat `json:"insertTextFormat,omitempty"`

	// An edit which is applied to a document when selecting this completion. When an edit is provided the value of
	// `insertText` is ignored.
	//
	// *Note:* The range of the edit must be a single line range and it must contain the position at which completion
	// has been requested.
	TextEdit *TextEdit `json:"textEdit,omitempty"`

	// An optional array of additional text edits that are applied when
	// selecting this completion. Edits must not overlap (including the same insert position)
	// with the main edit nor with themselves.
	//
	// Additional text edits should be used to change text unrelated to the current cursor position
	// (for example adding an import statement at the top of the file if the completion item will
	// insert an unqualified type).
	AdditionalTextEdits []TextEdit `json:"additionalTextEdits,omitempty"`

	// An optional set of characters that when pressed while this completion is active will accept it first and
	// then type that character. *Note* that all commit characters should have `length=1` and that superfluous
	// characters will be ignored.
	CommitCharacters []string `json:"commitCharacters,omitempty"`

	// An optional command that is executed *after* inserting this completion. *Note* that
	// additional modifications to the current document should be described with the
	// additionalTextEdits-property.
	Command *Command `json:"command,omitempty"`

	// A data entry field that is preserved on a completion item between
	// a completion and a completion resolve request.
	Data interface{} `json:"data,omitempty"`
}

CompletionItem completion items

type CompletionItemKind

type CompletionItemKind int

CompletionItemKind the kind of a completion entry.

const (
	CompletionItemKindText CompletionItemKind = iota + 1
	CompletionItemKindMethod
	CompletionItemKindFunction
	CompletionItemKindConstructor
	CompletionItemKindField
	CompletionItemKindVariable
	CompletionItemKindClass
	CompletionItemKindInterface
	CompletionItemKindModule
	CompletionItemKindProperty
	CompletionItemKindUnit
	CompletionItemKindValue
	CompletionItemKindEnum
	CompletionItemKindKeyword
	CompletionItemKindSnippet
	CompletionItemKindColor
	CompletionItemKindFile
	CompletionItemKindReference
	CompletionItemKindFolder
	CompletionItemKindEnumMember
	CompletionItemKindConstant
	CompletionItemKindStruct
	CompletionItemKindEvent
	CompletionItemKindOperator
	CompletionItemKindTypeParameter
)

CompletionItemKind 的各类枚举值

type CompletionItemTag added in v7.1.0

type CompletionItemTag int

CompletionItemTag are extra annotations that tweak the rendering of a completion item.

@since 3.15.0

const CompletionItemTagDeprecated CompletionItemTag = 1

CompletionItemTagDeprecated render a completion as obsolete, usually using a strike-out.

type CompletionList added in v7.1.0

type CompletionList struct {
	// This list it not complete. Further typing should result in recomputing this list.
	IsIncomplete bool `json:"isIncomplete"`

	// The completion items.
	Items []CompletionItem `json:"items"`
}

CompletionList represents a collection of [completion items](#CompletionItem) to be presented in the editor.

func (*CompletionList) MarshalJSON added in v7.2.0

func (l *CompletionList) MarshalJSON() ([]byte, error)

MarshalJSON 允许在 hover 为空值是返回 null

type CompletionOptions

type CompletionOptions struct {
	WorkDoneProgressOptions

	// The server provides support to resolve additional
	// information for a completion item.
	ResolveProvider bool `json:"resolveProvider,omitempty"`

	// The characters that trigger completion automatically.
	TriggerCharacters []string `json:"triggerCharacters,omitempty"`

	// The list of all possible characters that commit a completion. This field can be used
	// if clients don't support individual commit characters per completion item. See
	// `ClientCapabilities.textDocument.completion.completionItem.commitCharactersSupport`.
	//
	// If a server provides both `allCommitCharacters` and commit characters on an individual
	// completion item the ones on the completion item win.
	//
	// @since 3.2.0
	AllCommitCharacters []string `json:"allCommitCharacters,omitempty"`
}

CompletionOptions 服务端返回的有关对自动完成支持性的描述

type CompletionParams added in v7.1.0

type CompletionParams struct {
	TextDocumentPositionParams
	WorkDoneProgressParams
	PartialResultParams
	// The completion context. This is only available if the client specifies
	// to send this using `ClientCapabilities.textDocument.completion.contextSupport === true`
	Context *CompletionContext `json:"context,omitempty"`
}

CompletionParams textDocument/completion 的参数

type CompletionTriggerKind added in v7.1.0

type CompletionTriggerKind int

CompletionTriggerKind how a completion was triggered

const (
	// Completion was triggered by typing an identifier (24x7 code
	// complete), manual invocation (e.g Ctrl+Space) or via API.
	CompletionTriggerKindInvoked CompletionTriggerKind = 1

	// Completion was triggered by a trigger character specified by
	// the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
	CompletionTriggerKindTriggerCharacter CompletionTriggerKind = 2

	// Completion was re-triggered as the current completion list is incomplete.
	CompletionTriggerKindTriggerForIncompleteCompletions CompletionTriggerKind = 3
)

CompletionTriggerKind 定义的常量

type DefinitionClientCapabilities added in v7.2.0

type DefinitionClientCapabilities struct {
	// Whether definition supports dynamic registration.
	DynamicRegistration bool `json:"dynamicRegistration,omitempty"`

	// The client supports additional metadata in the form of definition links.
	//
	// @since 3.14.0
	LinkSupport bool `json:"linkSupport,omitempty"`
}

DefinitionClientCapabilities 客户端对 textDocument/definition 的支持情况

type DefinitionParams added in v7.2.0

DefinitionParams textDocument/definition 服务的客户端请求参数

type Diagnostic

type Diagnostic struct {
	// The range at which the message applies.
	Range core.Range `json:"range"`

	// The diagnostic's severity. Can be omitted. If omitted it is up to the
	// client to interpret diagnostics as error, warning, info or hint.
	Severity DiagnosticSeverity `json:"severity,omitempty"`

	// The diagnostic's code, which might appear in the user interface.
	Code string `json:"code,omitempty"`

	// A human-readable string describing the source of this
	// diagnostic, e.g. 'typescript' or 'super lint'.
	Source string `json:"source,omitempty"`

	// The diagnostic's message.
	Message string `json:"message"`

	// Additional metadata about the diagnostic.
	//
	// @since 3.15.0
	Tags []DiagnosticTag `json:"tags,omitempty"`

	// An array of related diagnostic information, e.g. when symbol-names within
	// a scope collide all definitions can be marked via this property.
	RelatedInformation []core.RelatedInformation `json:"relatedInformation,omitempty"`
}

Diagnostic represents a diagnostic,such as a compiler error or warning. Diagnostic objects are only valid in the scope of a resource.

https://microsoft.github.io/language-server-protocol/specifications/specification-current/#diagnostic

type DiagnosticSeverity

type DiagnosticSeverity int

DiagnosticSeverity 错误级别

const (
	DiagnosticSeverityError       DiagnosticSeverity = iota + 1 // Reports an error
	DiagnosticSeverityWarning                                   // Reports a warning
	DiagnosticSeverityInformation                               // Reports an information
	DiagnosticSeverityHint                                      // Reports a hint
)

DiagnosticSeverity 可用的常量

type DiagnosticTag

type DiagnosticTag int

DiagnosticTag the diagnostic tags.

@since 3.15.0

const (
	// DiagnosticTagUnnecessary unused or unnecessary code.
	//
	// Clients are allowed to render diagnostics with this tag faded out instead of having
	// an error squiggle.
	DiagnosticTagUnnecessary DiagnosticTag = 1

	// DiagnosticTagDeprecated deprecated or obsolete code.
	//
	// Clients are allowed to rendered diagnostics with this tag strike through.
	DiagnosticTagDeprecated DiagnosticTag = 2
)

DiagnosticTag 可用的常量列表

type DidChangeTextDocumentParams

type DidChangeTextDocumentParams struct {
	// The document that did change. The version number points
	// to the version after all provided content changes have been applied.
	TextDocument VersionedTextDocumentIdentifier `json:"textDocument"`

	// The actual content changes. The content changes describe single state changes
	// to the document. So if there are two content changes c1 (at array index 0) and
	// c2 (at array index 1) for a document in state S then c1 moves the document from
	// S to S' and c2 from S' to S”. So c1 is computed on the state S and c2 is computed
	// on the state S'.
	//
	// To mirror the content of a document using change events use the following approach:
	// - start with the same initial content
	// - apply the 'textDocument/didChange' notifications in the order you recevie them.
	// - apply the `TextDocumentContentChangeEvent`s in a single notification in the order
	//   you receive them.
	ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"`
}

DidChangeTextDocumentParams textDocument/didChange 的参数

func (*DidChangeTextDocumentParams) Blocks added in v7.1.0

func (p *DidChangeTextDocumentParams) Blocks() []core.Block

Blocks 返回 core.Block 的列表

type DidChangeWorkspaceFoldersParams

type DidChangeWorkspaceFoldersParams struct {
	// The actual workspace folder change event.
	Event WorkspaceFoldersChangeEvent `json:"event"`
}

DidChangeWorkspaceFoldersParams workspace/didChangeWorkspaceFolders 参数

type DocumentFilter

type DocumentFilter struct {
	// A language id, like `typescript`.
	Language string `json:"language,omitempty"`

	// A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
	Scheme string `json:"scheme,omitempty"`

	// A glob pattern, like `*.{ts,js}`.
	//
	// Glob patterns can have the following syntax:
	// - `*` to match one or more characters in a path segment
	// - `?` to match on one character in a path segment
	// - `**` to match any number of path segments, including none
	// - `{}` to group conditions (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files)
	// - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)
	// - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)
	Pattern string `json:"pattern,omitempty"`
}

DocumentFilter denotes a document through properties like language, scheme or pattern. An example is a filter that applies to TypeScript files on disk. Another example is a filter the applies to JSON files with name package.json:

{ language: 'typescript', scheme: 'file' }
{ language: 'json', pattern: '**/package.json' }

type DocumentSelector

type DocumentSelector []DocumentFilter

DocumentSelector is the combination of one or more document filters

type FailureHandlingKind

type FailureHandlingKind string

FailureHandlingKind 定义出错后的处理方式

const (

	// FailureHandlingKindAbort applying the workspace change is simply aborted
	// if one of the changes provided fails.
	// All operations executed before the failing operation stay executed.
	FailureHandlingKindAbort FailureHandlingKind = "abort"

	// FailureHandlingKindTransactional all operations are executed transactionally.
	// That means they either all succeed or no changes at all are applied to the workspace.
	FailureHandlingKindTransactional FailureHandlingKind = "transactional"

	// FailureHandlingKindTextOnlyTransactional if the workspace edit contains only textual
	// file changes they are executed transactionally. If resource changes (create, rename or delete file)
	// are part of the change the failure handling strategy is abort.
	FailureHandlingKindTextOnlyTransactional FailureHandlingKind = "textOnlyTransactional"

	// FailureHandlingKindUndo The client tries to undo the operations already executed.
	// But there is no guarantee that this succeeds.
	FailureHandlingKindUndo FailureHandlingKind = "undo"
)

type FoldingRange added in v7.1.0

type FoldingRange struct {
	// The zero-based line number from where the folded range starts.
	StartLine int `json:"startLine"`

	// The zero-based character offset from where the folded range starts. If not defined, defaults to the length of the start line.
	//
	// 0 是一个合法的值,所以只能采用指针类型表示空值。
	StartCharacter *int `json:"startCharacter,omitempty"`

	// The zero-based line number where the folded range ends.
	EndLine int `json:"endLine"`

	// The zero-based character offset before the folded range ends. If not defined, defaults to the length of the end line.
	//
	// 0 是一个合法的值,所以只能采用指针类型表示空值。
	EndCharacter *int `json:"endCharacter,omitempty"`

	// Describes the kind of the folding range such as `comment` or `region`. The kind
	// is used to categorize folding ranges and used by commands like 'Fold all comments'. See
	// [FoldingRangeKind](#FoldingRangeKind) for an enumeration of standardized kinds.
	Kind string `json:"kind,omitempty"`
}

FoldingRange represents a folding range

func BuildFoldingRange added in v7.1.0

func BuildFoldingRange(base xmlenc.Base, lineFoldingOnly bool) FoldingRange

BuildFoldingRange 根据参数构建 FoldingRange 实例

type FoldingRangeClientCapabilities added in v7.1.0

type FoldingRangeClientCapabilities struct {
	// Whether implementation supports dynamic registration for folding range providers. If this is set to `true`
	// the client supports the new `(FoldingRangeProviderOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions)`
	// return value for the corresponding server capability as well.
	DynamicRegistration bool `json:"dynamicRegistration,omitempty"`

	// The maximum number of folding ranges that the client prefers to receive per document. The value serves as a
	// hint, servers are free to follow the limit.
	RangeLimit int `json:"rangeLimit,omitempty"`

	// If set, the client signals that it only supports folding complete lines. If set, client will
	// ignore specified `startCharacter` and `endCharacter` properties in a FoldingRange.
	LineFoldingOnly bool `json:"lineFoldingOnly,omitempty"`
}

FoldingRangeClientCapabilities 定义客户对代码拆叠功能的支持情况

type FoldingRangeParams added in v7.1.0

type FoldingRangeParams struct {
	WorkDoneProgressParams
	PartialResultParams

	// The text document.
	TextDocument TextDocumentIdentifier `json:"textDocument"`
}

FoldingRangeParams 由用户传递的 textDocument/foldingRange 参数

type Hover

type Hover struct {
	// The hover's content
	Contents MarkupContent `json:"contents"`

	// An optional range is a range inside a text document
	// that is used to visualize a hover, e.g. by changing the background color.
	Range core.Range `json:"range"`
}

Hover textDocument/hover 的返回结果

func (*Hover) MarshalJSON added in v7.2.0

func (h *Hover) MarshalJSON() ([]byte, error)

MarshalJSON 允许在 hover 为空值是返回 null

type HoverCapabilities added in v7.1.0

type HoverCapabilities struct {
	// Whether hover supports dynamic registration.
	DynamicRegistration bool `json:"dynamicRegistration,omitempty"`

	// The client supports the follow content formats for the content
	// property. The order describes the preferred format of the client.
	ContentFormat []MarkupKind `json:"contentFormat,omitempty"`
}

HoverCapabilities 客户端有关 hover 功能的描述

type HoverParams

HoverParams textDocument/hover 发送的参数

type InitializationOptions

type InitializationOptions struct {
	// 客户端的本地化 ID
	//
	// 服务端会根据此值决定提示内容如何翻译。
	// 如果提交的 Locale 无法识别或是服务端不支持,
	// 则会采用服务端的默认值,即 locale.DefaultLocaleID。
	Locale string `json:"locale,omitempty"`
}

InitializationOptions 用户需要提交的自定义初始化参数

type InitializeParams

type InitializeParams struct {
	WorkDoneProgressParams

	// The process Id of the parent process that started
	// the server. Is null if the process has not been started by another process.
	// If the parent process is not alive then the server should exit (see exit notification) its process.
	ProcessID int `json:"processId,omitempty"`

	// The rootPath of the workspace. Is null if no folder is open.
	//
	// @deprecated in favour of rootUri.
	RootPath string `json:"rootPath,omitempty"`

	// The rootUri of the workspace. Is null if no
	// folder is open. If both `rootPath` and `rootUri` are set `rootUri` wins.
	RootURI core.URI `json:"rootUri,omitempty"`

	// User provided initialization options.
	InitializationOptions *InitializationOptions `json:"initializationOptions,omitempty"`

	// The capabilities provided by the client (editor or tool)
	Capabilities ClientCapabilities `json:"capabilities"`

	// The workspace folders configured in the client when the server starts.
	// This property is only available if the client supports workspace folders.
	// It can be `null` if the client supports workspace folders but none are
	// configured.
	//
	// Since 3.6.0
	//
	// 在客户端支持工作区的情况下,RootURI 和 RootPath 的内容为 WorkspaceFolders 的第一个元素,
	// 否则 WorkspaceFolders 为空。
	// RootURI 和 RootPath 的区别在于,RootURI 会带协议,比如 file:///path 而 RootPath 为 /path
	WorkspaceFolders []WorkspaceFolder `json:"workspaceFolders,omitempty"`

	// Information about the client
	//
	// @since 3.15.0
	ClientInfo *ServerInfo `json:"clientInfo,omitempty"`
}

InitializeParams 初始化请求的参数

func (*InitializeParams) Folders

func (p *InitializeParams) Folders() []WorkspaceFolder

Folders 获取客户端当前打开的所有项目

type InitializeResult

type InitializeResult struct {
	// The capabilities the language server provides.
	Capabilities ServerCapabilities `json:"capabilities"`

	// Information about the server.
	//
	// @since 3.15.0
	ServerInfo *ServerInfo `json:"serverInfo,omitempty"`
}

InitializeResult initialize 服务的返回结构

type InitializedParams

type InitializedParams struct{}

InitializedParams initialized 服务传递的参数

type InsertTextFormat added in v7.1.0

type InsertTextFormat int

InsertTextFormat defines whether the insert text in a completion item should be interpreted as plain text or a snippet.

const (
	// The primary text to be inserted is treated as a plain string.
	InsertTextFormatPlainText InsertTextFormat = 1

	// The primary text to be inserted is treated as a snippet.
	//
	// A snippet can define tab stops and placeholders with `$1`, `$2`
	// and `${3:foo}`. `$0` defines the final tab stop, it defaults to
	// the end of the snippet. Placeholders with equal identifiers are linked,
	// that is typing in one will update others too.
	InsertTextFormatSnippet InsertTextFormat = 2
)

InsertTextFormat 的可用常量

type LogMessageParams

type LogMessageParams struct {
	// The message type. See {@link MessageType}
	Type MessageType `json:"type"`

	// The actual message
	Message string `json:"message"`
}

LogMessageParams window/logMessage 传递的参数

type LogTraceParams added in v7.2.0

type LogTraceParams struct {
	// The message to be logged.
	Message string `json:"message"`

	// Additional information that can be computed if the `trace` configuration is set to `'verbose'`
	Verbose string `json:"verbose,omitempty"`
}

LogTraceParams $/logTrace 服务端下发参数

func BuildLogTrace added in v7.2.0

func BuildLogTrace(trace, message, verbose string) *LogTraceParams

BuildLogTrace 生成 logTrace 对象

type MarkupContent

type MarkupContent struct {
	// The type of the Markup
	Kind MarkupKind `json:"kind"`

	// The content itself
	Value string `json:"value"`
}

MarkupContent literal represents a string value which content is interpreted base on its kind flag. Currently the protocol supports `plaintext` and `markdown` as markup kinds.

If the kind is `markdown` then the value can contain fenced code blocks like in GitHub issues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting

Here is an example how such a string can be constructed using JavaScript / TypeScript: ```typescript

let markdown: MarkdownContent = {
 kind: MarkupKind.Markdown,
	value: [
		'# Header',
		'Some text',
		'```typescript',
		'someCode();',
		'```'
	].join('\n')
};

```

*Please Note* that clients might sanitize the return markdown. A client could decide to remove HTML from the markdown to avoid script execution.

type MarkupKind

type MarkupKind string

MarkupKind describes the content type that a client supports in various result literals like `Hover`, `ParameterInfo` or `CompletionItem`.

Please note that `MarkupKinds` must not start with a `$`. This kinds are reserved for internal usage.

const (
	// MarkupKindPlainText plain text is supported as a content format
	MarkupKindPlainText MarkupKind = "plaintext"

	// MarkupKindMarkdown markdown is supported as a content format
	MarkupKindMarkdown MarkupKind = "markdown"
)

type MessageType

type MessageType int

MessageType 传递的消息类型

const (
	MessageTypeError   MessageType = iota + 1 // An error message.
	MessageTypeWarning                        // A warning message.
	MessageTypeInfo                           // An information message.
	MessageTypeLog                            // A log message.
)

MessageType 可能的值

type PartialResultParams added in v7.1.0

type PartialResultParams struct {
	// An optional token that a server can use to report
	// partial results (e.g. streaming) to the client
	PartialResultToken ProgressToken `json:"partialResultToken,omitempty"`
}

PartialResultParams a parameter literal used to pass a partial result token

type ProgressToken

type ProgressToken interface{}

ProgressToken type ProgressToken = number | string;

type PublishDiagnosticsClientCapabilities added in v7.1.0

type PublishDiagnosticsClientCapabilities struct {
	// Whether the clients accepts diagnostics with related information.
	RelatedInformation bool `json:"relatedInformation,omitempty"`

	// Client supports the tag property to provide meta data about a diagnostic.
	// Clients supporting tags have to handle unknown tags gracefully.
	//
	// @since 3.15.0
	TagSupport struct {
		// The tags supported by the client.
		ValueSet []DiagnosticTag `json:"valueSet,omitempty"`
	} `json:"tagSupport,omitempty"`

	// Whether the client interprets the version property of the
	// `textDocument/publishDiagnostics` notification's parameter.
	//
	// @since 3.15.0
	VersionSupport bool `json:"versionSupport,omitempty"`
}

PublishDiagnosticsClientCapabilities 客户端有关错误信息的支持情况定义

type PublishDiagnosticsParams

type PublishDiagnosticsParams struct {
	// The URI for which diagnostic information is reported.
	URI core.URI `json:"uri"`

	// An array of diagnostic information items.
	Diagnostics []Diagnostic `json:"diagnostics"`
}

PublishDiagnosticsParams textDocument/publishDiagnostics 事件发送的参数

func NewPublishDiagnosticsParams added in v7.2.0

func NewPublishDiagnosticsParams(uri core.URI) *PublishDiagnosticsParams

NewPublishDiagnosticsParams 声明空的 PublishDiagnosticsParams 对象

func (*PublishDiagnosticsParams) AppendDiagnostic added in v7.2.0

func (p *PublishDiagnosticsParams) AppendDiagnostic(err *core.Error, msgType core.MessageType)

AppendDiagnostic 将 core.Message 添加至诊断数据

type ReferenceClientCapabilities added in v7.2.0

type ReferenceClientCapabilities struct {
	// Whether references supports dynamic registration.
	DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
}

ReferenceClientCapabilities 客户端对 textDocument/references 的支持情况

type ReferenceParams added in v7.2.0

type ReferenceParams struct {
	TextDocumentPositionParams
	WorkDoneProgressParams
	PartialResultParams
	Context struct {
		// Include the declaration of the current symbol.
		IncludeDeclaration bool `json:"includeDeclaration"`
	} `json:"context"`
}

ReferenceParams textDocument/references 的请求参数

type ResourceOperationKind

type ResourceOperationKind string

ResourceOperationKind the kind of resource operations supported by the client.

const (
	// ResourceOperationKindCreate supports creating new files and folders.
	ResourceOperationKindCreate ResourceOperationKind = "create"

	// ResourceOperationKindRename supports renaming existing files and folders.
	ResourceOperationKindRename ResourceOperationKind = "rename"

	// ResourceOperationKindDelete supports deleting existing files and folders.
	ResourceOperationKindDelete ResourceOperationKind = "delete"
)

type SaveOptions

type SaveOptions struct {
	// The client is supposed to include the content on save.
	IncludeText bool `json:"includeText,omitempty"`
}

SaveOptions Save options.

type SemanticTokens added in v7.1.0

type SemanticTokens struct {
	// An optional result id. If provided and clients support delta updating
	// the client will include the result id in the next semantic token request.
	// A server can then instead of computing all semantic tokens again simply
	// send a delta.
	ResultID string `json:"resultId,omitempty"`

	// The actual tokens.
	Data []int `json:"data"`
}

SemanticTokens textDocument/semanticTokens 返回参数

type SemanticTokensClientCapabilities added in v7.1.0

type SemanticTokensClientCapabilities struct {
	// Whether implementation supports dynamic registration. If this is set to `true`
	// the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`
	// return value for the corresponding server capability as well.
	DynamicRegistration bool `json:"dynamicRegistration,omitempty"`

	// Which requests the client supports and might send to the server.
	Requests struct {
		// The client will send the `textDocument/semanticTokens/range` request if
		// the server provides a corresponding handler.
		//
		// bool | {}
		Range interface{} `json:"range,omitempty"`

		// The client will send the `textDocument/semanticTokens/full` request if
		// the server provides a corresponding handler.
		//
		// bool | SemanticTokensOptions
		Full interface{} `json:"full,omitempty"`
	} `json:"requests"`

	// The token types that the client supports.
	TokenTypes []string `json:"tokenTypes"`

	// The token modifiers that the client supports.
	TokenModifiers []string `json:"tokenModifiers"`

	// The formats the clients supports.
	Formats []TokenFormat `json:"formats"`
}

SemanticTokensClientCapabilities 客户端的支持情况

type SemanticTokensLegend added in v7.1.0

type SemanticTokensLegend struct {
	// The token types a server uses.
	TokenTypes []string `json:"tokenTypes"`

	// The token modifiers a server uses.
	TokenModifiers []string `json:"tokenModifiers"`
}

type SemanticTokensOptions added in v7.1.0

type SemanticTokensOptions struct {
	WorkDoneProgressOptions
	// The legend used by the server
	Legend SemanticTokensLegend `json:"legend"`

	// Server supports providing semantic tokens for a specific range of a document.
	//
	// bool | {}
	Range interface{} `json:"range,omitempty"`

	// Server supports providing semantic tokens for a full document.
	//
	// bool | SemanticTokensOptions
	Full interface{} `json:"full,omitempty"`
}

SemanticTokensOptions 服务端有关 SemanticTokens 的支持情况

type SemanticTokensParams added in v7.1.0

type SemanticTokensParams struct {
	WorkDoneProgressParams
	PartialResultParams

	// The text document.
	TextDocument TextDocumentIdentifier `json:"textDocument"`
}

SemanticTokensParams textDocument/semanticTokens 入口参数

type SemanticTokensRegistrationOptions added in v7.1.0

type SemanticTokensRegistrationOptions struct {
	TextDocumentRegistrationOptions
	SemanticTokensOptions
	StaticRegistrationOptions
}

SemanticTokensRegistrationOptions textDocument/semanticTokens/full 返回参数

type ServerCapabilities

type ServerCapabilities struct {
	// Defines how text documents are synced.
	//
	// Is either a detailed structure defining each notification or
	// for backwards compatibility the TextDocumentSyncKind number.
	// If omitted it defaults to `TextDocumentSyncKind.None`.
	//
	// ServerCapabilitiesTextDocumentSyncOptions | TextDocumentSyncKind;
	TextDocumentSync *ServerCapabilitiesTextDocumentSyncOptions `json:"textDocumentSync"`

	// The server provides completion support.
	CompletionProvider *CompletionOptions `json:"completionProvider,omitempty"`

	// The server provides hover support.
	HoverProvider bool `json:"hoverProvider,omitempty"`

	// The server provides goto definition support.
	DefinitionProvider bool `json:"definitionProvider,omitempty"`

	// The server provides find references support.
	ReferencesProvider bool `json:"referencesProvider,omitempty"`

	// The server provides folding provider support.
	//
	// Since 3.10.0
	FoldingRangeProvider bool `json:"foldingRangeProvider,omitempty"`

	// The server provides folding provider support.
	//
	// Since 3.16.0
	//
	// SemanticTokensOptions | SemanticTokensRegistrationOptions
	SemanticTokensProvider interface{} `json:"semanticTokensProvider,omitempty"`

	// The server provides workspace symbol support.
	WorkspaceSymbolProvider bool `json:"workspaceSymbolProvider,omitempty"`

	// Workspace specific server capabilities
	Workspace *WorkspaceProvider `json:"workspace,omitempty"`

	// Experimental server capabilities.
	Experimental interface{} `json:"experimental,omitempty"`
}

ServerCapabilities 服务端的兼容列表

type ServerCapabilitiesTextDocumentSyncOptions

type ServerCapabilitiesTextDocumentSyncOptions struct {
	// Open and close notifications are sent to the server.
	// If omitted open close notification should not be sent.
	OpenClose bool `json:"openClose,omitempty"`

	// Change notifications are sent to the server. See TextDocumentSyncKind.None, TextDocumentSyncKind.Full
	// and TextDocumentSyncKind.Incremental. If omitted it defaults to TextDocumentSyncKind.None.
	Change TextDocumentSyncKind `json:"change,omitempty"`
}

ServerCapabilitiesTextDocumentSyncOptions 服务端对文档同步的支持项

type ServerInfo

type ServerInfo struct {
	Name    string `json:"name"`
	Version string `json:"version,omitempty"`
}

ServerInfo 终端的信息,同时用于描述服务和客户端。

@since 3.15.0

type SetTraceParams added in v7.2.0

type SetTraceParams struct {
	// The new value that should be assigned to the trace setting.
	Value string `json:"value"`
}

SetTraceParams $/setTrace 入口参数

type StaticRegistrationOptions

type StaticRegistrationOptions struct {
	// The id used to register the request. The id can be used to deregister
	// the request again. See also Registration#id.
	ID string `json:"id,omitempty"`
}

StaticRegistrationOptions static registration options to be returned in the initialize request.

type TextDocumentClientCapabilities

type TextDocumentClientCapabilities struct {
	Synchronization *struct {
		// Whether text document synchronization supports dynamic registration.
		DynamicRegistration bool `json:"dynamicRegistration,omitempty"`

		// The client supports sending will save notifications.
		WillSave bool `json:"willSave,omitempty"`

		// The client supports sending a will save request and
		// waits for a response providing text edits which will
		// be applied to the document before it is saved.
		WillSaveWaitUntil bool `json:"willSaveWaitUntil,omitempty"`

		// The client supports did save notifications.
		DidSave bool `json:"didSave,omitempty"`
	} `json:"synchronization,omitempty"`

	// Capabilities specific to the `textDocument/completion`
	Completion *CompletionClientCapabilities `json:"completion,omitempty"`

	// Capabilities specific to the `textDocument/hover`
	Hover *HoverCapabilities `json:"hover,omitempty"`

	// Capabilities specific to the `textDocument/textDocument/semanticTokens/*`
	SemanticTokens *SemanticTokensClientCapabilities `json:"semanticTokens,omitempty"`

	// Capabilities specific to the `textDocument/references` request.
	References *ReferenceClientCapabilities `json:"references,omitempty"`

	// Capabilities specific to the `textDocument/definition`.
	//
	// Since 3.14.0
	Definition *DefinitionClientCapabilities `json:"definition,omitempty"`

	// Capabilities specific to `textDocument/publishDiagnostics`.
	PublishDiagnostics *PublishDiagnosticsClientCapabilities `json:"publishDiagnostics,omitempty"`

	// Capabilities specific to `textDocument/foldingRange` requests.
	//
	// Since 3.10.0
	FoldingRange *FoldingRangeClientCapabilities `json:"foldingRange,omitempty"`
}

TextDocumentClientCapabilities text document specific client capabilities.

type TextDocumentContentChangeEvent

type TextDocumentContentChangeEvent struct {
	// The range of the document that changed.
	Range *core.Range `json:"range,omitempty"`

	// The new text for the provided range.
	// The new text of the whole document.
	//
	// 如果没有 Range 内容,表示整个文档内容;否则表示 Range 表示的内容
	Text string `json:"text"`

	// The optional length of the range that got replaced.
	//
	// @deprecated use range instead.
	RangeLength int `json:"rangeLength,omitempty"`
}

TextDocumentContentChangeEvent an event describing a change to a text document. If range and rangeLength are omitted the new text is considered to be the full content of the document.

type TextDocumentIdentifier

type TextDocumentIdentifier struct {
	// The text document's URI.
	URI core.URI `json:"uri"`
}

TextDocumentIdentifier text documents are identified using a URI. On the protocol level, URIs are passed as strings. The corresponding JSON structure looks like this:

type TextDocumentPositionParams

type TextDocumentPositionParams struct {
	// The text document.
	TextDocument TextDocumentIdentifier `json:"textDocument"`

	// The position inside the text document.
	Position core.Position `json:"position"`
}

TextDocumentPositionParams a parameter literal used in requests to pass a text document and a position inside that document.

type TextDocumentRegistrationOptions

type TextDocumentRegistrationOptions struct {
	// A document selector to identify the scope of the registration. If set to null
	// the document selector provided on the client side will be used.
	DocumentSelector DocumentSelector `json:"documentSelector,omitempty"`
}

TextDocumentRegistrationOptions General text document registration options

type TextDocumentSyncKind

type TextDocumentSyncKind int

TextDocumentSyncKind defines how the host (editor) should sync document changes to the language server.

const (
	// TextDocumentSyncKindNone documents should not be synced at all.
	TextDocumentSyncKindNone TextDocumentSyncKind = iota

	// TextDocumentSyncKindFull documents are synced by always sending the full content of the document.
	TextDocumentSyncKindFull

	// TextDocumentSyncKindIncremental documents are synced by sending the full content on open.
	// After that only incremental updates to the document are send.
	TextDocumentSyncKindIncremental
)

type TextEdit added in v7.1.0

type TextEdit struct {
	// The range of the text document to be manipulated. To insert
	// text into a document create a range where start === end.
	Range core.Range `json:"range"`

	// The string to be inserted. For delete operations use an empty string.
	NewText string `json:"newText"`
}

TextEdit a textual edit applicable to a text document.

type TokenFormat added in v7.1.0

type TokenFormat string

TokenFormat the protocol defines an additional token format capability to allow future extensions of the format

The only format that is currently specified is relative expressing that the tokens are described using relative positions

type VersionedTextDocumentIdentifier

type VersionedTextDocumentIdentifier struct {
	TextDocumentIdentifier

	// The version number of this document. If a versioned text document identifier
	// is sent from the server to the client and the file is not open in the editor
	// (the server has not received an open notification before) the server can send
	// `null` to indicate that the version is known and the content on disk is the
	// truth (as speced with document content ownership).
	//
	// The version number of a document will increase after each change, including
	// undo/redo. The number doesn't need to be consecutive.
	Version int `json:"version,omitempty"`
}

VersionedTextDocumentIdentifier an identifier to denote a specific version of a text document.

type WorkDoneProgressOptions

type WorkDoneProgressOptions struct {
	WorkDoneProgress bool `json:"workDoneProgress,omitempty"`
}

WorkDoneProgressOptions options to signal work done progress support in server capabilities.

https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workDoneProgressOptions

type WorkDoneProgressParams

type WorkDoneProgressParams struct {
	// An optional token that a server can use to report work done progress.
	WorkDoneToken ProgressToken `json:"workDoneToken,omitempty"`
}

WorkDoneProgressParams a parameter literal used to pass a work done progress token.

type WorkspaceClientCapabilities added in v7.2.0

type WorkspaceClientCapabilities struct {
	// The client supports applying batch edits to the workspace by supporting
	// the request 'workspace/applyEdit'
	ApplyEdit bool `json:"applyEdit,omitempty"`

	// Capabilities specific to `WorkspaceEdit`s
	WorkspaceEdit *WorkspaceEditClientCapabilities `json:"workspaceEdit,omitempty"`

	// Capabilities specific to the `workspace/didChangeConfiguration` notification.
	DidChangeConfiguration *struct {
		// Whether formatting supports dynamic registration.
		DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
	} `json:"didChangeConfiguration,omitempty"`

	// Capabilities specific to the `workspace/didChangeWatchedFiles` notification.
	DidChangeWatchedFiles *struct {
		// Whether formatting supports dynamic registration.
		DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
	} `json:"didChangeWatchedFiles,omitempty"`

	// The client has support for workspace folders.
	//
	// Since 3.6.0
	WorkspaceFolders bool `json:"workspaceFolders,omitempty"`

	// The client supports `workspace/configuration` requests.
	//
	// Since 3.6.0
	Configuration bool `json:"configuration,omitempty"`
}

WorkspaceClientCapabilities 客户有关 workspace 的支持情况

type WorkspaceEditClientCapabilities

type WorkspaceEditClientCapabilities struct {
	// The client supports versioned document changes in `WorkspaceEdit`s
	DocumentChanges bool `json:"documentChanges,omitempty"`

	// The resource operations the client supports. Clients should at least
	// support 'create', 'rename' and 'delete' files and folders.
	//
	// @since 3.13.0
	ResourceOperations []ResourceOperationKind `json:"resourceOperations,omitempty"`

	// The failure handling strategy of a client if applying the workspace edit fails.
	//
	// @since 3.13.0
	FailureHandling FailureHandlingKind `json:"failureHandling,omitempty"`
}

WorkspaceEditClientCapabilities the capabilities of a workspace edit has evolved over the time. Clients can describe their support using the following client capability

type WorkspaceFolder

type WorkspaceFolder struct {
	// The associated URI for this workspace folder.
	URI core.URI `json:"uri"`

	// The name of the workspace folder. Used to refer to this
	// workspace folder in the user interface.
	Name string `json:"name"`
}

WorkspaceFolder 项目文件夹

func (WorkspaceFolder) Contains added in v7.2.0

func (f WorkspaceFolder) Contains(path core.URI) bool

Contains 当前 WorkspaceFolder 是否包含了 uri 这个文件或是目录

type WorkspaceFoldersChangeEvent

type WorkspaceFoldersChangeEvent struct {
	// The array of added workspace folders
	Added []WorkspaceFolder `json:"added"`

	// The array of the removed workspace folders
	Removed []WorkspaceFolder `json:"removed"`
}

WorkspaceFoldersChangeEvent the workspace folder change event.

type WorkspaceFoldersServerCapabilities

type WorkspaceFoldersServerCapabilities struct {
	// The server has support for workspace folders
	Supported bool `json:"supported,omitempty"`

	// Whether the server wants to receive workspace folder
	// change notifications.
	//
	// If a string is provided, the string is treated as an ID
	// under which the notification is registered on the client
	// side. The ID can be used to unregister for these events
	// using the `client/unregisterCapability` request.
	//
	// string | boolean;
	ChangeNotifications bool `json:"changeNotifications,omitempty"`
}

WorkspaceFoldersServerCapabilities 服务端有关项目文件夹的支持情况

type WorkspaceProvider added in v7.1.0

type WorkspaceProvider struct {
	// The server supports workspace folder.
	//
	// Since 3.6.0
	WorkspaceFolders *WorkspaceFoldersServerCapabilities `json:"workspaceFolders,omitempty"`
}

WorkspaceProvider 服务端有关 workspace 的支持情况

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL