Fork me on GitHub
#calva
<
2022-10-31
>
dumrat11:10:05

I picked up the habit of putting a comma at the end of a comment block to preserve new lines and prevent closing parenthesis from sticking to the forms inside:

(comment
  (some stuff)
  ,)
However, if I press tab in calva to reformat, everything reformats and comma is deleted and it becomes this:
(comment
  (some stuff)
)
Anyone encountered this? How to prevent this?

pithyless11:10:03

This happens with some auto-formatters. Some will even remove the comma and clean up the ) by moving it up to the previous a line. I've gotten used to doing this:

(comment
  (some stuff)
#__)
So far no auto-formatter I've come across in any editor has messed with it. :)

pithyless11:10:30

Notice the second _ is not magic, it could be anything that is commented via #_, but I like the visual look :)

👍 1
dumrat11:10:44

ok, I will use this

wevrem15:10:21

What is it that you want to prevent, the deletion of the comma? Calva used to (maybe a year ago? maybe longer?) pull that trailing paren up to the line above, which I didn’t like at all. The fact that it now keeps the paren on its own line is good.

pithyless15:10:05

The problem for me was that the dangling paren was cleaned up by some linters and autoformatters. When working on a team where people use different tools and editors, I've gotten used to just ending my rich comment forms with #__) to avoid any editor accidentally creating change diffs when saving files.

dumrat15:10:20

@UTFAPNRPT Yes, I remember Calva deleting the line and pulling the paren above. It no longer seems to do it. But I don't like it deleting the comma - perhaps Now it's not much of an issue because the line doesn't get deleted.

pez15:10:42

Using the ignore tag is the safest here if working within a team. Someone is bound to use some tool deleting those commas. Like cljfmt, which is what Calva is using. I don’t think it offers a way to keep them.

👍 1
pez15:10:40

Or, do what I do. Allow it to get closed. Open it again by pressing tab in Calva.

dumrat15:10:53

@U0ETXRFEW Ignore tag seems fine, only gripe is it's 3 keystrokes instead of 1 😄

pithyless16:10:25

Maybe go all in and model some of the other languages with start/end symmetry:

#_commment)

#_endcomment)

#_tnemmoc)

;; or maybe docstrings, if it's a big block:
(comment "2k lines of rambling"
,,
,,
#_"2k lines of rambling")
😅

😂 3
Pragyan Tripathi07:11:30

I use following:

(comment

   ;; Do something
   ;; Hello World

  :rich-comment)

clojure-spin 1
pez07:11:02

I like that one! It is nice when searching the code base as well. :rcf I might use instead.

👍 2
pez08:11:07

This snippet does it. Maybe we should include that in Calva...

"RCF": {
		"prefix": "(rcf",
		"body": [
			"(comment",
			"  $0",
			"  :rcf"
		],
		"description": "RCF"
	}

❤️ 3
🎉 3
pithyless08:11:51

This has an interesting side-effect, that if someone accidentally evaluates the entire comment (vs something inside the comment), they will see :rcf and not nil -> and may realize quicker that is probably not what they wanted to do.

👍 1
💯 1
pez15:11:29

It's not easy to evaluate everything inside a (commen ..), though? Is that something people do?

pez12:10:11

Dear Calva friends: https://github.com/BetterThanTomorrow/calva/releases/tag/v2.0.313https://github.com/BetterThanTomorrow/calva/issues/1924 • Fix: https://github.com/BetterThanTomorrow/calva/issues/1927 If you find anything funny with the formatting done after Paredit edit commands are performed, please report.

Seb17:10:29

👋 Hello When I use Calva without a REPL connected, showing references of a function works totally fine. However, as soon as I connect to the repl, it doesn't work anymore. I have no idea how to fix it, any suggestions?

pez17:10:54

Hi! This means you don’t have the nrepl dependencies properly working. How are you starting the repl?

Robert Wood08:11:36

I have been having the same issue using: Calva: Connect to a Running REPL Server in the Project How would one debug the nrepl dependencies?

pez08:11:27

When Calva starts it outputs the configured nrepl dependencies in the Calva says Output channel. These are the ones your project needs. (Piggieback only needed for ClojureScript, so don't add that in a Clojure-only project).

pez09:11:50

Calva has a command for copying the command line it would use if it was to start the REPL for you. Calva Copy Jack-in Command to Clipboard. So that's one way to get your REPL started with the needed dependencies. Otherwise your user config or the project config are places to configure this.

Robert Wood10:11:38

Okay so looking through the deps the only one not in my project.clj was piggieback. Adding it doesn't seem to resolve the issue. Is there any nuance when connecting to a repl running from an uberjar? (jumping through a portforward of the nrepl port) The definitions will navigate to the correct ns but the file presented is empty. Another similar but distinct issue is when using: Go to Definition I am able to navigate to the definition from a callsite. I am also able to navigate to a callsite from the definition using the same action. After connection to the repl. the first remains true but the second changes. What happens is that instead of allowing you to peek the function calls, it pulls your cursor to the front of the form. If you press the action again then it takes you to the definiton of def (Which makes sense considering where the cursor is.) It might be important to note that the inverse action Go to References Still works as one would expect.

Robert Wood10:11:29

And to be specific issue 1 occurs on uberjar repl While issue 2 occurs lein run repl.

pez10:11:23

I'm not in-the-know about how to make it work with the uberjar REPL. If the REPL seems to be otherwise working, you can try change the default definition priority, calva.definitionProviderPriority to prefer lsp over nrepl for lookups.

🙌 1
pez10:11:24

Piggieback only comes into play with ClojureScript repls. So be sure to test that particular dependency with ClojureScript.

pez10:11:52

> it pulls your cursor to the front of the form This sounds very strange. Maybe you have some keyboard shortcut bound to two actions? Try using the command palette and see what the actual commands do.

Robert Wood11:11:46

So there are no other actions with the action that I use. My working suspicion is that in trying to "Go to Definition" It takes you to the definition and puts you at the start of the form. It just so happens that you are already at the definition and so the apparent result is that it just pulls the cursor forward. I will try change the priority now and see if that would be a reasonable workaround.

Robert Wood11:11:26

Setting the following:

"calva.definitionProviderPriority":[
        "lsp",
        "repl"
    ]
Solved both of my problems. @U0ETXRFEW You are a legend, thanks for the patience and help :dancer:

pez11:11:14

Cool. Please note that you might have an nrepl dependency problem still just not visible that way.

👍 1
julienvincent14:01:26

@U0ETXRFEW I am running into the same issue in all the following cases: • Running the build-in calva jack-in command • Running the copy-paste jack-in command and running it from terminal, then connect by running the calva.connect command Setting calva.definitionProviderPriority to ["lsp", "repl"] has no effect. In fact, weirdly, when trying to set this from the settings interface it gets immediately set back to repl, lsp in the interface when I click off the field. Setting it in the JSON settings file has no effect on the behaviour. This feels like a bug? Any assistance would be greatly appreciated. This is a hard blocker for using Calva for me.

pez14:01:52

@U04HKE0BTC5, what kind of project are you working with? (lein/deps/shadow-cljs/etc).

julienvincent14:01:04

Here you can see how in the interface it is still showing repl, lsp but in settings it is set correctly

julienvincent14:01:12

This is a deps project

pez14:01:29

Any aliases in the project that deals with nrepl deps or provides main args?

julienvincent14:01:30

Yes, I translated the “copy jack-in command” into a home-dir alias that looks like:

❯ cat ~/.clojure/deps.edn
{:aliases {:nrepl {:extra-deps {nrepl/nrepl {:mvn/version "1.0.0"}
                                cider/cider-nrepl {:mvn/version "0.28.5"}}
                   :main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}}}

pez14:01:09

Are you using that alias when jacking in?

julienvincent14:01:12

And then I run the repl with clojure -A:nrepl

julienvincent14:01:35

Followed by running the calva.connect remote connection

julienvincent14:01:59

But the issue is the same even if I use calva’s build-in jack-in

pez14:01:33

Does references and such work before you connect the REPL?

julienvincent14:01:37

Correct. LSP seems to work properly

julienvincent14:01:50

A before and after connection

pez14:01:58

Have you maybe set the definitionprovider priority in both workspace and user settings?

julienvincent14:01:48

How do I check? Would workspace settings be in a .vscode project folder? I don’t have any such settings

pez14:01:19

Also, any nrepl deps in the main deps.edn that might be interferning?

julienvincent14:01:54

For now I have the following:

{:deps {funcool/promesa {:mvn/version "10.0.594"}}}
But it is the same even with empty map

pez14:01:38

Could promesa bring in some dependency, maybe...

julienvincent14:01:42

Oh, nrepl deps specifically? No, the only nrepl deps are the ones used from my alias in my previous message

julienvincent14:01:51

It does the same issue even without promesa

pez15:01:18

OK. So even with an empty deps map you have the problem. Does it work with a minimal new deps project, with only an {} deps.edn and some minimal src/hello.cljs file?

julienvincent15:01:50

Something like this? Still not working

julienvincent15:01:17

(I did restart repl)

pez15:01:04

Which version of clojure are you using?

julienvincent15:01:26

❯ clojure --version
Clojure CLI version 1.11.1.1208

pez15:01:16

If you open the folder directly (not via a workspace), same?

julienvincent15:01:32

Hmm, how do I do that?

pez15:01:32

Just open the folder in in VS Code. File -&gt; Open Folder...

pez15:01:50

Very strange. What OS are you using?

julienvincent15:01:16

Macos Ventura 13.1 on mac M1

pez15:01:34

VS Code version?

pez15:01:43

Calva version too. 😃

julienvincent15:01:21

VSCode:

Version: 1.74.2 (Universal)
Commit: e8a3071ea4344d9d48ef8a4df2c097372b0c5161
Date: 2022-12-20T10:26:09.430Z (2 wks ago)
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin arm64 22.2.0
Sandboxed: No

julienvincent15:01:54

Calva: v2.0.322 (I think)

julienvincent15:01:59

The latest calva version

pez15:01:54

Hmmm, everything is about exactly the same as I have... I have an older clojure CLI, that's all.

julienvincent15:01:22

Java

❯ java --version
openjdk 19.0.1 2022-10-18
OpenJDK Runtime Environment Temurin-19.0.1+10 (build 19.0.1+10)
OpenJDK 64-Bit Server VM Temurin-19.0.1+10 (build 19.0.1+10, mixed mode)

pez15:01:39

% java -version
openjdk version "18.0.2.1" 2022-08-18
OpenJDK Runtime Environment Zulu18.32+13-CA (build 18.0.2.1+1)
OpenJDK 64-Bit Server VM Zulu18.32+13-CA (build 18.0.2.1+1, mixed mode, sharing)

julienvincent15:01:57

Full settings dump:

{
  // EDITOR

  "workbench.editor.focusRecentEditorAfterClose": false,
  "security.workspace.trust.enabled": false,
  "security.workspace.trust.untrustedFiles": "open",
  "window.dialogStyle": "custom",
  "workbench.editor.showTabs": false,
  "explorer.autoReveal": false,
  "workbench.settings.editor": "json",
  "editor.tabSize": 2,
  "editor.cursorStyle": "block",
  "editor.minimap.enabled": false,
  "explorer.openEditors.visible": 0,
  "files.autoSave": "onFocusChange",
  "editor.fontFamily": "'Operator Mono'",
  "editor.fontSize": 13,
  "editor.tabCompletion": "onlySnippets",
  "workbench.activityBar.visible": false,
  "extensions.autoUpdate": false,
  "window.zoomLevel": 0,
  "explorer.confirmDragAndDrop": false,
  "explorer.confirmDelete": false,
  "git.mergeEditor": true,
  "workbench.preferredDarkColorTheme": "Gruvbox Dark",
  "workbench.preferredLightColorTheme": "Gruvbox Light",

  "editor.autoClosingDelete": "always",
  "workbench.list.openMode": "doubleClick",
  "workbench.tree.expandMode": "doubleClick",
  "workbench.panel.opensMaximized": "never",

  "sync.forceDownload": false,
  "editor.detectIndentation": false,
  "update.showReleaseNotes": false,
  "window.newWindowDimensions": "maximized",
  "editor.cursorBlinking": "solid",
  "editor.lightbulb.enabled": false,
  "editor.inlayHints.enabled": "off",
  "editor.selectionHighlight": false,
  "editor.lineHeight": 1.6,
  "breadcrumbs.enabled": false,
  "editor.folding": false,
  "editor.glyphMargin": false,
  "editor.defaultFormatter": "esbenp.prettier-vscode",

  "workbench.editor.untitled.hint": "hidden",
  "explorer.compactFolders": false,
  "search.quickOpen.includeHistory": false,
  "editor.copyWithSyntaxHighlighting": false,
  "editor.emptySelectionClipboard": false,
  "editor.linkedEditing": true,
  "editor.renderLineHighlight": "all",
  "editor.find.seedSearchStringFromSelection": "selection",
  "files.insertFinalNewline": true,
  "files.trimTrailingWhitespace": true,
  "workbench.startupEditor": "none",
  "extensions.closeExtensionDetailsOnViewChange": true,
  "extensions.ignoreRecommendations": true,
  "problems.showCurrentInStatus": true,

  "workbench.editorAssociations": {
    "git-rebase-todo": "default"
  },
  "editor.guides.indentation": false,
  "editor.bracketPairColorization.enabled": false,
  "workbench.colorTheme": "Gruvbox Light",
  "workbench.iconTheme": "file-icons",

  "extensions.experimental.affinity": {
    "vscodevim.vim": 1,
    "eamodio.gitlens": 2,
    "esbenp.prettier-vscode": 2,
    "streetsidesoftware.code-spell-checker": 2,
    "betterthantomorrow.calva": 2
  },

  "terminal.explorerKind": "external",

  // "window.autoDetectColorScheme": true,

  // INTELLISENSE

  "editor.suggestSelection": "first",
  "editor.acceptSuggestionOnCommitCharacter": false,
  "editor.suggest.localityBonus": true,
  "editor.wordBasedSuggestions": false,
  "editor.parameterHints.enabled": false,
  "editor.snippetSuggestions": "inline",
  "typescript.suggest.autoImports": true,
  "typescript.preferences.autoImportFileExcludePatterns": ["**/node_modules/"],
  "editor.quickSuggestions": {
    "other": true,
    "comments": false,
    "strings": true
  },
  "emmet.showAbbreviationSuggestions": false,
  "emmet.showSuggestionsAsSnippets": false,
  "emmet.showExpandedAbbreviation": "never",

  // === Go-To

  "editor.gotoLocation.multipleReferences": "goto",
  "editor.gotoLocation.multipleImplementations": "goto",
  "editor.gotoLocation.multipleDeclarations": "goto",
  "editor.gotoLocation.multipleDefinitions": "goto",
  "editor.gotoLocation.multipleTypeDefinitions": "goto",
  "editor.definitionLinkOpensInPeek": false,

  // FILE ASSOCIATIONS

  "files.associations": {
    "Dockerfile.*": "dockerfile"
  },
  "files.watcherExclude": {
    "**/dist/*/**": true
  },
  "search.exclude": {
    "**/dist": true
  },



  // MISC

  "npm.autoDetect": "off",
  "npm.packageManager": "pnpm",
  "redhat.telemetry.enabled": false,
  "typescript.surveys.enabled": false,
  "typescript.suggest.completeFunctionCalls": true,

  // SETTINGS SYNC



  // VIM

  "vim.overrideCopy": false,
  "vim.cursorStylePerMode.normal": "block",
  "vim.cursorStylePerMode.insert": "line",
  "vim.cursorStylePerMode.replace": "block",
  "vim.statusBarColorControl": false,
  "vim.visualModeKeyBindings": [
    {
      "before": ["$"],
      "after": ["g", "_"]
    }
  ],
  "vim.normalModeKeyBindings": [
    {
      "before": ["f"],
      "after": ["<leader>", "<leader>", "s"]
    },
    {
      "before": ["F"],
      "after": ["<leader>", "<leader>", "f"]
    },
    {
      "before": ["<leader>", "<leader>", "g"],
      "commands": ["typescript.goToSourceDefinition"]
    },
    {
      "before": ["<leader>", "b"],
      "commands": ["paredit.barfSexpForward"]
    },
    {
      "before": ["<leader>", "s"],
      "commands": ["paredit.slurpSexpForward"]
    },
    {
      "before": ["<leader>", "g"],
      "commands": ["editor.action.goToImplementation"]
    },
    {
      "before": ["<leader>", "c", "c"],
      "commands": ["calva.connect"]
    },
    {
      "before": ["<leader>", "r"],
      "commands": ["paredit.raiseSexp"]
    },
    {
      "before": ["<leader>", "t"],
      "commands": ["paredit.transpose"]
    },
    {
      "before": ["<leader>", "d"],
      "commands": ["paredit.dragSexprBackward"]
    },
    {
      "before": ["<leader>", "D"],
      "commands": ["paredit.dragSexprForward"]
    },
    {
      "before": ["u"],
      "commands": ["undo"]
    },
    {
      "before": ["C-r"],
      "commands": ["redo"]
    }
  ],
  "vim.visualModeKeyBindingsNonRecursive": [
    {
      "before": ["p"],
      "after": ["p", "g", "v", "y"]
    }
  ],
  "vim.hlsearch": true,
  "vim.easymotion": true,
  "vim.sneak": true,

  // JS/TS

  "javascript.updateImportsOnFileMove.enabled": "always",
  "debug.javascript.codelens.npmScripts": "never",

  "typescript.updateImportsOnFileMove.enabled": "always",
  "typescript.disableAutomaticTypeAcquisition": true,

  "javascript.suggest.completeJSDocs": false,
  "typescript.suggest.completeJSDocs": false,

  // CLOJURE

  "calva.showCalvaSaysOnStart": false,

  "[clojure]": {
    "editor.defaultFormatter": "betterthantomorrow.calva"
    // "editor.formatOnType": true,
    // "editor.autoIndent": "full"
  },
  "calva.highlight.enableBracketColors": false,
  "calva.highlight.rainbowIndentGuides": false,
  "calva.highlight.highlightActiveIndent": false,
  "calva.keybindingsEnabled": false,
  "calva.definitionProviderPriority": ["lsp", "repl"],
  // Calva seems to change vs-codes' definition of a word boundary, which is what is used by default by vim
  "vim.iskeyword": "/\\()\"':,.;<>~!@#$%^&*|+=[]{}`?-",
  "calva.replConnectSequences": [
    {
      "name": "clojure",
      "projectType": "deps.edn",
      "cljsType": "none"
    }
  ],

  // GIT LENSE

  "gitlens.hovers.currentLine.over": "line",
  "gitlens.hovers.annotations.changes": false,
  "gitlens.currentLine.enabled": false,
  "gitlens.codeLens.enabled": false,
  "gitlens.statusBar.pullRequests.enabled": false,
  "gitlens.hovers.pullRequests.enabled": false,
  "gitlens.hovers.avatars": false,
  "gitlens.hovers.currentLine.details": false,
  "gitlens.hovers.annotations.enabled": false,
  "gitlens.hovers.enabled": false,
  "gitlens.views.commits.pullRequests.enabled": false,
  "gitlens.views.commits.avatars": false,
  "gitlens.views.fileHistory.avatars": false,
  "gitlens.blame.avatars": false,
  "gitlens.views.lineHistory.avatars": false,
  "gitlens.views.branches.avatars": false,
  "gitlens.views.branches.pullRequests.enabled": false,
  "gitlens.views.remotes.avatars": false,
  "gitlens.views.remotes.pullRequests.enabled": false,
  "gitlens.views.tags.avatars": false,
  "gitlens.views.worktrees.avatars": false,
  "gitlens.views.worktrees.pullRequests.enabled": false,
  "gitlens.views.contributors.avatars": false,
  "gitlens.views.contributors.pullRequests.enabled": false,
  "gitlens.views.searchAndCompare.avatars": false,
  "gitlens.views.searchAndCompare.pullRequests.enabled": false,
  "gitlens.blame.toggleMode": "window",
  "gitlens.blame.heatmap.enabled": false,
  "gitlens.blame.highlight.locations": ["gutter", "line", "overview"],
  "gitlens.changes.locations": ["overview", "gutter"],
  "gitlens.menus": false,
  "gitlens.mode.statusBar.enabled": false,

  // LIVE SHARE

  "liveshare.featureSet": "stable",
  "liveshare.codeLens": false,

  // CPP

  "[cpp]": {
    "editor.defaultFormatter": "ms-vscode.cpptools"
  },

  "C_Cpp.default.browse.limitSymbolsToIncludedHeaders": true,
  "C_Cpp.default.includePath": ["~/.platformio/packages/**"],

  // MISC

  "cSpell.userWords": ["Deserialization", "kubernetes", "typeof"],
  "cSpell.language": "en,en-GB",
  "[go]": {
    "editor.defaultFormatter": "golang.go"
  },

  "ruby.useBundler": true,
  "ruby.useLanguageServer": true,
  "ruby.lint": {
    "reek": false,
    "rubocop": {
      "useBundler": true,
      "lint": false
    }
  },
  "ruby.format": "rubocop",
  "[ruby]": {
    "editor.defaultFormatter": "rebornix.ruby"
  },

  "rust-client.engine": "rls",
  "rust.show_warnings": false,
  "[rust]": {
    "editor.defaultFormatter": "rust-lang.rust-analyzer"
  },

  "[json]": {
    "editor.quickSuggestions": {
      "strings": true
    },
    "editor.suggest.insertMode": "replace",
    "gitlens.codeLens.scopes": ["document"]
  },
  "githubPullRequests.pullBranch": "never",
  "editor.wordSeparators": "/\\()\"':,.;<>~!@#$%^&*|+=[]{}`?-"
}

pez15:01:46

I opened a huddle in the channel. If you wanna join and we can screen share and see if we can figure it out that way?