clojure-lsp / clojure-lsp

Clojure & ClojureScript Language Server (LSP) implementation
https://clojure-lsp.io
MIT License
1.17k stars 153 forks source link

server-info is now sent in camelCase #1195

Closed Cyrik closed 2 years ago

Cyrik commented 2 years ago

Describe the bug When the client calls 'clojure/serverInfo/raw' the map keys are now in camelCase instead of kebab-case.

To Reproduce Steps to reproduce the behavior: send 'clojure/serverInfo/raw' to clojure-lsp or start Calva

Expected behavior Until now it seems to have been sent in kebab-case.

Screenshots If applicable, add screenshots to help explain your problem.

Log - client <-> server
[Trace - 1:20:25 PM] Received response 'clojure/serverInfo/raw - (1)' in 1383ms.
Result: {
    "finalSettings": {
        "useMetadataForPrivacy?": true,
        "keepRequireAtStart?": true,
        "sourceAliases": [
            "debug",
            "test",
            "dev"
        ],
        "textDocumentSyncKind": null,
        "projectSpecs": [
            {
                "projectPath": "project.clj",
                "classpathCmd": [
                    "lein",
                    "with-profile",
                    "+debug,+test,+dev",
                    "classpath"
                ]
            },
            {
                "projectPath": "deps.edn",
                "classpathCmd": [
                    "clojure",
                    "-A:debug:test:dev",
                    "-Spath"
                ]
            },
            {
                "projectPath": "build.boot",
                "classpathCmd": [
                    "boot",
                    "show",
                    "--fake-classpath"
                ]
            },
            {
                "projectPath": "shadow-cljs.edn",
                "classpathCmd": [
                    "npx",
                    "shadow-cljs",
                    "classpath"
                ]
            },
            {
                "projectPath": "bb.edn",
                "classpathCmd": [
                    "bb",
                    "print-deps",
                    "--format",
                    "classpath"
                ]
            }
        ],
        "dependencyScheme": "jar",
        "sourcePaths": [
            "/Users/lukas/Workspace/clojure/clojure-lsp/lib/test",
            "/Users/lukas/Workspace/clojure/clojure-lsp/common-test/src",
            "/Users/lukas/Workspace/clojure/clojure-lsp/cli/target/lsp-classes",
            "/Users/lukas/Workspace/clojure/clojure-lsp/scripts",
            "/Users/lukas/Workspace/clojure/clojure-lsp/cli/src",
            "/Users/lukas/Workspace/clojure/clojure-lsp/cli/dev",
            "/Users/lukas/Workspace/clojure/clojure-lsp/lib/resources",
            "/Users/lukas/Workspace/clojure/clojure-lsp/cli/test",
            "/Users/lukas/Workspace/clojure/clojure-lsp/cli/resources",
            "/Users/lukas/Workspace/clojure/clojure-lsp/lib/src"
        ],
        "cljfmtConfigPath": ".cljfmt.edn",
        "uriFormat": {
            "upperCaseDriveLetter?": false,
            "encodeColonsInPath?": false
        },
        "documentFormatting?": false,
        "linters": {
            "cljKondo": {
                "nsExcludeRegex": "sample-test.*"
            }
        },
        "documentRangeFormatting?": false,
        "autoAddNsToNewFiles?": true
    },
    "cljfmtRaw": "{:remove-surrounding-whitespace? true, :remove-trailing-whitespace? true, :remove-consecutive-blank-lines? true, :insert-missing-whitespace? true, :align-associative? false, :indents {#\"^(?!catch-kondo-errors).*\" [[:block 0]], catch-kondo-errors [[:inner 0]]}, :test-code (comment (:require []) (:require [] []) (:clj []) (reg-event-fx :foo (fn [{db :db} _])) (reg-sub :foo (fn [db [_]])))}",

...

Additional context Add any other context about the problem here.

I'm guessing the coercer did the case switching before lsp4clj v1. We now have to decide if clojure-lsp should go back to the old behavior or if Calva and Co need to understand the new syntax. I'm fine with either.

ericdallo commented 2 years ago

@mainej I think we should try to fix that before next release to avoid breaking Calva

mainej commented 2 years ago

@Cyrik sorry about that. Good catch. @ericdallo, I agree, this should be fixed. I ran into this problem before—I can't remember where, but somewhere else we needed to preserve kebab-case. The solution I came up with is that in lsp4clj, keywords are camelCased, but anything else is just stringified. So, if we convert the keys of server-info to kebab-case strings, they'll pass through to the editors unchanged. We could do this manually, but it's probably safer to do automatically, with camel-snake-kebab.core/->kebab-case-string. @ericdallo, camel-snake-kebab is already a dependency of lsp4clj. Would you prefer to add it to clojure-lsp's dependencies and do the conversion in clojure-lsp? Or would you prefer a helper in lsp4clj that does that? (Another case where lsp4clj.utils would be useful.)

ericdallo commented 2 years ago

@mainej thanks for taking a look, I'm fine having it on clojure-lsp or lsp4clj until we have some utils on lsp4clj side, maybe on clojure-lsp side since it's the only place used ATM