joshmu / periscope

Ripgrep powered peek search in VSCode 🫧
Other
11 stars 4 forks source link

Periscope 🫧

Periscope is a VSCode extension that supercharges your ability to search workspace contents using ripgrep, providing an intuitive interface with real-time previews of search results.

Inspired by nvim's telescope

Key Features

Demo

Usage Instructions

  1. Invoke Search: Assign a keybinding such as <super> + p to invoke the periscope.search command. You can also access it via the command palette (Ctrl+Shift+P or Cmd+Shift+P) and search for periscope.
  2. Search and Preview: Enter your query to see the search results dynamically. Navigate through results to preview files directly in the editor.
  3. Open or Cancel: Press Enter to open the highlighted file or Esc to cancel and return to your work.

Requirements

For optimal performance, ensure that the VSCode configuration Editor: Enable Preview is enabled. This allows files to be previewed before opening them completely.

Tips

Configuration

Advanced Configurations

Detailed examples for setting up advanced search parameters and UI customization are provided below to help you tailor Periscope to fit your workflow.

periscope.rgQueryParams

Create shortcuts for common ripgrep search queries via regex matching against your current query. This provides a way to map your query to ripgrep parameters via capture groups in the regex.

Add the following to your settings.json:

"periscope.rgQueryParams": [
  {
    // filter the results to a folder
    // Query: "redis -m module1"
    // After: "rg 'redis' -g '**/*module1*/**'"
    "regex": "^(.+) -m ([\\w-_]+)$",
    "param": "-g '**/*$1*/**' -g '!**/node_modules/**'"
  },
  {
    // filter the results to a folder and filetype
    // Query: "redis -m module1 yaml"
    // After: "rg 'redis' -g '**/*module1*/**/*.yaml'"
    "regex": "^(.+) -m ([\\w-_]+) ([\\w]+)$",
    "param": "-g '**/*$1*/**/*.$2'"
  },
  {
    // filter the results that match a glob
    // Query: "redis -g *module"
    // After: "rg 'redis' -g '*module'"
    "regex": "^(.+) -g (.+)$",
    "param": "-g '$1'"
  },
  {
    // filter the results to rg filetypes
    // Query: "redis -t yaml"
    // After: "rg 'redis' -t yaml"
    "regex": "^(.+) -t ?(\\w+)$",
    "param": "-t $1"
  },
  {
    // filter the results that match a file extension through a glob
    // Query: redis *.rs => rg 'redis' -g '*.rs'
    "regex": "^(.+) \\*\\.(\\w+)$",
    "param": "-g '*.$1'"
  }
],

periscope.openInHorizontalSplit

Open the result preview in a horizontal split.

Add a keybinding (keybindings.json):

{
  "key": "ctrl+v",
  "command": "periscope.openInHorizontalSplit",
  "when": "periscopeActive"
}

Extension Settings

This extension contributes the following settings:

Troubleshooting

For common issues and troubleshooting guidance, please visit the Issues section of our GitHub repository. If you encounter a problem not covered there, feel free to open a new issue.

Contributing

Interested in contributing to Periscope? We welcome contributions of all forms. Please visit our Contributions Page for more information on how to get involved.

Feedback and Support

For support with using Periscope or to provide feedback, please open an issue in our GitHub repository.