Skip to content

feat(lang): Add Clojure language support#80

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

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

Conversation

@BuddhiLW
Copy link

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 <noreply@anthropic.com>
@bartolli
Copy link
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
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.

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