BetterThanTomorrow / calva

Clojure & ClojureScript Interactive Programming for VS Code
https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.calva
Other
1.7k stars 219 forks source link

Completion should 'add missing require' automatically #1663

Open CmdrDats opened 2 years ago

CmdrDats commented 2 years ago

When I complete a known namespace symbol, Calva doesn't automatically also add to the namespace require, even though Add missing require does that afterward. Ideally, even if there is ambiguity in the alias, it should base it on the selection I made?

I chatted with Eric Dallo on #calva and he confirms the following:

Just confirmed this only works on lsp-mode(emacs) but not on Calva for some reason, probably related to how calva handles completion/resolveItem , please open a issue on Calva so we can investigate further more

The code I tested (with thanks to Eric):

a.clj

(ns clojure-sample.a)

(defn foo []
  123)

b.clj

(ns clojure-sample.b
  (:require
   [clojure-sample.a :as my-alias]))

(my-alias/foo) 

c.clj

(ns clojure-sample.c)

my-alias ;; completion here should add the require
my-alias/foo ;; completion here should add the require

I don't have a .cljfmt.edn file in the project (completely new project)

clojure-lsp info:

{
  "client-settings": {
    "auto-add-ns-to-new-files?": true,
    "document-formatting?": false,
    "dependency-scheme": "jar",
    "keep-require-at-start?": true,
    "document-range-formatting?": false,
    "cljfmt-config-path": ".cljfmt.edn"
  },
  "project-root-uri": "file:///home/cmdrdats/storage/ext/requiretest",
  "cljfmt-raw": "nil",
  "clj-kondo-version": "2022.03.10-SNAPSHOT",
  "final-settings": {
    "auto-add-ns-to-new-files?": true,
    "document-formatting?": false,
    "dependency-scheme": "jar",
    "keep-require-at-start?": true,
    "source-paths": [
      "/home/cmdrdats/storage/ext/requiretest/test",
      "/home/cmdrdats/storage/ext/requiretest/src",
      "/home/cmdrdats/storage/ext/requiretest/dev-resources",
      "/home/cmdrdats/storage/ext/requiretest/resources",
      "/home/cmdrdats/storage/ext/requiretest/target/classes"
    ],
    "project-specs": [
      {
        "project-path": "project.clj",
        "classpath-cmd": [
          "lein",
          "with-profile",
          "+test,+dev",
          "classpath"
        ]
      },
      {
        "project-path": "deps.edn",
        "classpath-cmd": [
          "clojure",
          "-A:test:dev",
          "-Spath"
        ]
      },
      {
        "project-path": "build.boot",
        "classpath-cmd": [
          "boot",
          "show",
          "--fake-classpath"
        ]
      },
      {
        "project-path": "shadow-cljs.edn",
        "classpath-cmd": [
          "npx",
          "shadow-cljs",
          "classpath"
        ]
      },
      {
        "project-path": "bb.edn",
        "classpath-cmd": [
          "bb",
          "print-deps",
          "--format",
          "classpath"
        ]
      }
    ],
    "source-aliases": [
      "dev",
      "test"
    ],
    "uri-format": {
      "upper-case-drive-letter?": false,
      "encode-colons-in-path?": false
    },
    "document-range-formatting?": false,
    "cljfmt-config-path": ".cljfmt.edn"
  },
  "classpath": [
    "/home/cmdrdats/storage/ext/requiretest/test",
    "/home/cmdrdats/storage/ext/requiretest/src",
    "/home/cmdrdats/storage/ext/requiretest/dev-resources",
    "/home/cmdrdats/storage/ext/requiretest/resources",
    "/home/cmdrdats/storage/ext/requiretest/target/classes",
    "/home/cmdrdats/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar",
    "/home/cmdrdats/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar",
    "/home/cmdrdats/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar",
    "/home/cmdrdats/.m2/repository/nrepl/nrepl/0.8.3/nrepl-0.8.3.jar",
    "/home/cmdrdats/.m2/repository/clojure-complete/clojure-complete/0.2.5/clojure-complete-0.2.5.jar"
  ],
  "port": "NREPL only available on :debug profile (`make debug-cli`)",
  "server-version": "2022.03.31-20.00.20",
  "log-path": "/tmp/clojure-lsp.18393268698616922868.out",
  "project-settings": {}
}

Clojure Language Client logs

[Trace - 21:09:21] Sending request 'textDocument/documentHighlight - (37)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    },
    "position": {
        "line": 2,
        "character": 8
    }
}

[Trace - 21:09:21] Received response 'textDocument/documentHighlight - (37)' in 1ms.
Result: [
    {
        "range": {
            "start": {
                "line": 2,
                "character": 0
            },
            "end": {
                "line": 2,
                "character": 8
            }
        }
    }
]

[Trace - 21:09:21] Sending request 'textDocument/codeLens - (38)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    }
}

[Trace - 21:09:21] Sending request 'textDocument/codeAction - (39)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    },
    "range": {
        "start": {
            "line": 2,
            "character": 8
        },
        "end": {
            "line": 2,
            "character": 8
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 0
                    },
                    "end": {
                        "line": 2,
                        "character": 8
                    }
                },
                "message": "Unresolved symbol: my-alias",
                "code": "unresolved-symbol",
                "severity": 1,
                "source": "clj-kondo"
            }
        ]
    }
}

[Trace - 21:09:21] Received response 'textDocument/codeLens - (38)' in 2ms.
Result: [
    {
        "range": {
            "start": {
                "line": 0,
                "character": 4
            },
            "end": {
                "line": 0,
                "character": 20
            }
        },
        "data": [
            "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
            1,
            5
        ]
    }
]

[Trace - 21:09:21] Received response 'textDocument/codeAction - (39)' in 6ms.
Result: [
    {
        "title": "Add require '[clojure-sample.a :as my-alias]' × 1",
        "kind": "quickfix",
        "isPreferred": true,
        "command": {
            "title": "Add require suggestion",
            "command": "add-require-suggestion",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                2,
                0,
                "clojure-sample.a",
                "my-alias",
                null
            ]
        }
    },
    {
        "title": "Create private function 'my-alias'",
        "kind": "quickfix",
        "command": {
            "title": "Create function",
            "command": "create-function",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                2,
                0
            ]
        }
    },
    {
        "title": "Move to let",
        "kind": "refactor.extract",
        "command": {
            "title": "Move to let",
            "command": "move-to-let",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                2,
                8,
                "new-binding"
            ]
        }
    },
    {
        "title": "Introduce let",
        "kind": "refactor.extract",
        "command": {
            "title": "Introduce let",
            "command": "introduce-let",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                2,
                8,
                "new-binding"
            ]
        }
    },
    {
        "title": "Suppress 'unresolved-symbol' diagnostic",
        "kind": "quickfix",
        "command": {
            "title": "Suppress diagnostic",
            "command": "suppress-diagnostic",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                2,
                0,
                "unresolved-symbol"
            ]
        }
    },
    {
        "title": "Clean namespace",
        "kind": "source.organizeImports",
        "command": {
            "title": "Clean namespace",
            "command": "clean-ns",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                2,
                8
            ]
        }
    }
]

[Trace - 21:09:21] Sending request 'codeLens/resolve - (40)'.
Params: {
    "range": {
        "start": {
            "line": 0,
            "character": 4
        },
        "end": {
            "line": 0,
            "character": 20
        }
    },
    "data": [
        "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
        1,
        5
    ]
}

[Trace - 21:09:21] Received response 'codeLens/resolve - (40)' in 1ms.
Result: {
    "range": {
        "start": {
            "line": 0,
            "character": 4
        },
        "end": {
            "line": 0,
            "character": 20
        }
    },
    "command": {
        "title": "0 references",
        "command": "code-lens-references",
        "arguments": [
            "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
            1,
            5
        ]
    }
}

[Trace - 21:09:21] Sending request 'textDocument/completion - (41)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    },
    "position": {
        "line": 2,
        "character": 8
    },
    "context": {
        "triggerKind": 1
    }
}

[Trace - 21:09:21] Received response 'textDocument/completion - (41)' in 16ms.
Result: [
    {
        "label": "my-alias",
        "kind": 10,
        "detail": "clojure-sample.a",
        "additionalTextEdits": [
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 0
                    },
                    "end": {
                        "line": 0,
                        "character": 21
                    }
                },
                "newText": "(ns clojure-sample.c \n  (:require [clojure-sample.a :as my-alias]))"
            }
        ],
        "data": {
            "name": "",
            "filename": "/home/cmdrdats/storage/ext/requiretest/src/clojure_sample/b.clj",
            "name-row": 3,
            "name-col": 26
        }
    },
    {
        "label": "my-alias/foo",
        "kind": 3,
        "additionalTextEdits": [
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 0
                    },
                    "end": {
                        "line": 0,
                        "character": 21
                    }
                },
                "newText": "(ns clojure-sample.c \n  (:require [clojure-sample.a :as my-alias]))"
            }
        ],
        "data": {
            "name": "foo",
            "filename": "/home/cmdrdats/storage/ext/requiretest/src/clojure_sample/a.clj",
            "name-row": 3,
            "name-col": 7
        }
    }
]

[Trace - 21:09:21] Sending request 'completionItem/resolve - (42)'.
Params: {
    "label": "my-alias",
    "detail": "clojure-sample.a",
    "insertTextFormat": 1,
    "kind": 10,
    "additionalTextEdits": [
        {
            "range": {
                "start": {
                    "line": 0,
                    "character": 0
                },
                "end": {
                    "line": 0,
                    "character": 21
                }
            },
            "newText": "(ns clojure-sample.c \n  (:require [clojure-sample.a :as my-alias]))"
        }
    ],
    "data": {
        "name": "",
        "filename": "/home/cmdrdats/storage/ext/requiretest/src/clojure_sample/b.clj",
        "name-row": 3,
        "name-col": 26
    }
}

[Trace - 21:09:21] Received response 'completionItem/resolve - (42)' in 1ms.
Result: {
    "label": "my-alias",
    "kind": 10,
    "detail": "clojure-sample.a",
    "insertTextFormat": 1,
    "data": {
        ":name": "",
        ":filename": "/home/cmdrdats/storage/ext/requiretest/src/clojure_sample/b.clj",
        ":name-row": 3,
        ":name-col": 26
    }
}

[Trace - 21:09:22] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
        "version": 4
    },
    "contentChanges": [
        {
            "text": "(ns clojure-sample.c)\n\nmy-alias ;; completion here should add the require\nmy-alias/foo ;; completion here should add the require"
        }
    ]
}

[Trace - 21:09:22] Sending request 'textDocument/codeLens - (43)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    }
}

[Trace - 21:09:22] Sending request 'textDocument/codeLens - (44)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    }
}

[Trace - 21:09:22] Sending request 'textDocument/documentSymbol - (45)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    }
}

[Trace - 21:09:22] Received response 'textDocument/documentSymbol - (45)' in 1ms.
Result: [
    {
        "name": "clojure-sample.c",
        "kind": 3,
        "range": {
            "start": {
                "line": 0,
                "character": 0
            },
            "end": {
                "line": 999999,
                "character": 999999
            }
        },
        "selectionRange": {
            "start": {
                "line": 0,
                "character": 0
            },
            "end": {
                "line": 0,
                "character": 21
            }
        },
        "children": []
    }
]

[Trace - 21:09:22] Received response 'textDocument/codeLens - (43)' in 293ms.
Result: [
    {
        "range": {
            "start": {
                "line": 0,
                "character": 4
            },
            "end": {
                "line": 0,
                "character": 20
            }
        },
        "data": [
            "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
            1,
            5
        ]
    }
]

[Trace - 21:09:22] Received response 'textDocument/codeLens - (44)' in 293ms.
Result: [
    {
        "range": {
            "start": {
                "line": 0,
                "character": 4
            },
            "end": {
                "line": 0,
                "character": 20
            }
        },
        "data": [
            "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
            1,
            5
        ]
    }
]

[Trace - 21:09:22] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
    "diagnostics": [
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 0
                },
                "end": {
                    "line": 2,
                    "character": 8
                }
            },
            "severity": 1,
            "code": "unresolved-symbol",
            "source": "clj-kondo",
            "message": "Unresolved symbol: my-alias",
            "tags": []
        },
        {
            "range": {
                "start": {
                    "line": 3,
                    "character": 0
                },
                "end": {
                    "line": 3,
                    "character": 12
                }
            },
            "severity": 2,
            "code": "unresolved-namespace",
            "source": "clj-kondo",
            "message": "Unresolved namespace my-alias. Are you missing a require?",
            "tags": []
        }
    ]
}

[Trace - 21:09:22] Sending request 'codeLens/resolve - (46)'.
Params: {
    "range": {
        "start": {
            "line": 0,
            "character": 4
        },
        "end": {
            "line": 0,
            "character": 20
        }
    },
    "data": [
        "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
        1,
        5
    ]
}

[Trace - 21:09:22] Sending request 'codeLens/resolve - (47)'.
Params: {
    "range": {
        "start": {
            "line": 0,
            "character": 4
        },
        "end": {
            "line": 0,
            "character": 20
        }
    },
    "data": [
        "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
        1,
        5
    ]
}

[Trace - 21:09:22] Received response 'codeLens/resolve - (47)' in 2ms.
Result: {
    "range": {
        "start": {
            "line": 0,
            "character": 4
        },
        "end": {
            "line": 0,
            "character": 20
        }
    },
    "command": {
        "title": "0 references",
        "command": "code-lens-references",
        "arguments": [
            "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
            1,
            5
        ]
    }
}

[Trace - 21:09:22] Received response 'codeLens/resolve - (46)' in 2ms.
Result: {
    "range": {
        "start": {
            "line": 0,
            "character": 4
        },
        "end": {
            "line": 0,
            "character": 20
        }
    },
    "command": {
        "title": "0 references",
        "command": "code-lens-references",
        "arguments": [
            "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
            1,
            5
        ]
    }
}

[Trace - 21:09:22] Sending request 'textDocument/codeAction - (48)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    },
    "range": {
        "start": {
            "line": 2,
            "character": 8
        },
        "end": {
            "line": 2,
            "character": 8
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 0
                    },
                    "end": {
                        "line": 2,
                        "character": 8
                    }
                },
                "message": "Unresolved symbol: my-alias",
                "code": "unresolved-symbol",
                "severity": 1,
                "source": "clj-kondo"
            }
        ]
    }
}

[Trace - 21:09:22] Sending request 'textDocument/codeAction - (49)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    },
    "range": {
        "start": {
            "line": 3,
            "character": 12
        },
        "end": {
            "line": 3,
            "character": 12
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 3,
                        "character": 0
                    },
                    "end": {
                        "line": 3,
                        "character": 12
                    }
                },
                "message": "Unresolved namespace my-alias. Are you missing a require?",
                "code": "unresolved-namespace",
                "severity": 2,
                "source": "clj-kondo"
            }
        ]
    }
}

[Trace - 21:09:22] Received response 'textDocument/codeAction - (49)' in 4ms.
Result: [
    {
        "title": "Add require '[clojure-sample.a :as my-alias]' × 1",
        "kind": "quickfix",
        "isPreferred": true,
        "command": {
            "title": "Add require suggestion",
            "command": "add-require-suggestion",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0,
                "clojure-sample.a",
                "my-alias",
                null
            ]
        }
    },
    {
        "title": "Create namespace 'my-alias' and 'foo' function",
        "kind": "quickfix",
        "command": {
            "title": "Create function",
            "command": "create-function",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0
            ]
        }
    },
    {
        "title": "Suppress 'unresolved-namespace' diagnostic",
        "kind": "quickfix",
        "command": {
            "title": "Suppress diagnostic",
            "command": "suppress-diagnostic",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0,
                "unresolved-namespace"
            ]
        }
    },
    {
        "title": "Clean namespace",
        "kind": "source.organizeImports",
        "command": {
            "title": "Clean namespace",
            "command": "clean-ns",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                12
            ]
        }
    }
]

[Trace - 21:09:22] Received response 'textDocument/codeAction - (48)' in 6ms.
Result: [
    {
        "title": "Add require '[clojure-sample.a :as my-alias]' × 1",
        "kind": "quickfix",
        "isPreferred": true,
        "command": {
            "title": "Add require suggestion",
            "command": "add-require-suggestion",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                2,
                0,
                "clojure-sample.a",
                "my-alias",
                null
            ]
        }
    },
    {
        "title": "Create private function 'my-alias'",
        "kind": "quickfix",
        "command": {
            "title": "Create function",
            "command": "create-function",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                2,
                0
            ]
        }
    },
    {
        "title": "Move to let",
        "kind": "refactor.extract",
        "command": {
            "title": "Move to let",
            "command": "move-to-let",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                2,
                8,
                "new-binding"
            ]
        }
    },
    {
        "title": "Introduce let",
        "kind": "refactor.extract",
        "command": {
            "title": "Introduce let",
            "command": "introduce-let",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                2,
                8,
                "new-binding"
            ]
        }
    },
    {
        "title": "Suppress 'unresolved-symbol' diagnostic",
        "kind": "quickfix",
        "command": {
            "title": "Suppress diagnostic",
            "command": "suppress-diagnostic",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                2,
                0,
                "unresolved-symbol"
            ]
        }
    },
    {
        "title": "Clean namespace",
        "kind": "source.organizeImports",
        "command": {
            "title": "Clean namespace",
            "command": "clean-ns",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                2,
                8
            ]
        }
    }
]

[Trace - 21:09:23] Sending request 'textDocument/hover - (50)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    },
    "position": {
        "line": 3,
        "character": 11
    }
}

[Trace - 21:09:23] Received response 'textDocument/hover - (50)' in 0ms.
Result: {
    "contents": []
}

[Trace - 21:09:23] Sending request 'textDocument/codeAction - (51)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    },
    "range": {
        "start": {
            "line": 3,
            "character": 0
        },
        "end": {
            "line": 3,
            "character": 12
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 3,
                        "character": 0
                    },
                    "end": {
                        "line": 3,
                        "character": 12
                    }
                },
                "message": "Unresolved namespace my-alias. Are you missing a require?",
                "code": "unresolved-namespace",
                "severity": 2,
                "source": "clj-kondo"
            }
        ],
        "only": [
            "quickfix"
        ]
    }
}

[Trace - 21:09:23] Received response 'textDocument/codeAction - (51)' in 3ms.
Result: [
    {
        "title": "Add require '[clojure-sample.a :as my-alias]' × 1",
        "kind": "quickfix",
        "isPreferred": true,
        "command": {
            "title": "Add require suggestion",
            "command": "add-require-suggestion",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0,
                "clojure-sample.a",
                "my-alias",
                null
            ]
        }
    },
    {
        "title": "Create namespace 'my-alias' and 'foo' function",
        "kind": "quickfix",
        "command": {
            "title": "Create function",
            "command": "create-function",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0
            ]
        }
    },
    {
        "title": "Move to let",
        "kind": "refactor.extract",
        "command": {
            "title": "Move to let",
            "command": "move-to-let",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0,
                "new-binding"
            ]
        }
    },
    {
        "title": "Introduce let",
        "kind": "refactor.extract",
        "command": {
            "title": "Introduce let",
            "command": "introduce-let",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0,
                "new-binding"
            ]
        }
    },
    {
        "title": "Suppress 'unresolved-namespace' diagnostic",
        "kind": "quickfix",
        "command": {
            "title": "Suppress diagnostic",
            "command": "suppress-diagnostic",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0,
                "unresolved-namespace"
            ]
        }
    },
    {
        "title": "Clean namespace",
        "kind": "source.organizeImports",
        "command": {
            "title": "Clean namespace",
            "command": "clean-ns",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0
            ]
        }
    }
]

[Trace - 21:09:23] Sending request 'textDocument/documentHighlight - (52)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    },
    "position": {
        "line": 3,
        "character": 12
    }
}

[Trace - 21:09:23] Received response 'textDocument/documentHighlight - (52)' in 2ms.
Result: []

[Trace - 21:09:24] Sending request 'textDocument/codeAction - (53)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    },
    "range": {
        "start": {
            "line": 3,
            "character": 12
        },
        "end": {
            "line": 3,
            "character": 12
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 3,
                        "character": 0
                    },
                    "end": {
                        "line": 3,
                        "character": 12
                    }
                },
                "message": "Unresolved namespace my-alias. Are you missing a require?",
                "code": "unresolved-namespace",
                "severity": 2,
                "source": "clj-kondo"
            }
        ]
    }
}

[Trace - 21:09:24] Received response 'textDocument/codeAction - (53)' in 4ms.
Result: [
    {
        "title": "Add require '[clojure-sample.a :as my-alias]' × 1",
        "kind": "quickfix",
        "isPreferred": true,
        "command": {
            "title": "Add require suggestion",
            "command": "add-require-suggestion",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0,
                "clojure-sample.a",
                "my-alias",
                null
            ]
        }
    },
    {
        "title": "Create namespace 'my-alias' and 'foo' function",
        "kind": "quickfix",
        "command": {
            "title": "Create function",
            "command": "create-function",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0
            ]
        }
    },
    {
        "title": "Suppress 'unresolved-namespace' diagnostic",
        "kind": "quickfix",
        "command": {
            "title": "Suppress diagnostic",
            "command": "suppress-diagnostic",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0,
                "unresolved-namespace"
            ]
        }
    },
    {
        "title": "Clean namespace",
        "kind": "source.organizeImports",
        "command": {
            "title": "Clean namespace",
            "command": "clean-ns",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                12
            ]
        }
    }
]

[Trace - 21:09:24] Sending request 'textDocument/completion - (54)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    },
    "position": {
        "line": 3,
        "character": 12
    },
    "context": {
        "triggerKind": 1
    }
}

[Trace - 21:09:24] Received response 'textDocument/completion - (54)' in 6ms.
Result: [
    {
        "label": "my-alias/foo",
        "kind": 3,
        "additionalTextEdits": [
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 0
                    },
                    "end": {
                        "line": 0,
                        "character": 21
                    }
                },
                "newText": "(ns clojure-sample.c \n  (:require [clojure-sample.a :as my-alias]))"
            }
        ],
        "data": {
            "name": "foo",
            "filename": "/home/cmdrdats/storage/ext/requiretest/src/clojure_sample/a.clj",
            "name-row": 3,
            "name-col": 7
        }
    }
]

[Trace - 21:09:24] Sending request 'completionItem/resolve - (55)'.
Params: {
    "label": "my-alias/foo",
    "insertTextFormat": 1,
    "kind": 3,
    "additionalTextEdits": [
        {
            "range": {
                "start": {
                    "line": 0,
                    "character": 0
                },
                "end": {
                    "line": 0,
                    "character": 21
                }
            },
            "newText": "(ns clojure-sample.c \n  (:require [clojure-sample.a :as my-alias]))"
        }
    ],
    "data": {
        "name": "foo",
        "filename": "/home/cmdrdats/storage/ext/requiretest/src/clojure_sample/a.clj",
        "name-row": 3,
        "name-col": 7
    }
}

[Trace - 21:09:24] Received response 'completionItem/resolve - (55)' in 1ms.
Result: {
    "label": "my-alias/foo",
    "kind": 3,
    "documentation": {
        "kind": "markdown",
        "value": "```clojure\nclojure-sample.a/foo\n[]\n```\n\n----\n\n*[/home/cmdrdats/storage/ext/requiretest/src/clojure_sample/a.clj](file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/a.clj)*"
    },
    "insertTextFormat": 1,
    "data": {
        ":name": "foo",
        ":filename": "/home/cmdrdats/storage/ext/requiretest/src/clojure_sample/a.clj",
        ":name-row": 3,
        ":name-col": 7
    }
}

[Trace - 21:09:25] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
        "version": 5
    },
    "contentChanges": [
        {
            "text": "(ns clojure-sample.c)\n\nmy-alias ;; completion here should add the require\nmy-alias/foo ;; completion here should add the require"
        }
    ]
}

[Trace - 21:09:25] Sending request 'textDocument/codeLens - (56)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    }
}

[Trace - 21:09:25] Sending request 'textDocument/codeLens - (57)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    }
}

[Trace - 21:09:25] Sending request 'textDocument/documentSymbol - (58)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    }
}

[Trace - 21:09:25] Received response 'textDocument/documentSymbol - (58)' in 1ms.
Result: [
    {
        "name": "clojure-sample.c",
        "kind": 3,
        "range": {
            "start": {
                "line": 0,
                "character": 0
            },
            "end": {
                "line": 999999,
                "character": 999999
            }
        },
        "selectionRange": {
            "start": {
                "line": 0,
                "character": 0
            },
            "end": {
                "line": 0,
                "character": 21
            }
        },
        "children": []
    }
]

[Trace - 21:09:25] Received response 'textDocument/codeLens - (57)' in 292ms.
Result: [
    {
        "range": {
            "start": {
                "line": 0,
                "character": 4
            },
            "end": {
                "line": 0,
                "character": 20
            }
        },
        "data": [
            "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
            1,
            5
        ]
    }
]

[Trace - 21:09:25] Received response 'textDocument/codeLens - (56)' in 292ms.
Result: [
    {
        "range": {
            "start": {
                "line": 0,
                "character": 4
            },
            "end": {
                "line": 0,
                "character": 20
            }
        },
        "data": [
            "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
            1,
            5
        ]
    }
]

[Trace - 21:09:25] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
    "diagnostics": [
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 0
                },
                "end": {
                    "line": 2,
                    "character": 8
                }
            },
            "severity": 1,
            "code": "unresolved-symbol",
            "source": "clj-kondo",
            "message": "Unresolved symbol: my-alias",
            "tags": []
        },
        {
            "range": {
                "start": {
                    "line": 3,
                    "character": 0
                },
                "end": {
                    "line": 3,
                    "character": 12
                }
            },
            "severity": 2,
            "code": "unresolved-namespace",
            "source": "clj-kondo",
            "message": "Unresolved namespace my-alias. Are you missing a require?",
            "tags": []
        }
    ]
}

[Trace - 21:09:25] Sending request 'codeLens/resolve - (59)'.
Params: {
    "range": {
        "start": {
            "line": 0,
            "character": 4
        },
        "end": {
            "line": 0,
            "character": 20
        }
    },
    "data": [
        "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
        1,
        5
    ]
}

[Trace - 21:09:25] Sending request 'codeLens/resolve - (60)'.
Params: {
    "range": {
        "start": {
            "line": 0,
            "character": 4
        },
        "end": {
            "line": 0,
            "character": 20
        }
    },
    "data": [
        "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
        1,
        5
    ]
}

[Trace - 21:09:25] Received response 'codeLens/resolve - (59)' in 2ms.
Result: {
    "range": {
        "start": {
            "line": 0,
            "character": 4
        },
        "end": {
            "line": 0,
            "character": 20
        }
    },
    "command": {
        "title": "0 references",
        "command": "code-lens-references",
        "arguments": [
            "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
            1,
            5
        ]
    }
}

[Trace - 21:09:25] Received response 'codeLens/resolve - (60)' in 2ms.
Result: {
    "range": {
        "start": {
            "line": 0,
            "character": 4
        },
        "end": {
            "line": 0,
            "character": 20
        }
    },
    "command": {
        "title": "0 references",
        "command": "code-lens-references",
        "arguments": [
            "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
            1,
            5
        ]
    }
}

[Trace - 21:09:25] Sending request 'textDocument/codeAction - (61)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    },
    "range": {
        "start": {
            "line": 3,
            "character": 12
        },
        "end": {
            "line": 3,
            "character": 12
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 3,
                        "character": 0
                    },
                    "end": {
                        "line": 3,
                        "character": 12
                    }
                },
                "message": "Unresolved namespace my-alias. Are you missing a require?",
                "code": "unresolved-namespace",
                "severity": 2,
                "source": "clj-kondo"
            }
        ]
    }
}

[Trace - 21:09:25] Sending request 'textDocument/codeAction - (62)'.
Params: {
    "textDocument": {
        "uri": "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj"
    },
    "range": {
        "start": {
            "line": 3,
            "character": 12
        },
        "end": {
            "line": 3,
            "character": 12
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 3,
                        "character": 0
                    },
                    "end": {
                        "line": 3,
                        "character": 12
                    }
                },
                "message": "Unresolved namespace my-alias. Are you missing a require?",
                "code": "unresolved-namespace",
                "severity": 2,
                "source": "clj-kondo"
            }
        ]
    }
}

[Trace - 21:09:25] Received response 'textDocument/codeAction - (62)' in 4ms.
Result: [
    {
        "title": "Add require '[clojure-sample.a :as my-alias]' × 1",
        "kind": "quickfix",
        "isPreferred": true,
        "command": {
            "title": "Add require suggestion",
            "command": "add-require-suggestion",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0,
                "clojure-sample.a",
                "my-alias",
                null
            ]
        }
    },
    {
        "title": "Create namespace 'my-alias' and 'foo' function",
        "kind": "quickfix",
        "command": {
            "title": "Create function",
            "command": "create-function",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0
            ]
        }
    },
    {
        "title": "Suppress 'unresolved-namespace' diagnostic",
        "kind": "quickfix",
        "command": {
            "title": "Suppress diagnostic",
            "command": "suppress-diagnostic",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0,
                "unresolved-namespace"
            ]
        }
    },
    {
        "title": "Clean namespace",
        "kind": "source.organizeImports",
        "command": {
            "title": "Clean namespace",
            "command": "clean-ns",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                12
            ]
        }
    }
]

[Trace - 21:09:25] Received response 'textDocument/codeAction - (61)' in 4ms.
Result: [
    {
        "title": "Add require '[clojure-sample.a :as my-alias]' × 1",
        "kind": "quickfix",
        "isPreferred": true,
        "command": {
            "title": "Add require suggestion",
            "command": "add-require-suggestion",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0,
                "clojure-sample.a",
                "my-alias",
                null
            ]
        }
    },
    {
        "title": "Create namespace 'my-alias' and 'foo' function",
        "kind": "quickfix",
        "command": {
            "title": "Create function",
            "command": "create-function",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0
            ]
        }
    },
    {
        "title": "Suppress 'unresolved-namespace' diagnostic",
        "kind": "quickfix",
        "command": {
            "title": "Suppress diagnostic",
            "command": "suppress-diagnostic",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                0,
                "unresolved-namespace"
            ]
        }
    },
    {
        "title": "Clean namespace",
        "kind": "source.organizeImports",
        "command": {
            "title": "Clean namespace",
            "command": "clean-ns",
            "arguments": [
                "file:///home/cmdrdats/storage/ext/requiretest/src/clojure_sample/c.clj",
                3,
                12
            ]
        }
    }
]
ericdallo commented 2 years ago

c/c @bpringe @Cyrik it seems additionalTextEdits from completionItem/resolve is not being handled properly by Calva

riotrah commented 2 years ago

Down to do after multi cursor if no one else gets to it