BetterThanTomorrow / calva

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

Errors on every save when `source.organizeImports` is set in `editor.codeActionsOnSave` #2171

Open Limess opened 1 year ago

Limess commented 1 year ago

I'm seeing this popup whenever saving any file in Calva since a recent update, and these in the logs:

[Error - 11:43:36] Request workspace/executeCommand failed.
  Message: Nothing to change.
  Code: -32600 
[Error - 11:43:36] Request workspace/executeCommand failed.
  Message: Nothing to change.
  Code: -32600 
[Error - 11:43:37] Request workspace/executeCommand failed.
  Message: Nothing to change.
  Code: -32600 
[Error - 11:43:40] Request workspace/executeCommand failed.
  Message: Nothing to change.
  Code: -32600 
[Error - 11:43:40] Request workspace/executeCommand failed.
  Message: Nothing to change.
  Code: -32600 
[Error - 11:43:41] Request workspace/executeCommand failed.
  Message: Nothing to change.
  Code: -32600 
[Error - 11:43:41] Request workspace/executeCommand failed.
  Message: Nothing to change.
  Code: -32600 
[Error - 11:43:41] Request workspace/executeCommand failed.
  Message: Nothing to change.
  Code: -32600 
[Error - 11:43:42] Request workspace/executeCommand failed.
  Message: Nothing to change.
  Code: -32600 
[Error - 11:43:42] Request workspace/executeCommand failed.
  Message: Nothing to change.
  Code: -32600 
[Error - 11:43:43] Request workspace/executeCommand failed.
  Message: Nothing to change.
  Code: -32600 

I'm assuming this is the same issue as https://github.com/BetterThanTomorrow/calva/issues/2165, but wanted to open a new issue to confirm as the messaging is different, and not obviously tied to a specific action.

PEZ commented 1 year ago

It's good with a separate issue. I can't reproduce this one. What can you tell us about your setup? Operating system? Do you hava some settings for things that should happen on save?

I think that configuring Calva to use the previous version of clojure-lsp should get rid of the problem for you.

PEZ commented 1 year ago

Ping @bpringe @ericdallo . I think we need to figure out some way for Calva to filter away these notifications. Right now all I can think of is to create a an LSP proxy that Calva uses, but I hope there should be less complicated ways.

ericdallo commented 1 year ago

I'm wondering if it's the same issue, saving has nothing related to workspace/executeCommand.

I agree should have a way to filter that, not sure how unfortunately

Limess commented 1 year ago

Calva version v2.0.353

I've tried this on Windows and Mac and had the same issues,.

Calva settings:


  "calva.evalOnSave": true,
  "calva.paredit.defaultKeyMap": "original",
  // "calva.prettyPrintingOptions": {
  //   "enabled": true,
  //   "maxLength": 50,
  //   "printEngine": "pprint",
  //   "width": 100
  // },

Full settings (pretty beefy but included for completeness)

{
  "[go.mod]": {
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
    },
    "editor.formatOnSave": true
  },
  "[go]": {
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
    },
    "editor.formatOnSave": true,
    "editor.snippetSuggestions": "none"
  },
  "[handlebars]": {
    "editor.formatOnSave": false
  },
  "[html]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.formatOnSave": true
  },
  "[javascriptreact]": {
    "editor.formatOnSave": true
  },
  "[json]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[jsonc]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[markdown]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.formatOnSaveMode": "file"
  },
  "[python]": {
    "diffEditor.ignoreTrimWhitespace": false,
    "editor.codeActionsOnSave": {
      "source.fixAll.ruff": true
    },
    "editor.defaultFormatter": "ms-python.black-formatter",
    "editor.formatOnPaste": false,
    "editor.formatOnSave": true,
    "editor.formatOnSaveMode": "file",
    "editor.formatOnType": false
  },
  "[sql]": {
    "editor.defaultFormatter": "bradymholt.pgformatter",
    "editor.formatOnPaste": false,
    "editor.formatOnSave": false
  },
  "[yaml]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.formatOnSave": false
  },
  "breadcrumbs.enabled": true,
  "calva.evalOnSave": true,
  "calva.paredit.defaultKeyMap": "original",
  // "calva.prettyPrintingOptions": {
  //   "enabled": true,
  //   "maxLength": 50,
  //   "printEngine": "pprint",
  //   "width": 100
  // },
  "csharp.suppressDotnetInstallWarning": true,
  "css.validate": false,
  "editor.accessibilitySupport": "off",
  "editor.bracketPairColorization.enabled": true,
  "editor.codeActionsOnSave": {
    "source.addMissingImports": true,
    "source.fixAll": false,
    "source.fixAll.eslint": true,
    "source.fixAll.stylelint": true,
    "source.organizeImports": true
  },
  "editor.formatOnPaste": true,
  "editor.formatOnSave": true,
  "editor.formatOnSaveMode": "modificationsIfAvailable",
  "editor.inlineSuggest.enabled": true,
  "editor.largeFileOptimizations": false,
  "editor.multiCursorModifier": "ctrlCmd",
  "editor.renderWhitespace": "all",
  "editor.scrollBeyondLastLine": false,
  "editor.smoothScrolling": true,
  "editor.snippetSuggestions": "inline",
  "editor.suggest.localityBonus": true,
  "editor.suggestSelection": "first",
  "eslint.alwaysShowStatus": true,
  "eslint.run": "onSave",
  "explorer.confirmDelete": false,
  "explorer.confirmDragAndDrop": false,
  "extensions.ignoreRecommendations": false,
  "files.associations": {
    "*.boot": "clojure",
    "*.clj": "clojure",
    "*.css.mustache": "css",
    "*.hcl": "terraform",
    "*.js.mustache": "javascript",
    "*.mustache": "handlebars",
    "*.plk": "clojure",
    "*.template": "jinja-nginx",
    "*.yaml": "yaml",
    "Makefile.*": "makefile",
    "stderr": "plaintext",
    "stdout": "plaintext",
    "syslog": "plaintext"
  },
  "files.autoSave": "off",
  "files.eol": "\n",
  "files.exclude": {
    "**/.classpath": true,
    "**/.factorypath": true,
    "**/.lsp": true,
    "**/.metaflow.s3.*": true,
    "**/.metals": true,
    "**/.project": true,
    "**/.pytest_cache": true,
    "**/.ruff_cache": true,
    "**/.settings": true
  },
  "files.insertFinalNewline": true,
  "files.trimFinalNewlines": true,
  "files.trimTrailingWhitespace": true,
  "files.watcherExclude": {
    "**/.ammonite": true,
    "**/.bloop": true,
    "**/.metals": true
  },
  "git.autofetch": true,
  "git.confirmSync": false,
  "git.enableSmartCommit": true,
  "git.ignoreMissingGitWarning": true,
  "github.copilot.enable": {
    "*": true,
    "markdown": true,
    "plaintext": true,
    "yaml": true
  },
  "gitlens.advanced.messages": {
    "suppressGitMissingWarning": true
  },
  "gitlens.codeLens.enabled": true,
  "go.autocompleteUnimportedPackages": true,
  "go.docsTool": "gogetdoc",
  "go.formatFlags": ["-s"],
  "go.formatTool": "goimports",
  "go.inferGopath": true,
  "go.inlayHints.assignVariableTypes": true,
  "go.inlayHints.compositeLiteralFields": true,
  "go.inlayHints.compositeLiteralTypes": true,
  "go.inlayHints.constantValues": true,
  "go.inlayHints.functionTypeParameters": true,
  "go.inlayHints.parameterNames": true,
  "go.inlayHints.rangeVariableTypes": true,
  "go.lintFlags": ["--new"],
  "go.lintTool": "golangci-lint",
  "go.toolsManagement.autoUpdate": true,
  "go.useLanguageServer": true,
  "gopls": {
    "staticcheck": false,
    "usePlaceholders": true
  },
  "hadolint.hadolintPath": "/usr/local/bin/hadolint",
  "java.errors.incompleteClasspath.severity": "ignore",
  "java.semanticHighlighting.enabled": true,
  "javascript.format.enable": false,
  "javascript.updateImportsOnFileMove.enabled": "always",
  "jupyter.askForKernelRestart": false,
  "less.validate": false,
  "liveshare.allowGuestDebugControl": true,
  "liveshare.allowGuestTaskControl": true,
  "liveshare.languages.allowGuestCommandControl": true,
  "liveshare.publishWorkspaceInfo": true,
  "markdownlint.config": {
    "MD007": false,
    "MD010": false,
    "MD029": false,
    "MD030": false,
    "MD033": false,
    "MD036": false,
    "default": true
  },
  "notebook.cellToolbarLocation": {
    "default": "right",
    "jupyter-notebook": "left"
  },
  "notebook.lineNumbers": "on",
  "npm.keybindingsChangedWarningShown": true,
  "prettier.printWidth": 100,
  "python.analysis.autoImportCompletions": true,
  "python.analysis.autoImportUserSymbols": true,
  "python.analysis.inlayHints.functionReturnTypes": true,
  "python.analysis.inlayHints.pytestParameters": true,
  "python.analysis.typeCheckingMode": "basic",
  "python.diagnostics.sourceMapsEnabled": true,
  "python.formatting.provider": "black",
  "python.languageServer": "Pylance",
  "python.testing.pytestEnabled": true,
  "python.venvFolders": ["envs", ".pyenv", ".direnv", ".venv"],
  "redhat.telemetry.enabled": false,
  "remote.extensionKind": {
    "ms-azuretools.vscode-docker": "workspace"
  },
  "ruby.codeCompletion": "rcodetools",
  "ruby.format": false,
  "ruby.intellisense": "rubyLocate",
  "ruff.organizeImports": true,
  "scss.validate": false,
  "search.exclude": {
    "**/.calva": true,
    "**/.lsp": true,
    "**/.metals": true,
    "**/.pytest_cache": true,
    "**/.ruff_cache": true,
    "**/.target": true,
    "**/.terraform": true,
    "**/bower_components": true,
    "**/coverage": true,
    "**/node_modules": true
  },
  "security.workspace.trust.untrustedFiles": "open",
  "snipsnap.silent": true,
  "terraform.codelens.referenceCount": true,
  "terraform.experimentalFeatures.prefillRequiredFields": true,
  "typescript.format.enable": false,
  "vsicons.dontShowNewVersionMessage": true,
  "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
  "window.openFoldersInNewWindow": "on",
  "window.zoomLevel": 2,
  "workbench.activityBar.visible": true,
  "workbench.editor.showTabs": true,
  "workbench.editor.untitled.hint": "hidden",
  "workbench.editorAssociations": {
    "*.ipynb": "jupyter-notebook"
  },
  "workbench.fontAliasing": "auto",
  "workbench.iconTheme": "vscode-icons",
  "workbench.settings.editor": "json",
  "workbench.settings.useSplitJSON": true,
  "workbench.startupEditor": "newUntitledFile",
  "workbench.statusBar.visible": true,
  "yaml.format.enable": true,
  "yaml.validate": true,
  "errorLens.excludeBySource": ["Pylance(reportTypedDictNotRequiredAccess)"]
}
ericdallo commented 1 year ago

Would be nice if you could test with nightly clojure-lsp which fixed the known issue

Limess commented 1 year ago

Do you have instructions on downloading the nightly lsp build anywhere?

ericdallo commented 1 year ago

https://clojure-lsp.io/installation/#script or via Clojurians #clojure-lsp-dev-builds

PEZ commented 1 year ago

You can tell Calva to use the clojure-lsp nightly build in VS Code settings:

image
Limess commented 1 year ago

Thanks! I've tried to use nightly and I'm still seeing the same behaviour.

Weirdly it fires the notification multiple times during the jack in sequence. Each time I save a file, or evaluate something in a REPL it also logs twice to stdout.

Calva version used: v2.0.353
clojure-lsp version used: 2023.04.22-15.04.30-nightly
clj-kondo version used: 2023.04.15-SNAPSHOT

I can try cutting down extensions and settings again tomorrow to isolate this.

Limess commented 1 year ago

Aha! I have found the culprit:

"editor.codeActionsOnSave": {
    "source.organizeImports": true
}

I think I enabled this recently for https://github.com/charliermarsh/ruff-vscode.

For now I'll ensure this is off except for Python.

bpringe commented 1 year ago

I'm seeing this popup whenever saving any file in Calva since a recent update, and these in the logs:

@Limess Just to clarify, is the message in the popup the same as the errors from the logs? I just want to clarify since you said "I'm seeing this popup" but didn't add a screenshot or the popup message text.

Limess commented 1 year ago

Yes the popup matched the logs

ericdallo commented 1 year ago

@Limess that organizeImports should trigger clojure-lsp clean-ns refactoring, could you check if it's a exception that is happening on clojure-lsp side checking the server logs? I think calva has a command to open the server logs from VSCode

Limess commented 1 year ago

Clean NS Form doesn't produce any errors.

These are the LSP server logs after saving, when the error appears.

2023-04-25T13:19:58.417Z  INFO [clojure-lsp.handlers:441] - :code-actions 2ms
2023-04-25T13:19:58.849Z  INFO [clojure-lsp.handlers:441] - :code-actions 2ms
2023-04-25T13:19:58.857Z  INFO [clojure-lsp.handlers:441] - :code-actions 2ms
2023-04-25T13:19:58.864Z  INFO [clojure-lsp.handlers:441] - :code-actions 1ms
2023-04-25T13:19:58.872Z  INFO [clojure-lsp.handlers:441] - :code-actions 2ms
2023-04-25T13:19:58.923Z  INFO [clojure-lsp.handlers:389] - :execute-command 43ms
2023-04-25T13:19:59.006Z  INFO [clojure-lsp.handlers:188] - :did-save 0ms
2023-04-25T13:19:59.151Z  INFO [clojure-lsp.handlers:441] - :code-actions 0ms
2023-04-25T13:19:59.157Z  INFO [clojure-lsp.handlers:441] - :code-actions 0ms
2023-04-25T13:19:59.162Z  INFO [clojure-lsp.handlers:441] - :code-actions 0ms
2023-04-25T13:19:59.167Z  INFO [clojure-lsp.handlers:441] - :code-actions 0ms
2023-04-25T13:19:59.315Z  INFO [clojure-lsp.handlers:466] - :semantic-tokens-full 0ms
2023-04-25T13:20:00.342Z  INFO [clojure-lsp.dep-graph:269] - :maintain-dep-graph 0ms
2023-04-25T13:20:00.346Z  INFO [clojure-lsp.kondo:217] - Linting whole project for unused-public-var took 4ms
2023-04-25T13:20:00.346Z  WARN [clojure-lsp.kondo:325] - Non-fatal error from clj-kondo: No configs copied.

2023-04-25T13:20:00.347Z  INFO [clojure-lsp.feature.file-management:281] - Watched files analyzed, took 27ms
2023-04-25T13:20:00.347Z  INFO [clojure-lsp.dep-graph:269] - :maintain-dep-graph 0ms
2023-04-25T13:20:00.347Z  INFO [clojure-lsp.server:164] - :refreshing-test-tree 0ms
2023-04-25T13:20:00.347Z  INFO [clojure-lsp.server:556] - :analyze-files-in-watched-dir 28ms
2023-04-25T13:20:00.373Z  INFO [clojure-lsp.server:102] - :publish-diagnostics 0ms
ericdallo commented 1 year ago

Hum, so looks good from clojure-lsp side, maybe something in vscode is triggering something else after the clean-ns?