vscode-ripgrep-utils
TypeScript icon, indicating that this package has built-in type declarations

0.6.0 • Public • Published

vscode-ripgrep-utils

npm coverage build license

Utils to make it easy to call ripgrep in VSCode's extensions.

Install

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.

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.

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.

import { config } from "vscode-ripgrep-utils";

config.debug = true;

Credit

This project is inspired by Gruntfuggly/todo-tree and alexlafroscia/ripgrep-js.

CHANGELOG

Package Sidebar

Install

npm i vscode-ripgrep-utils

Weekly Downloads

1

Version

0.6.0

License

MIT

Unpacked Size

43.7 kB

Total Files

43

Last publish

Collaborators

  • discretetom