nvim-telescope / telescope-live-grep-args.nvim

Live grep with args
726 stars 40 forks source link

Auto prefix rg arg when calling live_grep_args #61

Open curious-toast opened 1 year ago

curious-toast commented 1 year ago

Hi there, awesome plug-in! I was wondering if there was a way to auto prefix an rg arg when calling live_grep_args.

As an example, anytime I open it I want all searches to use the -uuu arg instead of always having to type -uuu and then my search string.

Thanks!

dt098 commented 11 months ago

Check out :h telescope.defaults.vimgrep_arguments. You can extend the default value with the arguments you want. From what I understand, it should be possible to set it like this:

require("telescope").setup({  
    extensions = {  
        live_grep_args = {  
            vimgrep_arguments = { "rg", "--color=never", "--no-heading", "--with-filename", "--line-number", "--column", "--smart-case", "YOUR_ARGUMENT" },  
        }  
    }  
})

but I couldn't get it to work. It's probably a bug in the extension since setting custom mappings doesn't work either. So for now a workaround solution is to set it inside your remap:

vim.keymap.set("n", "<leader>fg", function() telescope.extensions.live_grep_args.live_grep_args({vimgrep_arguments = { "rg", "--color=never", "--no-heading", "--with-filename", "--line-number", "--column", "--smart-case", "YOUR_ARGUMENT" }}) end)

or to set it globally, which will affect other pickers as well:

telescope.setup({
    defaults = {
        vimgrep_arguments = { "rg", "--color=never", "--no-heading", "--with-filename", "--line-number", "--column", "--smart-case", "YOUR_ARGUMENT" },
    }
})