You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<tdstyle="text-align: left;">A JSON object with stuff from <ahref="https://github.com/clojure-emacs/cider-nrepl/blob/master/doc/modules/ROOT/pages/nrepl-api/ops.adoc#refresh-all">cider-nrepl ops/refresh-aa</a></td>
2276
2276
<tdstyle="text-align: left;">Mostly meant for sending <code>:dirs</code>, <code>:after</code>, and <code>:before</code>. The print options may or may not work.</td>
<tdstyle="text-align: left;">Sets the REPL window to use the specified session. If no argument is provided, shows a picker. Returns <code>void</code>.</td>
2283
+
</tr>
2278
2284
</tbody>
2279
2285
</table>
2280
2286
<h2id="wait-where-are-all-the-commands">Wait, where are all the commands?<aclass="headerlink" href="#wait-where-are-all-the-commands" title="Permanent link">#</a></h2>
Copy file name to clipboardExpand all lines: connect-sequences/index.html
+34-4Lines changed: 34 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -2430,12 +2430,13 @@ <h2 id="settings-for-adding-custom-sequences">Settings for adding Custom Sequenc
2430
2430
<p>A connect sequence configures the following:</p>
2431
2431
<ul>
2432
2432
<li><code>name</code>: (required) This will show up in the Jack-in quick-pick menu when you start Jack-in (see above). This will be set the <ahref="../when-clauses/">When Clause context</a><code>calva:connectSequence</code>, so you can e.g. bind keyboard shortcuts depending on which sequence is selected.</li>
2433
-
<li><code>projectType</code>: (required) This is either "Leiningen”, "deps.edn", "shadow-cljs", "lein-shadow", "Gradle", "babashka", "nbb", "basilisp", "joyride", ”generic”, "custom", or "cljs-only".</li>
2433
+
<li><code>projectType</code>: (required) This is either "Leiningen", "deps.edn", "shadow-cljs", "lein-shadow", "Gradle", "babashka", "nbb", "basilisp", "joyride", "scittle", "generic", "clj-projectless", "custom", or "cljs-only".</li>
2434
2434
<li><code>autoSelectForJackIn</code>: A boolean. If true, this sequence will be automatically selected at <strong>Jack-in</strong>, suppressing the Project Type. Use together with <code>projectRootPath</code> to also suppress the Project Root menu. Add usage of <code>menuSelections</code> to go for a prompt-less REPL Jack-in. If you have more than one sequence with <code>autoSelectForJackIn</code> set to true, Calva will use the sequence with its <code>projectRootPath</code> closest to the currently active editor file. And if there is no such closest file, the first sequence will be used.</li>
2435
2435
<li><code>autoSelectForConnect</code>: A boolean. If true, this sequence will be automatically selected at <strong>Connect</strong>, suppressing the Project Type menu. Use together with <code>projectRootPath</code> to also suppress the Project Root menu. If you have more than one sequence with <code>autoSelectForConnect</code> set to true, Calva will use the sequence with its <code>projectRootPath</code> closest to the currently active editor file. And if there is no such closest file, the first sequence will be used.</li>
2436
2436
<li><code>projectRootPath</code>: An array of path segments leading to the root of the project to which this connect sequence corresponds. Use together with <code>autoSelectForJackIn</code>/<code>autoSelectForConnect</code> to suppress the Project Root menu. The path can be absolute or relative to the workspace root. If there are several Workspace Folders, the workspace root is the path of the first folder, so relative paths will only work for this first folder.</li>
2437
2437
<li><code>nReplPortFile</code>: An array of path segments with the project root-relative path to the nREPL port file for this connect sequence. E.g. For shadow-cljs this would be <code>[".shadow-cljs", "nrepl.port"]</code>.</li>
2438
-
<li><code>afterCLJReplJackInCode</code>: Code to evaluate in the CLJ REPL once it has been created. You can use either a string or an array of strings. If you use an array, the strings will be joined with a newline character to form the resulting code.</li>
2438
+
<li><code>defaultPort</code>: A fallback port number to use when the <code>nReplPortFile</code> is missing (for example the built-in Babashka sequence uses <code>1667</code>, and the Scittle sequence uses <code>1339</code>). This lets Calva attempt an immediate connection instead of prompting for host/port when the port file is not present.</li>
2439
+
<li><code>afterPrimaryReplConnectedCode</code>: Code to evaluate in the primary REPL once it has been created. You can use either a string or an array of strings. If you use an array, the strings will be joined with a newline character to form the resulting code.</li>
2439
2440
<li><code>customJackInCommandLine</code>: A string with a command line that should be used to launch the REPL. See <ahref="#custom-command-line">Custom Command Line</a>, below.</li>
2440
2441
<li><code>cljsType</code>: This can be either "Figwheel Main", "shadow-cljs", "ClojureScript built-in for browser", "ClojureScript built-in for node", "lein-figwheel", "none", or a dictionary configuring a custom type. If set to "none", Calva will skip connecting a ClojureScript repl. A custom type has the following fields:<ul>
2441
2442
<li><code>dependsOn</code>: (required) Calva will use this to determine which dependencies it will add when starting the project (Jacking in). This can be either "Figwheel Main", "shadow-cljs", "ClojureScript built-in for browser", "ClojureScript built-in for node", "lein-figwheel", or ”User provided”. If it is "User provided", then you need to provide the dependencies in the project or launch with an alias (deps.edn), profile (Leiningen), or build (shadow-cljs) that provides the dependencies needed.</li>
@@ -2460,7 +2461,36 @@ <h2 id="settings-for-adding-custom-sequences">Settings for adding Custom Sequenc
2460
2461
</li>
2461
2462
<li><code>jackInEnv</code>: An object with environment variables that will be merged with the global <code>calva.jackInEnv</code> and then applied to the Jack-in process. The merge is very similar to how Clojure's <code>merge</code> works. So for any common keys between the global setting and this one, the ones from this setting will win.</li>
2462
2463
<li><code>extraNReplMiddleware</code>: Array of strings of the fully qualified names of extra middleware that should be applied to the nREPL server when started.</li>
2464
+
<li><code>replSessionNames</code>: Override the default repl session names that Calva registers for the primary and the secondary (if any) REPL sessions. Use this to enable connecting more than one connect sequence in the same VS Code window.<ul>
2465
+
<li><code>primary</code>: the name of the primary repl session. Defaults to <code>clj</code></li>
2466
+
<li><code>secondary</code>: the name of the secondary repl session in the sequence. Defaults to <code>cljs</code>.</li>
2463
2467
</ul>
2468
+
</li>
2469
+
<li><code>replSessionFilePatterns</code>: Map REPL session roles to the file patterns they should handle. Use <code>primary</code> and <code>secondary</code> as keys. Values can be a single pattern string, an array of patterns, or an object specifying <code>always-claim</code> and/or <code>is-fallback-for</code> patterns. Patterns are automatically scoped to the connect sequence's project root unless they start with <code>**/</code>, which makes them workspace-wide. Multi-root workspaces are supported. Defaults are <code>*.clj</code> for the primary session and <code>*.cljs</code> for the secondary session.</li>
<p>When there are many repls connected at once, Calva lets you pin a repl to be used for evaluations. We've tried to make the auto-routing flexible so that you shouldn't need to resort to session pinning too often; this is why the <code>replSessionFilePatterns</code> setting is a bit elaborate.</p>
2474
+
<p>Your first line of defence is pattern "specificity". The routing will take a simple specificity into account in cases of routing conflict. More specific patterns will take precedence over less specific ones.</p>
2475
+
<p>When you want to stay unspecific with the pattern targeting, you can signal that a particular session is fallback using the object form for <code>replSessionFilePatterns</code>. Specifying that some patterns are <code>is-fallback-for</code> gives other repl sessions the chance to handle the evaluation with their <code>always-claim</code> patterns. The built-in <strong>Babashka</strong> project type uses patterns like so:</p>
<p>This will make the Babashka repl (if connected) get all evaluations from <code>.bb</code> files in its project, and if no other repl session is handling <code>.clj</code> files, the Babashka repl will handle those too. But if some other connected repl is specifying <code>*.clj</code> as an <code>always-claim</code> pattern, the Babashka repl will not compete for those files. Additionally, the <code>**/*.clj</code>, <code>**/*.bb</code>. and <code>**/bb.edn</code> patterns in the fallback tier will match <code>.bb</code> files <em>anywhere</em> in the workspace (not just within the project root), making the Babashka repl a workspace-wide fallback for orphan Babashka files (and Clojure files, to make another repl fallback for Clojure files, connect it before connecting the Babashka repl).</p>
2489
+
<p>NB: When a sequence is not using the object form of the specification all patterns are considered <code>always-claim</code>.</p>
2490
+
<p><strong>Workspace-wide patterns</strong>: By default, patterns are scoped to the connect sequence's project root. To match files anywhere in the workspace, prefix patterns with <code>**/</code>.</p>
2491
+
<p>Inside each tier, Calva scores patterns by specificity: literal path segments earn more points than wildcard-heavy ones, and <code>**</code> incurs a penalty. This keeps patterns such as <code>src/app/*.cljs</code> ahead of a broad <code>*.cljs</code> even if both live in the same tier.</p>
2492
+
<p>If tiering and specificity still leave more than one repl session competing, Calva falls back to connection order, so the first connected session wins. The same fallback applies when no session matches.</p>
2493
+
</details>
2464
2494
<p>The <ahref="https://github.com/BetterThanTomorrow/calva/blob/published/src/nrepl/connectSequence.ts">Calva built-in sequences</a> also use this format, check them out to get a clearer picture of how these settings work.</p>
2465
2495
<divclass="admonition note">
2466
2496
<pclass="admonition-title">How sequence configurations are merged</p>
<spanclass="w"></span><spanclass="nt">"name"</span><spanclass="p">:</span><spanclass="w"></span><spanclass="s2">"Polylith RealWorld Server REPL (start)"</span><spanclass="p">,</span>
<spanclass="w"></span><spanclass="nt">"isReadyToStartRegExp"</span><spanclass="p">:</span><spanclass="w"></span><spanclass="s2">"Prompt will show"</span><spanclass="p">,</span>
@@ -2484,7 +2550,7 @@ <h2 id="connecting-without-jack-in">Connecting Without Jack-in<a class="headerli
2484
2550
<p>All this said, I still recommend you challenge the conclusion that you can't use Jack-in.</p>
2485
2551
<divclass="admonition note">
2486
2552
<pclass="admonition-title">Copy the Jack-in command line</p>
2487
-
<p>There is a Calva command for copying the Jack-in command line to the clipboard. It will copy the command line including commands to change to the current REPL project root, avoiding hard-to-detect errors when starting the REPL in the wrong directory.</p>
2553
+
<p>There is a Calva command for copying the Jack-in command line to the clipboard. It will copy the command line including commands to change to the current REPL project root, avoiding hard-to-detect errors when starting the REPL in the wrong directory. The command also accepts an optional connect sequence argument (by name or object) so automations and keybindings can copy the exact command for a particular sequence without prompts.</p>
@@ -2498,6 +2564,12 @@ <h2 id="auto-select-project-type-and-project-root">Auto-select Project Type and
2498
2564
<h2id="monorepos-multiple-clojure-projects-in-one-workspace">Monorepos / multiple Clojure projects in one workspace<aclass="headerlink" href="#monorepos-multiple-clojure-projects-in-one-workspace" title="Permanent link">#</a></h2>
2499
2565
<p>If the workspace is a monorepo, Polylith repo or just a repository with more than one Clojure project, Calva will start the connect sequence with prompting for which project to start/connect to.</p>
<p>Calva can keep several REPL connections alive at the same time. This is useful when you want to run a backend and frontend REPL concurrently, keep an nREPL connected to a remote server while also working locally, or maintain a scratch REPL that should not be restarted when another project reconnects.</p>
2569
+
<h3id="how-concurrent-connections-are-organized">How concurrent connections are organized<aclass="headerlink" href="#how-concurrent-connections-are-organized" title="Permanent link">#</a></h3>
2570
+
<p>Every connection registers one or two session names (for example the default <code>clj</code>/<code>cljs</code> pair or the custom names you define in a <ahref="../connect-sequences/#settings-for-adding-custom-sequences">connect sequence</a>). Calva routes evaluations to the session whose glob matches the active file so you can keep coding without rewiring buffers manually. Run jack-in or connect again at any point to add another repl session.</p>
2571
+
<h3id="picking-which-connection-to-keep">Picking which connection to keep<aclass="headerlink" href="#picking-which-connection-to-keep" title="Permanent link">#</a></h3>
2572
+
<p>Use <strong>Calva: Disconnect from the REPL</strong> whenever you need to tear down one connection without touching the others. The command opens a quick pick that lists every connection along with its session names, host/port, and project root. When more than one connection is active the picker also offers <strong>Close all REPL connections</strong> as a fast way to clean the slate.</p>
0 commit comments