From 3bf7d9673871af29783b4a5727159ce5d736112e Mon Sep 17 00:00:00 2001 From: "bscriver (aider)" Date: Wed, 11 Dec 2024 11:57:58 +0000 Subject: [PATCH] feat: Add support for Clojure language in parsers and update documentation --- README.md | 12 +++++++++++- grep_ast/parsers.py | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 759f87d..e094a88 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,17 @@ So it supports a lot of popular [code languages](https://github.com/paul-gauthie python -m pip install git+https://github.com/paul-gauthier/grep-ast.git ``` -## Usage +## Adding Support for New Languages + +To add support for a new language, you need to update the `PARSERS` dictionary in `grep_ast/parsers.py` with the appropriate file extensions and language name as recognized by `tree-sitter`. For example, to add support for Clojure, you would add: + +```python +".clj": "clojure", +".cljs": "clojure", +".cljc": "clojure", +``` + +Ensure that the language is supported by `tree-sitter` and `py-tree-sitter-languages`. You may need to install additional language parsers if they are not included by default. Basic usage: diff --git a/grep_ast/parsers.py b/grep_ast/parsers.py index 66f7ea8..7363161 100644 --- a/grep_ast/parsers.py +++ b/grep_ast/parsers.py @@ -53,6 +53,9 @@ ".tsx": "typescript", ".ts": "typescript", ".yaml": "yaml", + ".clj": "clojure", + ".cljs": "clojure", + ".cljc": "clojure", }