/nvim-ripgrep

A Neovim plugin to run ripgrep asynchronously.

Primary LanguageFennelThe UnlicenseUnlicense

nvim-ripgrep

A Neovim plugin that runs ripgrep rg (ag, pt) asynchronously and send results into quickfix list.

demo

Installation

Using packer.nvim,

use {
  "rinx/nvim-ripgrep",
  config = function()
    require("nvim-ripgrep").setup {
        -- your configurations here
    }
  end
  }

This plugin requires ripgrep.

Usage

This plugin does not create a binding to Vim commands. Please write a command to call grep() function like the following.

command! Rg lua require'nvim-ripgrep'.grep()

grep() will show a floating window that accepts grep query. After search, quickfix window will be shown.

Configurations

Default:

{
    runner = require('nvim-ripgrep.run').ripgrep, -- grep command
    prompt = "", -- prompt
    window = {
        width = 0.8,
        border = "rounded",
    }
    open_qf_fn = function()
        return vim.api.nvim_command('copen')
    end,
}

By default, the search command is fixed as rg {query} --vimgrep --smart-case. If you want to change it, please modify the runner field.

    -- Predefined `pt` search command.
    -- `pt {query} --nogroup --nocolor --smart-case`
    runner = require('nvim-ripgrep.run').pt,

    -- Or you can define your own search command.
    runner = function(query)
        return require('nvim-ripgrep.run').run(
            'rg',
            {
                args = {
                    '--vimgrep',
                    '--smart-case',
                    '--regexp',
                    query
                },
            },
        )
    end,

If you use trouble.nvim, it is recommended to set Trouble quickfix as open_qf_fn.

    open_qf_fn = require('nvim-ripgrep.extensions').trouble_open_qf,

The highlight groups RgNormal and RgBorder will be used for highlighting popup window.

License

Unlicense