Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto prefix rg arg when calling live_grep_args #61

Open
curious-toast opened this issue Jun 6, 2023 · 1 comment
Open

Auto prefix rg arg when calling live_grep_args #61

curious-toast opened this issue Jun 6, 2023 · 1 comment

Comments

@curious-toast
Copy link

curious-toast commented Jun 6, 2023

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
Copy link

dt098 commented Dec 8, 2023

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" },
	}
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants