Skip to content

Commit

Permalink
feat(document-symbols): add yamlls document-symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
qvalentin committed Jul 25, 2024
1 parent 312b9c0 commit e2c89b8
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 12 deletions.
40 changes: 40 additions & 0 deletions internal/adapter/yamlls/initization.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, &params)
Expand Down
15 changes: 15 additions & 0 deletions internal/adapter/yamlls/symbol.go
Original file line number Diff line number Diff line change
@@ -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)
}
6 changes: 0 additions & 6 deletions internal/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
10 changes: 4 additions & 6 deletions internal/handler/initialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
12 changes: 12 additions & 0 deletions internal/handler/symbol.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit e2c89b8

Please sign in to comment.