Structural outline: a high-level, line-ranged skeleton of a source file produced via tree-sitter (com.blockether/tree-sitter-language-pack, which sources Clojure from our own grammar fork).
Every item carries FULL anchors — the same <lineno>:<hash> anchors cat
emits and patch consumes — for its first and last line, so you can replace
a whole definition straight from the index with one
patch([{from_anchor start, to_anchor end, replace …}]), no intermediate
cat. Each line is:
<kind> <name> <signature> @<start-anchor>..<end-anchor>
e.g.
class Greeter @3:a1b..7:c2d function hello @6:1b2..7:c2d function main @9:3c4..10:5d6
Read it BEFORE cat: a cheap map of a file so you jump straight to the right
range (and its anchors) instead of reading the whole file.
Requiring this namespace also requires the native resolver, which selects the right per-platform FFI library at runtime.
Structural outline: a high-level, line-ranged skeleton of a source file
produced via tree-sitter (com.blockether/tree-sitter-language-pack, which
sources Clojure from our own grammar fork).
Every item carries FULL anchors — the same `<lineno>:<hash>` anchors `cat`
emits and `patch` consumes — for its first and last line, so you can replace
a whole definition straight from the index with one
`patch([{from_anchor start, to_anchor end, replace …}])`, no intermediate
`cat`. Each line is:
<kind> <name> <signature> @<start-anchor>..<end-anchor>
e.g.
class Greeter @3:a1b..7:c2d
function hello @6:1b2..7:c2d
function main @9:3c4..10:5d6
Read it BEFORE `cat`: a cheap map of a file so you jump straight to the right
range (and its anchors) instead of reading the whole file.
Requiring this namespace also requires the native resolver, which selects the
right per-platform FFI library at runtime.(code-language path)The tree-sitter language for path IFF it is a vetted CODE language
(code-languages) — else nil. Use this (not detect-language) wherever a
syntax-error refusal must be meaningful: prose / markup / data / .log /
extensionless files all return nil, so they're never falsely guarded.
The tree-sitter language for `path` IFF it is a vetted CODE language (`code-languages`) — else nil. Use this (not `detect-language`) wherever a syntax-error refusal must be meaningful: prose / markup / data / `.log` / extensionless files all return nil, so they're never falsely guarded.
Curated allowlist of tree-sitter languages vis treats as CODE — where a parse
ERROR means a genuinely broken file, worth refusing an edit over. Deliberately
EXCLUDES the pack's prose / markup / loose grammars (vimdoc — remember .txt
maps to it! — markdown, rst, csv, html, xml, ini …) that carry error nodes on
normal content and would fire false positives. Real programming languages plus
the STRICT structured-config formats (json/yaml/toml). This is the vetted subset
the syntax guard runs on; extend it as vis takes on more languages.
Curated allowlist of tree-sitter languages vis treats as CODE — where a parse ERROR means a genuinely broken file, worth refusing an edit over. Deliberately EXCLUDES the pack's prose / markup / loose grammars (vimdoc — remember `.txt` maps to it! — markdown, rst, csv, html, xml, ini …) that carry error nodes on normal content and would fire false positives. Real programming languages plus the STRICT structured-config formats (json/yaml/toml). This is the vetted subset the syntax guard runs on; extend it as vis takes on more languages.
(definitions source language)(definitions source language name)The DATA behind file-skeleton: every definition in source (parsed as
language), flattened across nesting, as
[{:name :kind :visibility :signature :doc :anchor :end-anchor} …]
where the def's span is patch-ready lineno:hash anchors — the SOLE position
(no redundant start/end line; patch/anchor->line recovers the number). So
outline → patch needs no re-cat. With name, only the definitions with that
exact name (there may be several — same name in different scopes). Empty when
the language is unsupported or nothing structural was found.
The DATA behind `file-skeleton`: every definition in `source` (parsed as
`language`), flattened across nesting, as
`[{:name :kind :visibility :signature :doc :anchor :end-anchor} …]`
where the def's span is patch-ready `lineno:hash` anchors — the SOLE position
(no redundant start/end line; `patch/anchor->line` recovers the number). So
`outline` → `patch` needs no re-cat. With `name`, only the definitions with that
exact name (there may be several — same name in different scopes). Empty when
the language is unsupported or nothing structural was found.(detect-language path)tree-sitter language name for path (by extension/shebang), or nil. NOTE: the
pack recognizes HUNDREDS of grammars, including prose/markup — .txt maps to
vimdoc (Vim :help files), .md→markdown, .csv→csv — which parse WITH error
nodes on ordinary content. For 'is a syntax error meaningful here?' use
code-language, not this.
Falls back to extra-extension->language (currently .edn→clojure) ONLY
when the pack returns nil, covering Clojure-family extensions the pack's table
omits so their files still get structural editing.
tree-sitter language name for `path` (by extension/shebang), or nil. NOTE: the pack recognizes HUNDREDS of grammars, including prose/markup — `.txt` maps to `vimdoc` (Vim `:help` files), `.md`→markdown, `.csv`→csv — which parse WITH error nodes on ordinary content. For 'is a syntax error meaningful here?' use `code-language`, not this. Falls back to `extra-extension->language` (currently `.edn`→`clojure`) ONLY when the pack returns nil, covering Clojure-family extensions the pack's table omits so their files still get structural editing.
(file-skeleton path)(file-skeleton path source)Skeleton string for path (items + line ranges + full start..end anchors),
or nil when the language is unsupported or nothing structural was found.
source may be passed to avoid a re-read (e.g. for unsaved buffers).
Skeleton string for `path` (items + line ranges + full start..end anchors), or nil when the language is unsupported or nothing structural was found. `source` may be passed to avoid a re-read (e.g. for unsaved buffers).
(node-span source language target kind)0-based inclusive [start-line end-line] of the TOP-LEVEL structural node named
target (optionally narrowed by kind, case-insensitive), or nil if not found.
Used by the structural move op to extract a node's exact source text by name.
0-based inclusive `[start-line end-line]` of the TOP-LEVEL structural node named `target` (optionally narrowed by `kind`, case-insensitive), or nil if not found. Used by the structural `move` op to extract a node's exact source text by name.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |