Liking cljdoc? Tell your friends :D

com.blockether.vis.ext.language-clojure.core

vis-language-clojure — Clojure language handlers for Vis.

Format/test/REPL are exposed through the generic language facade (format, test, repl_eval, repl, repl_stop) — format here does parinfer delimiter repair + cljfmt. The pack also registers a cross-cutting op-hook that auto repairs+formats .clj files after the foundation's struct_patch / patch / write, so no separate repair step is needed.

vis-language-clojure — Clojure language handlers for Vis.

Format/test/REPL are exposed through the generic language facade
(`format`, `test`, `repl_eval`, `repl`, `repl_stop`) —
`format` here does parinfer delimiter repair + cljfmt. The pack also registers
a cross-cutting op-hook that auto repairs+formats `.clj` files after the
foundation's struct_patch / patch / write, so no separate repair step is
needed.
raw docstring

available-aliasesclj

(available-aliases env)

Alias names declared in the workspace deps.edn — surfaced to the UI so the user picks REAL aliases (:dev, :test, …) instead of guessing. Returns a sorted vec of strings WITHOUT the leading colon; empty on any read/parse failure or a non-deps project.

Alias names declared in the workspace `deps.edn` — surfaced to the UI so the
user picks REAL aliases (`:dev`, `:test`, …) instead of guessing. Returns a
sorted vec of strings WITHOUT the leading colon; empty on any read/parse
failure or a non-deps project.
sourceraw docstring

clj-edit-repair-hookclj

(clj-edit-repair-hook env _op-kw args result)

An :after op-hook (registered on struct_patch / patch / write): after a SUCCESSFUL edit, paren-repair + cljfmt every Clojure file it touched, so the model never needs a separate repair/format step and a raw patch that left delimiters unbalanced is auto-corrected.

It then makes the RESULT TRUTHFUL: the foundation rendered each file's diff from what the raw edit wrote, BEFORE this repair/format rewrote the bytes on disk, so without this the model would be shown its INTENT, not the file. Using the pre-edit content the foundation stashes on :metadata :file-befores, we re-diff every touched summary against the FINAL on-disk bytes, and when parinfer CHANGED STRUCTURE (moved delimiters, which can silently re-nest code) we flag the summary loudly (repaired/note) so a scope shift can never hide behind a stale diff.

A throwing repair is caught + logged by the op-hook runner, never breaking the underlying edit.

An :after op-hook (registered on struct_patch / patch / write): after a
SUCCESSFUL edit, paren-repair + cljfmt every Clojure file it touched, so the
model never needs a separate repair/format step and a raw `patch` that left
delimiters unbalanced is auto-corrected.

It then makes the RESULT TRUTHFUL: the foundation rendered each file's
`diff` from what the raw edit wrote, BEFORE this repair/format rewrote the
bytes on disk, so without this the model would be shown its INTENT, not the
file. Using the pre-edit content the foundation stashes on
`:metadata :file-befores`, we re-diff every touched summary against the
FINAL on-disk bytes, and when parinfer CHANGED STRUCTURE (moved delimiters,
which can silently re-nest code) we flag the summary loudly
(`repaired`/`note`) so a scope shift can never hide behind a stale diff.

A throwing repair is caught + logged by the op-hook runner, never breaking
the underlying edit.
sourceraw docstring

clj-eval-fnclj

(clj-eval-fn env arg)

Evaluate Clojure over a RUNNING nREPL in this session. Target resolution:

  • explicit port → dial it directly (escape hatch);
  • id/repl_id → the REPL registered under that id in THIS session;
  • dir → the REPL rooted at that dir (when the session owns one);
  • no id, 1 REPL → use it (the implicit default);
  • no id, >1 REPLs → the REPL owning dir (default: the workspace root) when present, else the first (dir-sorted);
  • no id, 0 REPLs → error (:clj/no-repl): no running nREPL to hit. A connect failure surfaces as DATA so the model can repl / wait.
Evaluate Clojure over a RUNNING nREPL in this session. Target resolution:
  - explicit `port` → dial it directly (escape hatch);
  - `id`/`repl_id`  → the REPL registered under that id in THIS session;
  - `dir`           → the REPL rooted at that dir (when the session owns one);
  - no id, 1 REPL   → use it (the implicit default);
  - no id, >1 REPLs → the REPL owning `dir` (default: the workspace root) when
                      present, else the first (dir-sorted);
  - no id, 0 REPLs  → error (:clj/no-repl): no running nREPL to hit.
A connect failure surfaces as DATA so the model can repl / wait.
sourceraw docstring

clj-format-fnclj

(clj-format-fn arg)
(clj-format-fn env arg)

Format Clojure source via the language facade (format_code). Accepts:

  • a raw code string / {"code": ...} -> report changed? + char delta (NO text)
  • {"path": "src/foo.clj"} -> format that file IN PLACE
  • {"paths": ["src" "test" ...]} -> format those paths IN PLACE; a DIRECTORY is walked RECURSIVELY (every .clj/.cljs/.cljc/.cljx under it)
  • nothing / {} -> format the whole project's source roots (every deps.edn module's :paths + test), skipping build/vendor dirs (target, dist, node_modules, .clj-kondo, .clojure-lsp, .cpcache…) dirs (target, dist, node_modules, .clj-kondo, .clojure-lsp, .cpcache…) Paths are resolved against the workspace root when relative. Every result NAMES the backend that ran: "formatter" ("zprint" | "cljfmt") on a single file / code string, and the distinct "formatters" set on a batch.
Format Clojure source via the language facade (`format_code`). Accepts:
  - a raw code string / {"code": ...}   -> report changed? + char delta (NO text)
  - {"path": "src/foo.clj"}              -> format that file IN PLACE
  - {"paths": ["src" "test" ...]}        -> format those paths IN PLACE; a
      DIRECTORY is walked RECURSIVELY (every .clj/.cljs/.cljc/.cljx under it)
  - nothing / {}                         -> format the whole project's source
      roots (every deps.edn module's :paths + test), skipping build/vendor
      dirs (target, dist, node_modules, .clj-kondo, .clojure-lsp, .cpcache…)
dirs (target, dist, node_modules, .clj-kondo, .clojure-lsp, .cpcache…)
Paths are resolved against the workspace root when relative. Every result
NAMES the backend that ran: `"formatter"` ("zprint" | "cljfmt") on a
single file / code string, and the distinct `"formatters"` set on a batch.
sourceraw docstring

clj-lint-fnclj

(clj-lint-fn env arg)

clj-kondo lint via the language facade (lint_code). Accepts:

  • a raw code string / {"code": ...} -> lint it on stdin
  • {"path": "src/foo.clj"} -> lint that file
  • {"paths": ["src", "test"]} -> lint those paths
  • nothing / {} -> lint the whole project's source roots (every deps.edn module's :paths + test), skipping build/vendor dirs path and paths are UNIONED (not shadowing); a target that resolves to nothing is an ERROR, not a silent clean. Paths are resolved against the workspace root when relative. Finding "file" paths are reported RELATIVE to the workspace root (absolute only when outside).

Findings come from one or more PROVIDERS, tagged per finding as "provider" and listed under "providers": "clj-kondo" (static analysis, every branch) and "general" (the compiler's reflection + boxed-math warnings). Reflection/boxed-math only exist at compile time, so "general" COMPILES its target: the code-string snippet, or every source file the lint targets (path / paths / whole project) — each in a throwaway namespace that is torn down. The flat "findings" vector is also grouped under "by-dir" — nested by directory to write each path prefix once: {<dir> {<basename> {"error"/"warning"/"info" [...]}}}.

clj-kondo lint via the language facade (`lint_code`). Accepts:
  - a raw code string / {"code": ...}  -> lint it on stdin
  - {"path": "src/foo.clj"}           -> lint that file
  - {"paths": ["src", "test"]}        -> lint those paths
  - nothing / {}                       -> lint the whole project's source roots
      (every deps.edn module's :paths + test), skipping build/vendor dirs
`path` and `paths` are UNIONED (not shadowing); a target that resolves to
nothing is an ERROR, not a silent `clean`.
Paths are resolved against the workspace root when relative. Finding "file"
paths are reported RELATIVE to the workspace root (absolute only when outside).

Findings come from one or more PROVIDERS, tagged per finding as `"provider"`
and listed under `"providers"`: `"clj-kondo"` (static analysis, every
branch) and `"general"` (the compiler's reflection + boxed-math warnings).
Reflection/boxed-math only exist at compile time, so `"general"` COMPILES its
target: the code-string snippet, or every source file the lint targets (path /
paths / whole project) — each in a throwaway namespace that is torn down. The
flat `"findings"` vector is also grouped under `"by-dir"` — nested by
directory to write each path prefix once:
`{<dir> {<basename> {"error"/"warning"/"info" [...]}}}`.
sourceraw docstring

clj-patch-no-fail-aroundclj

(clj-patch-no-fail-around env _op-kw args next)

MIDDLEWARE (:around) on patch — the anchored-edit mirror of clj-struct-patch-no-fail-around. A raw patch whose :replace leaves a cleanly-parsing .clj file with unbalanced delimiters is REFUSED by the foundation's re-parse guard (a {:success? false … :reason :syntax-error} envelope, nothing written). The refusal's :metadata carries the WHOLE-BATCH :candidate-plans (every planned file with its edits applied, unwritten) plus :broken-paths.

Here we parinfer-repair each broken candidate as a WHOLE SOURCE — fragment repair cannot fix CONTEXTUAL imbalance (a replacement that is locally balanced but swallows or duplicates an enclosing closer only shows up in the full file) — and, when every broken file is Clojure and every one repairs clean, COMMIT the whole batch ourselves and return a success envelope with the SAME per-file diff/changed result shape as a normal successful patch. The :after repair+format hook then cljfmt-polishes the files and re-diffs from :metadata :file-befores, so the displayed collapsible changes describe the FINAL bytes on disk. If any broken file is not Clojure, or any repair fails, the ORIGINAL refusal is surfaced untouched — we never bury a real failure. The baseline is always 'nothing written'.

MIDDLEWARE (:around) on patch — the anchored-edit mirror of
`clj-struct-patch-no-fail-around`. A raw `patch` whose `:replace` leaves a
cleanly-parsing `.clj` file with unbalanced delimiters is REFUSED by the
foundation's re-parse guard (a `{:success? false … :reason :syntax-error}`
envelope, nothing written). The refusal's `:metadata` carries the
WHOLE-BATCH `:candidate-plans` (every planned file with its edits applied,
unwritten) plus `:broken-paths`.

Here we parinfer-repair each broken candidate as a WHOLE SOURCE — fragment
repair cannot fix CONTEXTUAL imbalance (a replacement that is locally
balanced but swallows or duplicates an enclosing closer only shows up in
the full file) — and, when every broken file is Clojure and every one
repairs clean, COMMIT the whole batch ourselves and return a success
envelope with the SAME per-file `diff`/`changed` result shape as a normal
successful patch. The `:after` repair+format hook then cljfmt-polishes the
files and re-diffs from `:metadata :file-befores`, so the displayed
collapsible changes describe the FINAL bytes on disk. If any broken file is
not Clojure, or any repair fails, the ORIGINAL refusal is surfaced untouched
— we never bury a real failure. The baseline is always 'nothing written'.
sourceraw docstring

clj-repair+formatclj

(clj-repair+format code)
(clj-repair+format code path)

The combined Clojure tidy used by BOTH format and the post-edit hook: parinfer delimiter repair FIRST (so unbalanced ( [ { from a raw edit are fixed), THEN indentation via the config-driven formatter (fmt/format-source picks zprint when a .zprint.edn/.zprintrc is near path, else cljfmt). Total — returns code unchanged on any failure of either step.

The combined Clojure tidy used by BOTH `format` and the post-edit hook:
parinfer delimiter repair FIRST (so unbalanced ( [ { from a raw edit are
fixed), THEN indentation via the config-driven formatter (`fmt/format-source`
picks zprint when a `.zprint.edn`/`.zprintrc` is near `path`, else cljfmt).
Total — returns `code` unchanged on any failure of either step.
sourceraw docstring

clj-struct-patch-no-fail-aroundclj

(clj-struct-patch-no-fail-around _env _op-kw args next)

MIDDLEWARE (:around) on struct_patch so a Clojure structural edit does NOT fail on unbalanced delimiters. If the call throws and it targeted a .clj file with a :code form, parinfer-repair the code and retry ONCE. If the repair changes nothing — or the retried edit still fails — the ORIGINAL error is surfaced (we never bury a real structural failure). Non-clj / non-code calls pass straight through to next.

MIDDLEWARE (:around) on struct_patch so a Clojure structural edit does NOT
fail on unbalanced delimiters. If the call throws and it targeted a `.clj`
file with a `:code` form, parinfer-repair the code and retry ONCE. If the
repair changes nothing — or the retried edit still fails — the ORIGINAL error
is surfaced (we never bury a real structural failure). Non-clj / non-code
calls pass straight through to `next`.
sourceraw docstring

register-repl-resource!clj

(register-repl-resource! session-id dir aliases result)

Mirror a session's managed nREPL into the session-scoped resource registry so it shows in ctx (resources) + the footer, and can be stopped/restarted by id from the agent or the UI. No-op without a session or a live spawn. The stop-fn/restart-fn thunks ARE the canonical lifecycle — the footer and resource_stop both drive repl-manager through them, scoped to session-id.

Mirror a session's managed nREPL into the session-scoped resource registry so
it shows in ctx (resources) + the footer, and can be stopped/restarted by id
from the agent or the UI. No-op without a session or a live spawn. The
stop-fn/restart-fn thunks ARE the canonical lifecycle — the footer and
resource_stop both drive repl-manager through them, scoped to `session-id`.
sourceraw docstring

repl-start-fnclj

(repl-start-fn env)
(repl-start-fn env op)
(repl-start-fn env op opts)

Manage THIS session's workspace nREPL(s). Positional op (default "status") + optional opts dict {"dir": <path>, "aliases": ["dev", "test"]}:

"status" — managed-process view for this session (always allowed) "start" — start a project nREPL subprocess (always allowed) "restart" — stop then start (always allowed) "stop" — stop a Vis-managed nREPL / DETACH an external one (always allowed) "connect" — attach to an EXTERNAL user-started nREPL: opts {"port": N, "host"?: S (default localhost)}; vis never spawns/kills it

"dir" runs the REPL in a subdir (e.g. an extension) instead of the workspace root — that's how MULTIPLE REPLs coexist, each addressed by its id. "aliases" default to [:dev :test] (full deps/paths, user :main-opts dropped). Live nREPL state already rides in ctx under :session/env :languages :clojure :nrepl; this tool acts on it.

Manage THIS session's workspace nREPL(s). Positional op (default "status") +
optional opts dict `{"dir": <path>, "aliases": ["dev", "test"]}`:

  "status"  — managed-process view for this session (always allowed)
  "start"   — start a project nREPL subprocess (always allowed)
  "restart" — stop then start (always allowed)
  "stop"    — stop a Vis-managed nREPL / DETACH an external one (always allowed)
  "connect" — attach to an EXTERNAL user-started nREPL: opts {"port": N,
              "host"?: S (default localhost)}; vis never spawns/kills it

"dir" runs the REPL in a subdir (e.g. an extension) instead of the workspace
root — that's how MULTIPLE REPLs coexist, each addressed by its id. "aliases"
default to [:dev :test] (full deps/paths, user :main-opts dropped). Live nREPL
state already rides in ctx under `:session/env :languages :clojure :nrepl`;
this tool acts on it.
sourceraw docstring

vis-extensionclj

source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close