ast-grep picker for telescope.nvim
Inspired by this PR
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
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
Make sure you call :checkhealth telescope
after intalling to ensure everything is set up correctly.
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
}
}
}
Telescope ast_grep