Documentation ¶
Overview ¶
Package langserver is a language server for Go that adheres to the Language Server Protocol (LSP).
Index ¶
Constants ¶
const HasAlias = true
Variables ¶
This section is empty.
Functions ¶
func NewHandler ¶
NewHandler creates a Go language server handler.
Types ¶
type Config ¶
type Config struct { // DisableFuncSnippet enables the returning of argument snippets on `func` // completions, eg. func(foo string, arg2 bar). Requires code complete // to be enabled. // // Defaults to true if not specified. DisableFuncSnippet bool // EnableGlobalCache enable global cache when hover, reference, definition. Can be overridden by InitializationOptions. // // Defaults to "always" if not specified GlobalCacheStyle string // DiagnosticsEnabled enables handling of diagnostics // // Defaults to false if not specified. DiagnosticsStyle string // FormatStyle format style // // Defaults to "gofmt" if not secified FormatStyle string // GoimportsLocalPrefix sets the local prefix (comma-separated string) that goimports will use // // Defaults to empty string if not specified. GoimportsLocalPrefix string // EnhanceSignatureHelp enhance the signature help with return result. // // Defaults to false EnhanceSignatureHelp bool // BuildTags controls build tag constraints and will be passed to build flags. // // Defaults to empty BuildTags []string }
Config adjusts the behaviour of go-langserver. Please keep in sync with InitializationOptions in the README.
func NewDefaultConfig ¶
func NewDefaultConfig() Config
NewDefaultConfig returns the default config. See the field comments for the defaults.
func (Config) Apply ¶
func (c Config) Apply(o *InitializationOptions) Config
Apply sets the corresponding field in c for each non-nil field in o.
type DiagnosticsStyleEnum ¶
type DiagnosticsStyleEnum string
type FilterType ¶
type FilterType string
const ( FilterExported FilterType = "exported" FilterDir FilterType = "dir" )
type HandlerCommon ¶
type HandlerCommon struct {
// contains filtered or unexported fields
}
HandlerCommon contains functionality that both the build and lang handlers need. They do NOT share the memory of this HandlerCommon struct; it is just common functionality. (Unlike HandlerCommon, HandlerShared is shared in-memory.)
func (*HandlerCommon) CheckReady ¶
func (h *HandlerCommon) CheckReady() error
CheckReady returns an error if the handler has been shut down.
func (*HandlerCommon) ShutDown ¶
func (h *HandlerCommon) ShutDown()
ShutDown marks this server as being shut down and causes all future calls to checkReady to return an error.
type HandlerShared ¶
type HandlerShared struct {
// contains filtered or unexported fields
}
HandlerShared contains data structures that a build server and its wrapped lang server may share in memory.
func (*HandlerShared) FilePath ¶
func (h *HandlerShared) FilePath(uri lsp.DocumentURI) string
func (*HandlerShared) View ¶
func (h *HandlerShared) View() source.View
type InitializationOptions ¶
type InitializationOptions struct { // DisableFuncSnippet is an optional version of Config.DisableFuncSnippet DisableFuncSnippet *bool `json:"disableFuncSnippet"` // DiagnosticsEnabled enables handling of diagnostics // // Defaults to false if not specified. DiagnosticsStyle *string `json:"diagnosticsStyle"` // EnableGlobalCache enable global cache when hover, reference, definition. Can be overridden by InitializationOptions. // // Defaults to false if not specified GlobalCacheStyle *string `json:"globalCacheStyle"` // FormatStyle format style // // Defaults to "gofmt" if not specified FormatStyle *string `json:"formatStyle"` // Enhance sigature help // // Defaults to false if not specified EnhanceSignatureHelp *bool `json:"enhanceSignatureHelp"` // GoimportsLocalPrefix is an optional version of // Config.GoimportsLocalPrefix GoimportsLocalPrefix *string `json:"goimportsLocalPrefix"` // BuildTags is an optional version of Config.BuildTags BuildTags []string `json:"buildTags"` }
InitializationOptions are the options supported by go-langserver. It is the Config struct, but each field is optional.
type InitializeParams ¶
type InitializeParams struct { lsp.InitializeParams InitializationOptions *InitializationOptions `json:"initializationOptions,omitempty"` // TODO these should be InitializationOptions // RootImportPath is the root Go import path for this // workspace. For example, // "golang.org/x/tools" is the root import // path for "github.com/golang/tools". RootImportPath string }
type LangHandler ¶
type LangHandler struct { HandlerCommon // DefaultConfig is the default values used for configuration. It is // combined with InitializationOptions after initialize. This should be // set by LangHandler creators. Please read config instead. DefaultConfig Config // contains filtered or unexported fields }
LangHandler is a Go language server LSP/JSON-RPC handler.
func (*LangHandler) Handle ¶
func (h *LangHandler) Handle(ctx context.Context, conn jsonrpc2.JSONRPC2, req *jsonrpc2.Request) (result interface{}, err error)
Handle creates a response for a JSONRPC2 LSP request. Note: LSP has strict ordering requirements, so this should not just be wrapped in an jsonrpc2.AsyncHandler. Ensure you have the same ordering as used in the NewHandler implementation.
type Query ¶
type Query struct { Kind lsp.SymbolKind Filter FilterType File, Dir string Tokens []string Symbol lspext.SymbolDescriptor }
Query is a structured representation that is parsed from the user's raw query string.
func ParseQuery ¶
ParseQuery parses a user's raw query string and returns a structured representation of the query.
type SymbolCollector ¶
type SymbolCollector struct {
// contains filtered or unexported fields
}
SymbolCollector stores symbol information for an AST
Source Files ¶
- ast.go
- cancel.go
- codeaction.go
- completion.go
- config.go
- definition.go
- diagnostics.go
- doc.go
- format.go
- fs.go
- handler.go
- handler_common.go
- handler_shared.go
- hover.go
- implementation.go
- initialization.go
- is_alias.go
- loader.go
- position.go
- references.go
- rename.go
- signature.go
- symbol.go
- symbol_descriptor.go
- workspace_refs.go
- xcache.go