Marskey / telescope-sg

Ast-grep picker for telescop.nvim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Telescope ast-grep

ast-grep picker for telescope.nvim

Inspired by this PR

Requires

ast-grep to be installed ( version >= 0.10.0 ). You can install it by the following commands.

npm install --global @ast-grep/cli
pip install ast-grep-cli
cargo install ast-grep

What it does

ast-grep is a AST-based tool to search code by pattern code. Think it as your old-friend grep but it matches AST nodes instead of text. You can write patterns as if you are writing ordinary code. It will match all code that has the same syntactical structure. You can use $ sign + upper case letters as wildcard, e.g. $MATCH, to match any single AST node. Think it as REGEX dot ., except it is not textual.

See ast-grep

Check Health

Make sure you call :checkhealth telescope after intalling to ensure everything is set up correctly.

Configuration

require('telescope').setup {
    extensions = {
        ast_grep = {
            command = {
                "sg",
                "--json=stream",
            }, -- must have --json=stream
            grep_open_files = false, -- search in opened files
            lang = nil, -- string value, specify language for ast-grep `nil` for default
        }
    }
}

Usage

Telescope ast_grep

About

Ast-grep picker for telescop.nvim


Languages

Language:Lua 100.0%