Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

SunskyXH/ast-grep.el

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ast-grep.el

GNU Emacs MELPA MELPA Stable

An Emacs interface to ast-grep, a CLI tool for code structural search, lint and rewriting based on Abstract Syntax Tree patterns.

Features

  • Search code using ast-grep patterns with completing-read interface
  • Project-wide search support
  • Integration with completing-read frameworks (Vertico, etc.)
  • Streaming JSON parsing for efficient processing
  • Async search with live results when consult is available

Requirements

  • Emacs 28.1 or later
  • ast-grep CLI tool installed and available in PATH

Installation

ast-grep is available on MELPA. Install it using M-x package-install command or your preferred package manager:

use-package

(use-package ast-grep :ensure t)

Doom Emacs

Add to your packages.el:

(package! ast-grep)

Straight.el

(straight-use-package '(ast-grep :type git :host github :repo "SunskyXH/ast-grep.el"))

Manual Installation

  1. Clone the repository:
    git clone https://github.com/SunskyXH/ast-grep.el.git
        
  2. Add to your Emacs configuration:
    (add-to-list 'load-path "/path/to/ast-grep.el")
    (require 'ast-grep)
        

Usage

Interactive Commands

  • ast-grep-search - Search for patterns in current directory
  • ast-grep-project - Search for patterns in current project
  • ast-grep-directory - Search for patterns in specified directory

Minor Mode

Enable ast-grep-mode for ast-grep integration (useful for configuration hooks).

Configuration

Customize the following variables:

  • ast-grep-executable - Path to ast-grep executable (default: “ast-grep”)
  • ast-grep-debug - Enable debug output for troubleshooting (default: nil)
  • ast-grep-async-min-input - Minimum input length before triggering async search (default: 3)

About

Emacs package for searching code using ast-grep with `completing-read' interface or `consult'

Topics

Resources

License

Stars

Watchers

Forks

Morty Proxy This is a proxified and sanitized view of the page, visit original site.