Skip to content

feat(lang): Add Clojure language support#80

Closed
BuddhiLW wants to merge 1 commit intobartolli:mainfrom
BuddhiLW:feat/clojure-language-support
Closed

feat(lang): Add Clojure language support#80
BuddhiLW wants to merge 1 commit intobartolli:mainfrom
BuddhiLW:feat/clojure-language-support

Conversation

@BuddhiLW
Copy link
Copy Markdown
Contributor

Summary

Add comprehensive Clojure language support using tree-sitter-clojure-orchard.

Changes

New Parser Module: src/parsing/clojure/

  • mod.rs - Module exports
  • definition.rs - ClojureDefinition implementation
  • parser.rs - AST parsing & symbol extraction (30KB)
  • behavior.rs - Runtime behavior tracking
  • resolution.rs - Cross-reference resolution
  • audit.rs - Code health analysis

Integration:

  • Updated Cargo.toml with tree-sitter-clojure-orchard = "0.2.5"
  • Registered Clojure in factory.rs, language.rs, registry.rs
  • Added .clj, .cljs, .cljc, .edn extensions

Features

  • Extracts: defn, defmacro, def, defmulti, defmethod, defprotocol, defrecord, ns
  • Handles namespaced symbols and qualified references
  • Tracks function calls and dependencies
  • Supports docstrings and metadata extraction
  • Pattern-based form detection (tree-sitter-clojure is syntax-only)

Testing

Tested with hive-mcp codebase:

  • 13,324 symbols indexed successfully
  • 4,812 semantic embeddings generated
  • All symbol searches working correctly

Documentation

Added contributing/parsers/clojure/IMPLEMENTATION_GUIDE.md (1400 lines) with:

  • Architecture overview
  • Implementation patterns
  • Test cases
  • Known limitations

Notes

The Clojure tree-sitter grammar is syntax-only (no semantic nodes for defn etc.), so the parser uses pattern matching on list forms to identify definitions. This approach is documented in the implementation guide.


🤖 Generated with Claude Code

Add comprehensive Clojure parser using tree-sitter-clojure-orchard.

**New Files:**
- src/parsing/clojure/mod.rs - Module exports
- src/parsing/clojure/definition.rs - ClojureDefinition impl
- src/parsing/clojure/parser.rs - AST parsing & symbol extraction
- src/parsing/clojure/behavior.rs - Runtime behavior tracking
- src/parsing/clojure/resolution.rs - Cross-reference resolution
- src/parsing/clojure/audit.rs - Code health analysis

**Features:**
- Extracts defn, defmacro, def, defmulti, defmethod, defprotocol, defrecord
- Handles namespaced symbols and qualified references
- Tracks function calls and dependencies
- Supports docstrings and metadata extraction
- Pattern-based form detection (Clojure grammar is syntax-only)

**Dependencies:**
- tree-sitter-clojure-orchard = "0.2.5"

**Documentation:**
- contributing/parsers/clojure/IMPLEMENTATION_GUIDE.md

Tested with hive-mcp codebase: 13,324 symbols indexed successfully.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@bartolli
Copy link
Copy Markdown
Owner

Hi @BuddhiLW Thank you for your contribution!

A significant update was merged that includes API changes likely to cause conflicts with your branch.

What's changed:

  • Unified Envelope format for all --json output (breaking change)
  • Cleaned up dead resolution code - resolve_import, build_resolution_context, resolve_import_path and related methods are gone
  • file_extensions() no longer exists on LanguageBehavior - switch to LanguageDefinition::extensions()
  • Language behaviors now require format_path_as_module trait method
  • New src/parsing/paths.rs module with shared path helpers

Please rebase on main. Happy to assist if you encounter any issues.

@BuddhiLW
Copy link
Copy Markdown
Contributor Author

Hi!

I will be happy to conciliate with updates. Thank you for considering the PR.

One idea I had, because tree-sitter is limited for lisps, I may write a rust module wrapper to use clj-kondo.

I have some thoughts. Because, it will help greatly with token-efficiency in my other project (hive-mcp); and behavior normalization. When I have 5+ claudes and 3+ free models per claude doing work, like refactoring etc.

Sometimes free models will have way less context and hallucinate on function annotations ("types" for clojure) - I noticed.

So, yeah. Let's see... Nice talking to you, anyway.

bartolli added a commit that referenced this pull request Mar 15, 2026
- Clojure parser: defn, def, defmacro, defprotocol, defrecord, deftype, defmulti, defmethod, ns
- tree-sitter-clojure-orchard 0.2.5 grammar (codeberg.org/grammar-orchard)
- 7 symbol kinds extracted: Function, Variable, Macro, Interface, Struct, Method, Module
- comprehensive.clj: 520 lines, 34/35 grammar nodes covered
- ABI audit test and grammar analysis artifacts
- compare-nodes.sh language-mode: node extraction from GRAMMAR_ANALYSIS.md
- Based on BuddhiLW contribution, rebased and updated for current API

Co-authored-by: BuddhiLW <[email protected]>
bartolli added a commit that referenced this pull request Mar 15, 2026
- Clojure parser: defn, def, defmacro, defprotocol, defrecord, deftype, defmulti, defmethod, ns
- tree-sitter-clojure-orchard 0.2.5 grammar (codeberg.org/grammar-orchard)
- 7 symbol kinds extracted: Function, Variable, Macro, Interface, Struct, Method, Module
- comprehensive.clj: 520 lines, 34/35 grammar nodes covered
- ABI audit test and grammar analysis artifacts
- compare-nodes.sh language-mode: node extraction from GRAMMAR_ANALYSIS.md
- Based on BuddhiLW contribution, rebased and updated for current API

Co-authored-by: BuddhiLW <[email protected]>
@bartolli
Copy link
Copy Markdown
Owner

Hey thanks for putting this together. I reworked parts of the parser, behavior, and audit modules to align with some conventions and refactors that landed after you opened the PR. Also added the grammar analysis artifacts and test fixtures. So closing this, your work is already in main.

@bartolli bartolli closed this Mar 15, 2026
@BuddhiLW
Copy link
Copy Markdown
Contributor Author

That's awesome. Thanks. I left this behind

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.

2 participants