https://github.com/discretetom/vscode-ripgrep-utils
Utils to make it easy to call ripgrep in VSCode's extensions.
https://github.com/discretetom/vscode-ripgrep-utils
javascript nodejs ripgrep typescript vscode vscode-extension
Last synced: about 1 month ago
JSON representation
Utils to make it easy to call ripgrep in VSCode's extensions.
- Host: GitHub
- URL: https://github.com/discretetom/vscode-ripgrep-utils
- Owner: DiscreteTom
- License: mit
- Created: 2023-11-14T11:23:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-08T15:07:46.000Z (over 1 year ago)
- Last Synced: 2025-04-10T01:07:22.408Z (about 1 month ago)
- Topics: javascript, nodejs, ripgrep, typescript, vscode, vscode-extension
- Language: TypeScript
- Homepage:
- Size: 94.7 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# vscode-ripgrep-utils
[](https://www.npmjs.com/package/vscode-ripgrep-utils)


Utils to make it easy to call [`ripgrep`](https://github.com/BurntSushi/ripgrep) in VSCode's extensions.
## Install
```bash
yarn add vscode-ripgrep-utils
```## Usage
VSCode use `ripgrep` to search files. There is a `rg` binary in VSCode's installation directory, but the location differs on different platforms and different versions. This package provides a `getBinPath` function to get the absolute path of the `rg` binary.
```ts
import * as vscode from "vscode";
import { getBinPath } from "vscode-ripgrep-utils";await getBinPath(vscode.env.appRoot);
```Then you can use the high level `search` function to search files, or the low level `exec`/`execJson` functions to execute `ripgrep` with custom arguments.
```ts
import * as vscode from "vscode";
import { getBinPath, search, exec, execJson } from "vscode-ripgrep-utils";const bin = await getBinPath(vscode.env.appRoot);
await search({ bin, folder: "./", regex: "123" });
await exec(bin, "--version");
await execJson(bin, "-e", "123");
```Enable debug to see what command is executed.
```ts
import { config } from "vscode-ripgrep-utils";config.debug = true;
```## Credit
This project is inspired by [Gruntfuggly/todo-tree](https://github.com/Gruntfuggly/todo-tree/tree/a6f60e0ce830c4649ac34fc05e5a1799ec91d151) and [alexlafroscia/ripgrep-js](https://github.com/alexlafroscia/ripgrep-js).
## [CHANGELOG](./CHANGELOG.md)