9fans / acme-lsp

Language Server Protocol tools for the acme text editor
MIT License
193 stars 25 forks source link

error on startup #54

Closed ilanpillemer closed 1 year ago

ilanpillemer commented 1 year ago

2023/01/01 14:02:52 failed to create file manager: failed to connect to language server ["gopls" "serve" "-rpc.trace" "--debug=localhost:6060"]: initialize failed: unmarshalling result: json: cannot unmarshal object into Go struct field ServerCapabilities.capabilities.selectionRangeProvider of type boo

seems probably linked to this line of code

internal/lsp/acmelsp/client.go:166:     return fmt.Errorf("initialize failed: %v", err)
    params := &protocol.InitializeParams{
        RootURI: text.ToURI(d),
        Capabilities: protocol.ClientCapabilities{
            // Workspace: ..., (struct literal)
            TextDocument: protocol.TextDocumentClientCapabilities{
                CodeAction: &protocol.CodeActionClientCapabilities{
                    CodeActionLiteralSupport: &protocol.CodeActionLiteralSupport{
                        // CodeActionKind: ..., (struct literal)
                    },
                },
                DocumentSymbol: &protocol.DocumentSymbolClientCapabilities{
                    HierarchicalDocumentSymbolSupport: true,
                },
            },
        },
        WorkspaceFolders:      cfg.Workspaces,
        InitializationOptions: cfg.Options,
    }
    params.Capabilities.Workspace.WorkspaceFolders = true
    params.Capabilities.Workspace.ApplyEdit = true
    params.Capabilities.TextDocument.CodeAction.CodeActionLiteralSupport.CodeActionKind.ValueSet =
        []protocol.CodeActionKind{protocol.SourceOrganizeImports}
    var result protocol.InitializeResult
    if err := rpc.Call(ctx, "initialize", params, &result); err != nil {
        return fmt.Errorf("initialize failed: %v", err)
    }
    if err := rpc.Notify(ctx, "initialized", &protocol.InitializedParams{}); err != nil {
        return fmt.Errorf("initialized failed: %v", err)
    }
    c.Server = server
    c.initializeResult = &result
    return nil

So error is being returned I assume from gopls, I will look there now and see if I can see what changed there.

look like its linked to this commit in gopls

https://github.com/golang/tools/commit/1270fd75a4eb59b0f0970889a22eb94a73065f7e

and

https://github.com/golang/go/issues/36679

Upon analysis the error is because the go server is expecting a struct and not a bool.. see https://github.com/golang/tools/commit/1270fd75a4eb59b0f0970889a22eb94a73065f7e

I have made a PR to match this expectation (my local testing in acme was successful)

NB: started happening during last week of December.

fhs commented 1 year ago

This should be fixed now. See my comment in PR #55: https://github.com/fhs/acme-lsp/pull/55#issuecomment-1596268988