Open PEZ opened 2 years ago
clojure-lsp checks if the text sent during didOpen is empty here, so not sure it's a clojure-lsp bug, we would need to check client <-> server logs
Thanks! I should of course have thought about those logs. As I don't know where this log turns uninteresting I'll paste it in full:
[Trace - 3:51:21 PM] Sending notification '$/setTrace'.
Params: {
"value": "verbose"
}
[Trace - 3:51:38 PM] Sending request 'textDocument/semanticTokens/full - (814)'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj"
}
}
[Trace - 3:51:38 PM] Sending notification 'textDocument/didChange'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
"version": 2
},
"contentChanges": [
{
"text": "(ns fortytwo-lab\n (:require [clojure.string :as string]))\n\n;; Evaluate selection to Cursor\n(defn fortytwo-from-thirty\n []\n (let [thirty 30]\n (def thirty thirty)\n (-> thirty\n (->>\n inc\n (+ 1 2 3)\n (+ 2 2)\n (+))\n list\n (->>\n (into [1])\n (reduce + 1))\n (- 1)\n (* -1))))\n\n(comment\n (fortytwo-from-thirty) ;; => -42 (WRONG answer! (or question?))\n )\n"
}
]
}
[Trace - 3:51:38 PM] Sending notification 'textDocument/didOpen'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
"languageId": "clojure",
"version": 1,
"text": ""
}
}
[Trace - 3:51:38 PM] Received response 'textDocument/semanticTokens/full - (814)' in 2ms.
Result: {
"data": []
}
[Trace - 3:51:38 PM] Received request 'workspace/applyEdit - (7)'.
Params: {
"edit": {
"documentChanges": [
{
"textDocument": {
"version": 0,
"uri": "file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj"
},
"edits": [
{
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 999998,
"character": 999998
}
},
"newText": "(ns fortytwo-lab)"
}
]
}
]
}
}
[Trace - 3:51:38 PM] Sending notification 'textDocument/didSave'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj"
},
"text": "(ns fortytwo-lab\n (:require [clojure.string :as string]))\n\n;; Evaluate selection to Cursor\n(defn fortytwo-from-thirty\n []\n (let [thirty 30]\n (def thirty thirty)\n (-> thirty\n (->>\n inc\n (+ 1 2 3)\n (+ 2 2)\n (+))\n list\n (->>\n (into [1])\n (reduce + 1))\n (- 1)\n (* -1))))\n\n(comment\n (fortytwo-from-thirty) ;; => -42 (WRONG answer! (or question?))\n )\n"
}
[Trace - 3:51:38 PM] Sending request 'textDocument/documentSymbol - (815)'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj"
}
}
[Trace - 3:51:38 PM] Sending request 'textDocument/codeAction - (816)'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj"
},
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 0,
"character": 0
}
},
"context": {
"diagnostics": [],
"triggerKind": 2
}
}
[Trace - 3:51:38 PM] Sending notification '$/cancelRequest'.
Params: {
"id": 816
}
[Trace - 3:51:38 PM] Sending response 'workspace/applyEdit - (7)'. Processing request took 57ms
Result: {
"applied": true
}
[Trace - 3:51:38 PM] Received response 'textDocument/codeAction - (816)' in 5ms. Request failed: The request {:id 816, :method "textDocument/codeAction"} has been cancelled. (-32800).
Error data: {
"id": 816,
"method": "textDocument/codeAction"
}
[Trace - 3:51:38 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
"uri": "file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
"diagnostics": []
}
[Trace - 3:51:38 PM] Sending notification 'textDocument/didChange'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
"version": 3
},
"contentChanges": [
{
"text": "(ns fortytwo-lab)"
}
]
}
[Trace - 3:51:38 PM] Sending request 'textDocument/codeAction - (817)'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj"
},
"range": {
"start": {
"line": 0,
"character": 16
},
"end": {
"line": 0,
"character": 16
}
},
"context": {
"diagnostics": [],
"triggerKind": 2
}
}
[Trace - 3:51:38 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {
"changes": [
{
"uri": "file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
"type": 1
}
]
}
[Trace - 3:51:38 PM] Sending request 'textDocument/semanticTokens/full - (818)'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj"
}
}
[Trace - 3:51:38 PM] Sending notification '$/cancelRequest'.
Params: {
"id": 815
}
[Trace - 3:51:38 PM] Sending request 'textDocument/documentSymbol - (819)'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj"
}
}
[Trace - 3:51:38 PM] Received response 'textDocument/documentSymbol - (815)' in 351ms. Request failed: The request {:id 815, :method "textDocument/documentSymbol"} has been cancelled. (-32800).
Error data: {
"id": 815,
"method": "textDocument/documentSymbol"
}
[Trace - 3:51:39 PM] Received response 'textDocument/semanticTokens/full - (818)' in 227ms.
Result: {
"data": [
0,
4,
12,
0,
0
]
}
[Trace - 3:51:39 PM] Received response 'textDocument/codeAction - (817)' in 274ms.
Result: [
{
"title": "Change coll to vector",
"kind": "refactor",
"command": {
"title": "Change coll",
"command": "change-coll",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16,
"vector"
]
}
},
{
"title": "Change coll to set",
"kind": "refactor",
"command": {
"title": "Change coll",
"command": "change-coll",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16,
"set"
]
}
},
{
"title": "Change coll to map",
"kind": "refactor",
"command": {
"title": "Change coll",
"command": "change-coll",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16,
"map"
]
}
},
{
"title": "Move to let",
"kind": "refactor.extract",
"command": {
"title": "Move to let",
"command": "move-to-let",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16,
"new-binding"
]
}
},
{
"title": "Extract to def",
"kind": "refactor.extract",
"command": {
"title": "Extract to def",
"command": "extract-to-def",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16,
null
]
}
},
{
"title": "Move another expression to get/get-in",
"kind": "refactor.rewrite",
"command": {
"title": "Move another expression to get/get-in",
"command": "get-in-more",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16
]
}
},
{
"title": "Move all expressions to get/get-in",
"kind": "refactor.rewrite",
"command": {
"title": "Move all expressions to get/get-in",
"command": "get-in-all",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16
]
}
},
{
"title": "Sort list",
"kind": "refactor.rewrite",
"command": {
"title": "Sort list",
"command": "sort-clauses",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16
]
}
},
{
"title": "Introduce let",
"kind": "refactor.extract",
"command": {
"title": "Introduce let",
"command": "introduce-let",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16,
"new-binding"
]
}
},
{
"title": "Create test for 'fortytwo-lab'",
"kind": "refactor.rewrite",
"command": {
"title": "Create test",
"command": "create-test",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16
]
}
},
{
"title": "Clean namespace",
"kind": "source.organizeImports",
"command": {
"title": "Clean namespace",
"command": "clean-ns",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16
]
}
}
]
[Trace - 3:51:39 PM] Received response 'textDocument/documentSymbol - (819)' in 183ms.
Result: [
{
"name": "fortytwo-lab",
"kind": 3,
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 999999,
"character": 999999
}
},
"selectionRange": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 0,
"character": 17
}
},
"children": []
}
]
[Trace - 3:51:39 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
"uri": "file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
"diagnostics": []
}
[Trace - 3:51:39 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
"uri": "file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
"diagnostics": [
{
"range": {
"start": {
"line": 1,
"character": 13
},
"end": {
"line": 1,
"character": 27
}
},
"tags": [
1
],
"message": "namespace clojure.string is required but never used",
"code": "unused-namespace",
"severity": 2,
"source": "clj-kondo"
},
{
"range": {
"start": {
"line": 7,
"character": 4
},
"end": {
"line": 7,
"character": 23
}
},
"tags": [],
"message": "inline def",
"code": "inline-def",
"severity": 2,
"source": "clj-kondo"
},
{
"range": {
"start": {
"line": 7,
"character": 9
},
"end": {
"line": 7,
"character": 15
}
},
"tags": [
1
],
"message": "Unused public var 'fortytwo-lab/thirty'",
"code": "clojure-lsp/unused-public-var",
"severity": 3,
"source": "clojure-lsp"
}
]
}
[Trace - 3:51:40 PM] Sending request 'textDocument/codeAction - (820)'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj"
},
"range": {
"start": {
"line": 0,
"character": 16
},
"end": {
"line": 0,
"character": 16
}
},
"context": {
"diagnostics": [],
"triggerKind": 2
}
}
[Trace - 3:51:40 PM] Received response 'textDocument/codeAction - (820)' in 3ms.
Result: [
{
"title": "Move to let",
"kind": "refactor.extract",
"command": {
"title": "Move to let",
"command": "move-to-let",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16,
"new-binding"
]
}
},
{
"title": "Extract to def",
"kind": "refactor.extract",
"command": {
"title": "Extract to def",
"command": "extract-to-def",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16,
null
]
}
},
{
"title": "Sort list",
"kind": "refactor.rewrite",
"command": {
"title": "Sort list",
"command": "sort-clauses",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16
]
}
},
{
"title": "Drag backward",
"kind": "refactor.rewrite",
"command": {
"title": "Drag backward",
"command": "drag-backward",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16
]
}
},
{
"title": "Drag forward",
"kind": "refactor.rewrite",
"command": {
"title": "Drag forward",
"command": "drag-forward",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16
]
}
},
{
"title": "Introduce let",
"kind": "refactor.extract",
"command": {
"title": "Introduce let",
"command": "introduce-let",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16,
"new-binding"
]
}
},
{
"title": "Create test for 'fortytwo-lab'",
"kind": "refactor.rewrite",
"command": {
"title": "Create test",
"command": "create-test",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16
]
}
},
{
"title": "Clean namespace",
"kind": "source.organizeImports",
"command": {
"title": "Clean namespace",
"command": "clean-ns",
"arguments": [
"file:///Users/pez/.config/joyride/scripts/fortytwo_lab.clj",
0,
16
]
}
}
]
Maybe ... VS Code seems to first create an empty file and then save the text to it. clojure-lsp adds an ns and also does clean-ns is performed while the file is empty and returns with its results when the file text has been saved, replacing the text. I'm guessing wildly here. 😄
@PEZ the logs seems weird, how a didChange could be sent before a didOpen? Seems like you started recording the logs a little bit later, could you try to repro the minimal and paste logs since initialize request?
I started the logs, then clicked the unnamed file, and saved it. Not sure what I could do different. What is the initial request?
I think the steps are as mentioned here on 'Viewing the Logs Between the Client and Server'
Thanks!
[Trace - 11:36:23 PM] Sending request 'initialize - (0)'.
Params: {
"processId": 5807,
"clientInfo": {
"name": "Visual Studio Code",
"version": "1.72.1"
},
"locale": "en-us",
"rootPath": "/Users/pez/Projects/tests/minimal-deps",
"rootUri": "file:///Users/pez/Projects/tests/minimal-deps",
"capabilities": {
"workspace": {
"applyEdit": true,
"workspaceEdit": {
"documentChanges": true,
"resourceOperations": [
"create",
"rename",
"delete"
],
"failureHandling": "textOnlyTransactional",
"normalizesLineEndings": true,
"changeAnnotationSupport": {
"groupsOnLabel": true
}
},
"configuration": true,
"didChangeWatchedFiles": {
"dynamicRegistration": true,
"relativePatternSupport": true
},
"symbol": {
"dynamicRegistration": true,
"symbolKind": {
"valueSet": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26
]
},
"tagSupport": {
"valueSet": [
1
]
},
"resolveSupport": {
"properties": [
"location.range"
]
}
},
"codeLens": {
"refreshSupport": true
},
"executeCommand": {
"dynamicRegistration": true
},
"didChangeConfiguration": {
"dynamicRegistration": true
},
"workspaceFolders": true,
"semanticTokens": {
"refreshSupport": true
},
"fileOperations": {
"dynamicRegistration": true,
"didCreate": true,
"didRename": true,
"didDelete": true,
"willCreate": true,
"willRename": true,
"willDelete": true
},
"inlineValue": {
"refreshSupport": true
},
"inlayHint": {
"refreshSupport": true
},
"diagnostics": {
"refreshSupport": true
}
},
"textDocument": {
"publishDiagnostics": {
"relatedInformation": true,
"versionSupport": false,
"tagSupport": {
"valueSet": [
1,
2
]
},
"codeDescriptionSupport": true,
"dataSupport": true
},
"synchronization": {
"dynamicRegistration": true,
"willSave": true,
"willSaveWaitUntil": true,
"didSave": true
},
"completion": {
"dynamicRegistration": true,
"contextSupport": true,
"completionItem": {
"snippetSupport": true,
"commitCharactersSupport": true,
"documentationFormat": [
"markdown",
"plaintext"
],
"deprecatedSupport": true,
"preselectSupport": true,
"tagSupport": {
"valueSet": [
1
]
},
"insertReplaceSupport": true,
"resolveSupport": {
"properties": [
"documentation",
"detail",
"additionalTextEdits"
]
},
"insertTextModeSupport": {
"valueSet": [
1,
2
]
},
"labelDetailsSupport": true
},
"insertTextMode": 2,
"completionItemKind": {
"valueSet": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25
]
},
"completionList": {
"itemDefaults": [
"commitCharacters",
"editRange",
"insertTextFormat",
"insertTextMode"
]
}
},
"hover": {
"dynamicRegistration": true,
"contentFormat": [
"markdown",
"plaintext"
]
},
"signatureHelp": {
"dynamicRegistration": true,
"signatureInformation": {
"documentationFormat": [
"markdown",
"plaintext"
],
"parameterInformation": {
"labelOffsetSupport": true
},
"activeParameterSupport": true
},
"contextSupport": true
},
"definition": {
"dynamicRegistration": true,
"linkSupport": true
},
"references": {
"dynamicRegistration": true
},
"documentHighlight": {
"dynamicRegistration": true
},
"documentSymbol": {
"dynamicRegistration": true,
"symbolKind": {
"valueSet": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26
]
},
"hierarchicalDocumentSymbolSupport": true,
"tagSupport": {
"valueSet": [
1
]
},
"labelSupport": true
},
"codeAction": {
"dynamicRegistration": true,
"isPreferredSupport": true,
"disabledSupport": true,
"dataSupport": true,
"resolveSupport": {
"properties": [
"edit"
]
},
"codeActionLiteralSupport": {
"codeActionKind": {
"valueSet": [
"",
"quickfix",
"refactor",
"refactor.extract",
"refactor.inline",
"refactor.rewrite",
"source",
"source.organizeImports"
]
}
},
"honorsChangeAnnotations": false
},
"codeLens": {
"dynamicRegistration": true
},
"formatting": {
"dynamicRegistration": true
},
"rangeFormatting": {
"dynamicRegistration": true
},
"onTypeFormatting": {
"dynamicRegistration": true
},
"rename": {
"dynamicRegistration": true,
"prepareSupport": true,
"prepareSupportDefaultBehavior": 1,
"honorsChangeAnnotations": true
},
"documentLink": {
"dynamicRegistration": true,
"tooltipSupport": true
},
"typeDefinition": {
"dynamicRegistration": true,
"linkSupport": true
},
"implementation": {
"dynamicRegistration": true,
"linkSupport": true
},
"colorProvider": {
"dynamicRegistration": true
},
"foldingRange": {
"dynamicRegistration": true,
"rangeLimit": 5000,
"lineFoldingOnly": true,
"foldingRangeKind": {
"valueSet": [
"comment",
"imports",
"region"
]
},
"foldingRange": {
"collapsedText": false
}
},
"declaration": {
"dynamicRegistration": true,
"linkSupport": true
},
"selectionRange": {
"dynamicRegistration": true
},
"callHierarchy": {
"dynamicRegistration": true
},
"semanticTokens": {
"dynamicRegistration": true,
"tokenTypes": [
"namespace",
"type",
"class",
"enum",
"interface",
"struct",
"typeParameter",
"parameter",
"variable",
"property",
"enumMember",
"event",
"function",
"method",
"macro",
"keyword",
"modifier",
"comment",
"string",
"number",
"regexp",
"operator",
"decorator"
],
"tokenModifiers": [
"declaration",
"definition",
"readonly",
"static",
"deprecated",
"abstract",
"async",
"modification",
"documentation",
"defaultLibrary"
],
"formats": [
"relative"
],
"requests": {
"range": true,
"full": {
"delta": true
}
},
"multilineTokenSupport": false,
"overlappingTokenSupport": false,
"serverCancelSupport": true,
"augmentsSyntaxTokens": true
},
"linkedEditingRange": {
"dynamicRegistration": true
},
"typeHierarchy": {
"dynamicRegistration": true
},
"inlineValue": {
"dynamicRegistration": true
},
"inlayHint": {
"dynamicRegistration": true,
"resolveSupport": {
"properties": [
"tooltip",
"textEdits",
"label.tooltip",
"label.location",
"label.command"
]
}
},
"diagnostic": {
"dynamicRegistration": true,
"relatedDocumentSupport": false
}
},
"window": {
"showMessage": {
"messageActionItem": {
"additionalPropertiesSupport": true
}
},
"showDocument": {
"support": true
},
"workDoneProgress": true
},
"general": {
"staleRequestSupport": {
"cancel": true,
"retryOnContentModified": [
"textDocument/semanticTokens/full",
"textDocument/semanticTokens/range",
"textDocument/semanticTokens/full/delta"
]
},
"regularExpressions": {
"engine": "ECMAScript",
"version": "ES2020"
},
"markdown": {
"parser": "marked",
"version": "1.1.0"
},
"positionEncodings": [
"utf-16"
]
},
"notebookDocument": {
"synchronization": {
"dynamicRegistration": true,
"executionSummarySupport": true
}
},
"experimental": {
"testTree": true
}
},
"initializationOptions": {
"dependency-scheme": "jar",
"auto-add-ns-to-new-files?": true,
"document-formatting?": false,
"document-range-formatting?": false,
"keep-require-at-start?": true
},
"trace": "verbose",
"workspaceFolders": [
{
"uri": "file:///Users/pez/Projects/tests/minimal-deps",
"name": "minimal-deps"
}
],
"workDoneToken": "9c155777-f1c2-4964-bed3-87c4f152abfd"
}
[Trace - 11:36:23 PM] Received notification '$/progress'.
Params: {
"token": "9c155777-f1c2-4964-bed3-87c4f152abfd",
"value": {
"kind": "begin",
"title": "clojure-lsp",
"percentage": 0
}
}
[Trace - 11:36:23 PM] Received notification '$/progress'.
Params: {
"token": "9c155777-f1c2-4964-bed3-87c4f152abfd",
"value": {
"kind": "report",
"title": "Finding kondo config",
"percentage": 5
}
}
[Trace - 11:36:23 PM] Received notification '$/progress'.
Params: {
"token": "9c155777-f1c2-4964-bed3-87c4f152abfd",
"value": {
"kind": "report",
"title": "Finding cache",
"percentage": 10
}
}
[Trace - 11:36:23 PM] Received notification '$/progress'.
Params: {
"token": "9c155777-f1c2-4964-bed3-87c4f152abfd",
"value": {
"kind": "report",
"title": "Copying kondo configs",
"percentage": 15
}
}
[Trace - 11:36:23 PM] Received notification '$/progress'.
Params: {
"token": "9c155777-f1c2-4964-bed3-87c4f152abfd",
"value": {
"kind": "report",
"title": "Resolving config paths",
"percentage": 15
}
}
[Trace - 11:36:23 PM] Received notification '$/progress'.
Params: {
"token": "9c155777-f1c2-4964-bed3-87c4f152abfd",
"value": {
"kind": "report",
"title": "Analyzing project files",
"percentage": 20
}
}
[Trace - 11:36:23 PM] Received notification '$/progress'.
Params: {
"token": "9c155777-f1c2-4964-bed3-87c4f152abfd",
"value": {
"kind": "report",
"title": "Analyzing project files",
"percentage": 99
}
}
[Trace - 11:36:23 PM] Received notification '$/progress'.
Params: {
"token": "9c155777-f1c2-4964-bed3-87c4f152abfd",
"value": {
"kind": "end",
"title": "Project analyzed",
"percentage": 100
}
}
[Trace - 11:36:23 PM] Received response 'initialize - (0)' in 208ms.
Result: {
"capabilities": {
"documentSymbolProvider": true,
"textDocumentSync": {
"openClose": true,
"change": 1,
"save": {
"includeText": true
}
},
"declarationProvider": true,
"semanticTokensProvider": {
"legend": {
"tokenTypes": [
"namespace",
"type",
"function",
"macro",
"keyword",
"class",
"variable",
"method",
"event"
],
"tokenModifiers": [
"definition",
"defaultLibrary",
"implementation"
]
},
"range": true,
"full": true
},
"linkedEditingRangeProvider": true,
"workspaceSymbolProvider": true,
"experimental": {
"testTree": true,
"cursorInfo": true,
"serverInfo": true,
"clojuredocs": true
},
"codeActionProvider": {
"codeActionKinds": [
"quickfix",
"refactor",
"refactor.extract",
"refactor.inline",
"refactor.rewrite",
"source",
"source.organizeImports"
]
},
"documentHighlightProvider": true,
"completionProvider": {
"resolveProvider": true,
"triggerCharacters": [
":",
"/"
]
},
"workspace": {
"fileOperations": {
"willRename": {
"filters": [
{
"scheme": "file",
"pattern": {
"glob": "**/*.{clj,cljs,cljc,cljd,edn,bb,clj_kondo}",
"matches": "file"
}
}
]
}
}
},
"implementationProvider": true,
"signatureHelpProvider": {
"triggerCharacters": []
},
"documentRangeFormattingProvider": false,
"executeCommandProvider": {
"commands": [
"add-import-to-namespace",
"add-missing-import",
"add-missing-libspec",
"add-require-suggestion",
"change-coll",
"clean-ns",
"create-function",
"create-test",
"cycle-coll",
"cycle-privacy",
"demote-fn",
"destructure-keys",
"drag-backward",
"drag-forward",
"expand-let",
"extract-function",
"extract-to-def",
"get-in-all",
"get-in-less",
"get-in-more",
"get-in-none",
"inline-symbol",
"introduce-let",
"move-coll-entry-down",
"move-coll-entry-up",
"move-form",
"move-to-let",
"promote-fn",
"resolve-macro-as",
"restructure-keys",
"sort-clauses",
"sort-map",
"suppress-diagnostic",
"thread-first",
"thread-first-all",
"thread-last",
"thread-last-all",
"unwind-all",
"unwind-thread"
]
},
"referencesProvider": true,
"codeLensProvider": {
"resolveProvider": true
},
"callHierarchyProvider": true,
"documentFormattingProvider": false,
"renameProvider": {
"prepareProvider": true
},
"definitionProvider": true,
"hoverProvider": true
}
}
[Trace - 11:36:23 PM] Sending notification 'initialized'.
Params: {}
[Trace - 11:36:23 PM] Sending notification 'workspace/didChangeConfiguration'.
Params: {
"settings": {}
}
[Trace - 11:36:23 PM] Sending request 'clojure/serverInfo/raw - (1)'.
[Trace - 11:36:23 PM] Received request 'client/registerCapability - (1)'.
Params: {
"registrations": [
{
"id": "id",
"method": "workspace/didChangeWatchedFiles",
"registerOptions": {
"watchers": [
{
"globPattern": "**/*.{clj,cljs,cljc,cljd,edn,bb,clj_kondo}"
}
]
}
}
]
}
[Trace - 11:36:23 PM] Sending response 'client/registerCapability - (1)'. Processing request took 0ms
No result returned.
[Trace - 11:36:23 PM] Received response 'clojure/serverInfo/raw - (1)' in 8ms.
Result: {
"log-path": "/tmp/clojure-lsp.out",
"project-settings": {
"log-path": "/tmp/clojure-lsp.out"
},
"classpath": [
"/Users/pez/.m2/repository/org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar",
"src",
"/Users/pez/.m2/repository/org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar",
"/Users/pez/.m2/repository/nrepl/nrepl/0.9.0/nrepl-0.9.0.jar",
"/Users/pez/.m2/repository/cider/cider-nrepl/0.27.4/cider-nrepl-0.27.4.jar",
"test",
"/Users/pez/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar"
],
"project-root-uri": "file:///Users/pez/Projects/tests/minimal-deps",
"client-settings": {
"auto-add-ns-to-new-files?": true,
"document-formatting?": false,
"dependency-scheme": "jar",
"keep-require-at-start?": true,
"source-paths": null,
"text-document-sync-kind": null,
"source-aliases": null,
"document-range-formatting?": false,
"cljfmt-config-path": ".cljfmt.edn"
},
"clj-kondo-version": "2022.10.05",
"server-version": "2022.10.06-12.49.56-nightly",
"port": "NREPL only available on :debug profile (`bb debug-cli`)",
"final-settings": {
"log-path": "/tmp/clojure-lsp.out",
"auto-add-ns-to-new-files?": true,
"document-formatting?": false,
"dependency-scheme": "jar",
"keep-require-at-start?": true,
"source-paths": [
"/Users/pez/Projects/tests/minimal-deps/src",
"/Users/pez/Projects/tests/minimal-deps/test"
],
"project-specs": [
{
"project-path": "project.clj",
"classpath-cmd": [
"/opt/homebrew/bin/lein",
"with-profile",
"+test,+dev",
"classpath"
]
},
{
"project-path": "deps.edn",
"classpath-cmd": [
"/opt/homebrew/bin/clojure",
"-A:test:dev",
"-Spath"
]
},
{
"project-path": "build.boot",
"classpath-cmd": [
"boot",
"show",
"--fake-classpath"
]
},
{
"project-path": "shadow-cljs.edn",
"classpath-cmd": [
"/opt/homebrew/bin/npx",
"shadow-cljs",
"classpath"
]
},
{
"project-path": "bb.edn",
"classpath-cmd": [
"/Users/pez/binaries/bb",
"print-deps",
"--format",
"classpath"
]
}
],
"text-document-sync-kind": null,
"source-aliases": [
"test",
"dev"
],
"uri-format": {
"upper-case-drive-letter?": false,
"encode-colons-in-path?": false
},
"document-range-formatting?": false,
"cljfmt-config-path": ".cljfmt.edn"
},
"classpath-settings": null,
"cljfmt-raw": "{}"
}
[Trace - 11:36:24 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/hello.clj",
"diagnostics": [
{
"range": {
"start": {
"line": 1,
"character": 13
},
"end": {
"line": 1,
"character": 27
}
},
"tags": [
1
],
"message": "namespace clojure.string is required but never used",
"code": "unused-namespace",
"severity": 2,
"source": "clj-kondo"
},
{
"range": {
"start": {
"line": 3,
"character": 6
},
"end": {
"line": 3,
"character": 9
}
},
"tags": [
1
],
"message": "Unused public var 'hello/bar'",
"code": "clojure-lsp/unused-public-var",
"severity": 3,
"source": "clojure-lsp"
}
]
}
[Trace - 11:36:32 PM] Sending notification 'textDocument/didChange'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj",
"version": 2
},
"contentChanges": [
{
"text": "(ns foo\n (:require [clojure.string :as string]))\n\n(defn bar\n []\n (let [x 1]\n x))"
}
]
}
[Trace - 11:36:32 PM] Sending notification 'textDocument/didOpen'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj",
"languageId": "clojure",
"version": 1,
"text": ""
}
}
[Trace - 11:36:32 PM] Sending request 'textDocument/semanticTokens/full - (2)'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj"
}
}
[Trace - 11:36:32 PM] Received request 'workspace/applyEdit - (2)'.
Params: {
"edit": {
"documentChanges": [
{
"textDocument": {
"version": 0,
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj"
},
"edits": [
{
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 999998,
"character": 999998
}
},
"newText": "(ns foo)"
}
]
}
]
}
}
[Trace - 11:36:32 PM] Sending notification 'textDocument/didSave'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj"
},
"text": "(ns foo\n (:require [clojure.string :as string]))\n\n(defn bar\n []\n (let [x 1]\n x))"
}
[Trace - 11:36:32 PM] Sending request 'textDocument/documentSymbol - (3)'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj"
}
}
[Trace - 11:36:32 PM] Sending request 'textDocument/codeAction - (4)'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj"
},
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 0,
"character": 0
}
},
"context": {
"diagnostics": [],
"triggerKind": 2
}
}
[Trace - 11:36:32 PM] Sending notification '$/cancelRequest'.
Params: {
"id": 4
}
[Trace - 11:36:32 PM] Sending response 'workspace/applyEdit - (2)'. Processing request took 58ms
Result: {
"applied": true
}
[Trace - 11:36:32 PM] Received response 'textDocument/codeAction - (4)' in 11ms. Request failed: The request {:id 4, :method "textDocument/codeAction"} has been cancelled. (-32800).
Error data: {
"id": 4,
"method": "textDocument/codeAction"
}
[Trace - 11:36:32 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj",
"diagnostics": []
}
[Trace - 11:36:32 PM] Sending notification 'textDocument/didChange'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj",
"version": 3
},
"contentChanges": [
{
"text": "(ns foo)"
}
]
}
[Trace - 11:36:32 PM] Sending request 'textDocument/codeAction - (5)'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj"
},
"range": {
"start": {
"line": 0,
"character": 8
},
"end": {
"line": 0,
"character": 8
}
},
"context": {
"diagnostics": [],
"triggerKind": 2
}
}
[Trace - 11:36:32 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {
"changes": [
{
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj",
"type": 1
}
]
}
[Trace - 11:36:32 PM] Sending request 'textDocument/semanticTokens/range - (6)'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj"
},
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 0,
"character": 8
}
}
}
[Trace - 11:36:32 PM] Received response 'textDocument/semanticTokens/range - (6)' in 15ms.
Result: {
"data": [
0,
4,
3,
0,
0
]
}
[Trace - 11:36:32 PM] Received response 'textDocument/codeAction - (5)' in 267ms.
Result: [
{
"title": "Clean namespace",
"kind": "source.organizeImports",
"command": {
"title": "Clean namespace",
"command": "clean-ns",
"arguments": [
"file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj",
0,
8
]
}
}
]
[Trace - 11:36:32 PM] Received response 'textDocument/semanticTokens/full - (2)' in 596ms.
Result: {
"data": [
0,
4,
3,
0,
0
]
}
[Trace - 11:36:32 PM] Received response 'textDocument/documentSymbol - (3)' in 574ms.
Result: [
{
"name": "foo",
"kind": 3,
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 999999,
"character": 999999
}
},
"selectionRange": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 0,
"character": 8
}
},
"children": []
}
]
[Trace - 11:36:32 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj",
"diagnostics": []
}
[Trace - 11:36:33 PM] Sending request 'textDocument/documentSymbol - (7)'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj"
}
}
[Trace - 11:36:33 PM] Received response 'textDocument/documentSymbol - (7)' in 1ms.
Result: [
{
"name": "foo",
"kind": 3,
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 999999,
"character": 999999
}
},
"selectionRange": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 0,
"character": 8
}
},
"children": []
}
]
[Trace - 11:36:33 PM] Sending request 'textDocument/semanticTokens/full - (8)'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj"
}
}
[Trace - 11:36:33 PM] Received response 'textDocument/semanticTokens/full - (8)' in 1ms.
Result: {
"data": [
0,
4,
3,
0,
0
]
}
[Trace - 11:36:33 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj",
"diagnostics": [
{
"range": {
"start": {
"line": 1,
"character": 13
},
"end": {
"line": 1,
"character": 27
}
},
"tags": [
1
],
"message": "namespace clojure.string is required but never used",
"code": "unused-namespace",
"severity": 2,
"source": "clj-kondo"
},
{
"range": {
"start": {
"line": 3,
"character": 6
},
"end": {
"line": 3,
"character": 9
}
},
"tags": [
1
],
"message": "Unused public var 'foo/bar'",
"code": "clojure-lsp/unused-public-var",
"severity": 3,
"source": "clojure-lsp"
}
]
}
[Trace - 11:36:34 PM] Sending request 'textDocument/codeAction - (9)'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj"
},
"range": {
"start": {
"line": 0,
"character": 8
},
"end": {
"line": 0,
"character": 8
}
},
"context": {
"diagnostics": [],
"triggerKind": 2
}
}
[Trace - 11:36:34 PM] Received response 'textDocument/codeAction - (9)' in 4ms.
Result: [
{
"title": "Move to let",
"kind": "refactor.extract",
"command": {
"title": "Move to let",
"command": "move-to-let",
"arguments": [
"file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj",
0,
8,
"new-binding"
]
}
},
{
"title": "Extract to def",
"kind": "refactor.extract",
"command": {
"title": "Extract to def",
"command": "extract-to-def",
"arguments": [
"file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj",
0,
8,
null
]
}
},
{
"title": "Sort list",
"kind": "refactor.rewrite",
"command": {
"title": "Sort list",
"command": "sort-clauses",
"arguments": [
"file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj",
0,
8
]
}
},
{
"title": "Drag backward",
"kind": "refactor.rewrite",
"command": {
"title": "Drag backward",
"command": "drag-backward",
"arguments": [
"file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj",
0,
8
]
}
},
{
"title": "Drag forward",
"kind": "refactor.rewrite",
"command": {
"title": "Drag forward",
"command": "drag-forward",
"arguments": [
"file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj",
0,
8
]
}
},
{
"title": "Introduce let",
"kind": "refactor.extract",
"command": {
"title": "Introduce let",
"command": "introduce-let",
"arguments": [
"file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj",
0,
8,
"new-binding"
]
}
},
{
"title": "Clean namespace",
"kind": "source.organizeImports",
"command": {
"title": "Clean namespace",
"command": "clean-ns",
"arguments": [
"file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj",
0,
8
]
}
}
]
So, it's a weird behavior, it seems that the issue is on this part:
[Trace - 11:36:32 PM] Sending notification 'textDocument/didChange'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj",
"version": 2
},
"contentChanges": [
{
"text": "(ns foo\n (:require [clojure.string :as string]))\n\n(defn bar\n []\n (let [x 1]\n x))"
}
]
}
[Trace - 11:36:32 PM] Sending notification 'textDocument/didOpen'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/Projects/tests/minimal-deps/src/foo.clj",
"languageId": "clojure",
"version": 1,
"text": ""
}
}
Vscode sends a didChange before a didOpen and the spec says:
Before a client can change a text document it must claim ownership of its content using the textDocument/didOpen notification.
So it seems to me to be a bug on the LSP client library
Thanks! A quite scary bug. The user can actually undo the change, but if you don't realize that, you'll think that all your work in that file is gone...
Yes, we could maybe do a hack on clojure-lsp to avoid that, but sounds like fixing that and not following the spec what I'd try to avoid
@PEZ You could file an issue here if you want: https://github.com/microsoft/vscode-languageserver-node. It does look like a bug in that lib.
I understand the subject too poorly to formulate an issue. If someone else can file it, it would be great!
I think this will be fixed in the next release of the language client lib (8.1.0): https://github.com/microsoft/vscode-languageserver-node/issues/1105#issuecomment-1296951826
I think this upstream fix is released. We need to update the dep to a version >= 8.1.0 and test.
Hi, I noted that the file also gets erased (up to the ns form) when using save-as in VSCode. I'm on WSL2 (Ubuntu), Windows version of VSCode 1.82.2 . Calva version used: v2.0.394 clojure-lsp version used: 2023.10.30-16.25.41 clj-kondo version used: 2023.10.21-SNAPSHOT
I had an untitled file (created with
cmd+n
) with some content. When I saved it, naming it according to its namespace, the content was wiped.Steps to reproduce:
1 cmd+n
2 Enter this code (set to Clojure file type if VS Code doesn't autodetect)
3 Save the file as
src/foo.clj
(assuming"src"
is in your classpath)Expected: File content is preserved
Actual: File content is:
I think this is upstream, in clojure-lsp, but I haven't investigated that, so filing it here and pinging @ericdallo for a second guess.