Skip to content

Commit

Permalink
Mock out code lens support (#561)
Browse files Browse the repository at this point in the history
Because it is not trivial to omit codeLens support from the server capabilities
with gopls' LSP structs, we just pretend that we support it but don't return any.
  • Loading branch information
radeksimko authored Jun 22, 2021
1 parent f70f42d commit ad67838
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/langserver/handlers/code_lens.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package handlers

import (
"context"

lsp "github.com/hashicorp/terraform-ls/internal/protocol"
)

func (h *logHandler) TextDocumentCodeLens(ctx context.Context, params lsp.CodeLensParams) ([]lsp.CodeLens, error) {
// TODO: Implement code lens
return []lsp.CodeLens{}, nil
}
1 change: 1 addition & 0 deletions internal/langserver/handlers/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func (lh *logHandler) Initialize(ctx context.Context, params lsp.InitializeParam
CompletionProvider: lsp.CompletionOptions{
ResolveProvider: false,
},
CodeLensProvider: lsp.CodeLensOptions{},
HoverProvider: true,
DocumentFormattingProvider: true,
DocumentSymbolProvider: true,
Expand Down
8 changes: 8 additions & 0 deletions internal/langserver/handlers/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ func (svc *service) Assigner() (jrpc2.Assigner, error) {

return handle(ctx, req, lh.TextDocumentHover)
},
"textDocument/codeLens": func(ctx context.Context, req *jrpc2.Request) (interface{}, error) {
err := session.CheckInitializationIsConfirmed()
if err != nil {
return nil, err
}

return handle(ctx, req, lh.TextDocumentCodeLens)
},
"textDocument/formatting": func(ctx context.Context, req *jrpc2.Request) (interface{}, error) {
err := session.CheckInitializationIsConfirmed()
if err != nil {
Expand Down

0 comments on commit ad67838

Please sign in to comment.