Skip to content

Conversation

waddie
Copy link

@waddie waddie commented Oct 1, 2025

Clojure Text Objects and Indentation

Text Objects (textobjects.scm)

Match in/around selections for Clojure code:

f (function)

  • Inside: (defn foo [x] |body|) - body only
  • Around: |(defn foo [x] body)| - entire form

e (class/data structure)

  • Inside: (defrecord Point [x y] |methods|) - body after name
  • Around: |(defrecord Point [x y] methods)| - entire form

T (test)

  • Inside: (deftest my-test |(is (= 1 1))|) - test body
  • Around: |(deftest my-test (is (= 1 1)))| - entire form

a (parameter)

  • Inside: [|x y z|] - parameters only
  • Around: |[x y z]| - includes brackets

entry

  • Inside/Around: (foo |bar| baz) - same, selects individual element

c (comment)

  • Inside: |; single comment| - one comment
  • Around: |; comment 1\n; comment 2| - consecutive comments (matches upward from cursor)

Indentation (indents.scm)

Indentation rules for Clojure code:

  1. Two-element alignment: When a list has two elements on the first line (excluding literals and special forms), align subsequent lines to the second element
  2. Nested list alignment: When the first element is a list on its own line, align the outer list to it
  3. Single-element indent: When the first element is on its own line (not a literal or special form), indent the body by one level
  4. Literal alignment: When the first element is a literal (true, false, nil, string, number, keyword), align to it
  5. Special forms: def*, let*, binding, loop, for, doseq, when-*, if-*, with-*, fn, and ns forms indent their body by one level
  6. Vector/map alignment: When first two elements are on the same line (common in let bindings), align subsequent pairs to them
  7. Collection indent: Vectors, maps, and sets are indented by one level

@waddie waddie force-pushed the clojure-ts-queries branch from 2dcd633 to 1cc87e7 Compare October 10, 2025 07:21
match/around/function less strict
@waddie waddie force-pushed the clojure-ts-queries branch from 1cc87e7 to fcdc5bd Compare October 10, 2025 07:30
@waddie waddie force-pushed the clojure-ts-queries branch from fcdc5bd to 5103372 Compare October 10, 2025 09:43
@waddie waddie marked this pull request as ready for review October 13, 2025 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant