cmp-rg icon indicating copy to clipboard operation
cmp-rg copied to clipboard

feat(option): options to control when cmp-rg can be triggered

Open gjeusel opened this issue 3 years ago • 2 comments

Hey there ! 👋

I noticed rg is launched while editing my ~/.zshrc and fires up all the procs as it's searching all my home files. Would it be possible to add options to whitelist / blacklist some paths ?

Regards,

gjeusel avatar Nov 11 '22 19:11 gjeusel

This plugin has option to set additional arguments for rg. Here is my config for example. I created a file in gitignore format and passed it to rg for ignore

cmp.setup({
 ...
sources = cmp.config.sources({
{
  name = "rg",
  keyword_length = 3,
  option = {
  additional_arguments = "--max-depth 6 --one-file-system --ignore-file ~/.config/nvim/ignore.rg",
  },
},
}),

ignore.rg

Pictures/
Videos/
Documents/
go/pkg/
.node_modules/
.config/google-chrome/
.cache/
.java/
.mozilla/
.rustup/
.encryptfs/
.local/
.npm/
.cargo/

This prevents RipGrep from RIP-crashing my system when I edit a file in my home directory. Thanks to the ignore list, the list of files to search is reduced hundreds of times.

coffebar avatar Nov 21 '22 20:11 coffebar

Just another idea for folks finding this issue, in my case I don't really want the RG source unless in specific use cases so I just trigger it manually like so :

vim.keymap.set("i", "<c-x><c-r>", function()
  require("cmp").complete({
    config = {
      sources = {
        {
          name = "rg",
        },
      },
    },
  })
end)

jemag avatar Dec 11 '22 22:12 jemag