Skip to content

(:kind) - Operators

select a value by its grammatical kind

clojure
(:kind val)

Where:

  1. val: TreeSitter node kind to match *

Guides

Behavior

  • Unstable: relies on internal TreeSitter grammar kind names (e.g., 'identifier', 'string_node', 'call_expression').
  • Kind names are grammar-specific and may differ between languages (e.g., JavaScript's 'identifier' vs Rust's 'scoped_identifier').

Examples

Extract TODO and FIXME comments from code for issue tracking.

clojure
(:and (:kind /comment/) (:text /TODO|FIXME/))

Selects in lines { 1, 2 } but not in { 3, 4 }:

typescript
// TODO: optimize this algorithm
/* FIXME: handle edge case */
// Regular comment
const x = 1;

Locate Rust token trees that aren't parsed into structured macro bodies.

clojure
(:kind "token_tree")

Selects in lines { 2 }:

typescript
macro_rules! m {
  () => { Foo::Bar }
}

Match TypeScript-specific type annotation nodes.

clojure
(:kind "type_annotation")

Selects in lines { 1, 1 }:

typescript
function f(x: number): string {
  return String(x);
}

Arguments

val

  1. String
  2. Pattern

Does NOT support: CompositionFree-form SelectionRefinementReplacement

Copyright © 2022-present Semantic Works, Inc.