diff --git a/internal/adapter/yamlls/initization.go b/internal/adapter/yamlls/initization.go index 396b6ae..26dc1fb 100644 --- a/internal/adapter/yamlls/initization.go +++ b/internal/adapter/yamlls/initization.go @@ -19,6 +19,46 @@ func (yamllsConnector Connector) CallInitialize(ctx context.Context, workspaceUR ClientInfo: &lsp.ClientInfo{ Name: "helm-ls", }, + Capabilities: lsp.ClientCapabilities{ + Workspace: &lsp.WorkspaceClientCapabilities{}, + TextDocument: &lsp.TextDocumentClientCapabilities{ + Synchronization: &lsp.TextDocumentSyncClientCapabilities{}, + Completion: &lsp.CompletionTextDocumentClientCapabilities{}, + Hover: &lsp.HoverTextDocumentClientCapabilities{}, + SignatureHelp: &lsp.SignatureHelpTextDocumentClientCapabilities{}, + Declaration: &lsp.DeclarationTextDocumentClientCapabilities{}, + Definition: &lsp.DefinitionTextDocumentClientCapabilities{}, + TypeDefinition: &lsp.TypeDefinitionTextDocumentClientCapabilities{}, + Implementation: &lsp.ImplementationTextDocumentClientCapabilities{}, + References: &lsp.ReferencesTextDocumentClientCapabilities{}, + DocumentHighlight: &lsp.DocumentHighlightClientCapabilities{}, + DocumentSymbol: &lsp.DocumentSymbolClientCapabilities{ + DynamicRegistration: false, + SymbolKind: &lsp.SymbolKindCapabilities{}, + HierarchicalDocumentSymbolSupport: true, + TagSupport: &lsp.DocumentSymbolClientCapabilitiesTagSupport{}, + LabelSupport: false, + }, + CodeAction: &lsp.CodeActionClientCapabilities{}, + CodeLens: &lsp.CodeLensClientCapabilities{}, + DocumentLink: &lsp.DocumentLinkClientCapabilities{}, + ColorProvider: &lsp.DocumentColorClientCapabilities{}, + Formatting: &lsp.DocumentFormattingClientCapabilities{}, + RangeFormatting: &lsp.DocumentRangeFormattingClientCapabilities{}, + OnTypeFormatting: &lsp.DocumentOnTypeFormattingClientCapabilities{}, + PublishDiagnostics: &lsp.PublishDiagnosticsClientCapabilities{}, + Rename: &lsp.RenameClientCapabilities{}, + FoldingRange: &lsp.FoldingRangeClientCapabilities{}, + SelectionRange: &lsp.SelectionRangeClientCapabilities{}, + CallHierarchy: &lsp.CallHierarchyClientCapabilities{}, + SemanticTokens: &lsp.SemanticTokensClientCapabilities{}, + LinkedEditingRange: &lsp.LinkedEditingRangeClientCapabilities{}, + Moniker: &lsp.MonikerClientCapabilities{}, + }, + Window: &lsp.WindowClientCapabilities{}, + General: &lsp.GeneralClientCapabilities{}, + Experimental: nil, + }, } _, err := yamllsConnector.server.Initialize(ctx, ¶ms) diff --git a/internal/adapter/yamlls/symbol.go b/internal/adapter/yamlls/symbol.go new file mode 100644 index 0000000..3ea128b --- /dev/null +++ b/internal/adapter/yamlls/symbol.go @@ -0,0 +1,15 @@ +package yamlls + +import ( + "context" + + lsp "go.lsp.dev/protocol" +) + +func (yamllsConnector Connector) CallDocumentSymbol(ctx context.Context, params *lsp.DocumentSymbolParams) (result []interface{}, err error) { + if yamllsConnector.server == nil { + return []interface{}{}, nil + } + + return yamllsConnector.server.DocumentSymbol(ctx, params) +} diff --git a/internal/handler/handler.go b/internal/handler/handler.go index ac86b4f..6ad1a42 100644 --- a/internal/handler/handler.go +++ b/internal/handler/handler.go @@ -130,12 +130,6 @@ func (h *langHandler) DocumentLinkResolve(ctx context.Context, params *lsp.Docum return nil, nil } -// DocumentSymbol implements protocol.Server. -func (h *langHandler) DocumentSymbol(ctx context.Context, params *lsp.DocumentSymbolParams) (result []interface{}, err error) { - logger.Error("Document symbol unimplemented") - return nil, nil -} - // ExecuteCommand implements protocol.Server. func (h *langHandler) ExecuteCommand(ctx context.Context, params *lsp.ExecuteCommandParams) (result interface{}, err error) { logger.Error("Execute command unimplemented") diff --git a/internal/handler/initialization.go b/internal/handler/initialization.go index 1828e67..a98076e 100644 --- a/internal/handler/initialization.go +++ b/internal/handler/initialization.go @@ -36,17 +36,15 @@ func (h *langHandler) Initialize(ctx context.Context, params *lsp.InitializePara TextDocumentSync: lsp.TextDocumentSyncOptions{ Change: lsp.TextDocumentSyncKindIncremental, OpenClose: true, - Save: &lsp.SaveOptions{ - IncludeText: true, - }, }, CompletionProvider: &lsp.CompletionOptions{ TriggerCharacters: []string{".", "$."}, ResolveProvider: false, }, - HoverProvider: true, - DefinitionProvider: true, - ReferencesProvider: true, + HoverProvider: true, + DefinitionProvider: true, + ReferencesProvider: true, + DocumentSymbolProvider: true, }, }, nil } diff --git a/internal/handler/symbol.go b/internal/handler/symbol.go new file mode 100644 index 0000000..29886bd --- /dev/null +++ b/internal/handler/symbol.go @@ -0,0 +1,12 @@ +package handler + +import ( + "context" + + lsp "go.lsp.dev/protocol" +) + +// DocumentSymbol implements protocol.Server. +func (h *langHandler) DocumentSymbol(ctx context.Context, params *lsp.DocumentSymbolParams) (result []interface{}, err error) { + return h.yamllsConnector.CallDocumentSymbol(ctx, params) +}