telescope-live-grep-args.nvim icon indicating copy to clipboard operation
telescope-live-grep-args.nvim copied to clipboard

Allow to parse search phrase in quotes "as is"

Open mambusskruj opened this issue 1 year ago • 3 comments

Let's say I want to search for parameter --jobs in files. And for that I need to escape dashes with backslashes even while I use quotes for search phrase (like this "\-\-jobs").

So I propose to parse characters "as is" in quotes for search phrase. Example: for "--jobs" prompt -> search phrase will be --jobs

mambusskruj avatar Apr 04 '23 08:04 mambusskruj

rg "--jobs" is the same as rg --jobs, which results in this error:

error: Found argument '--jobs' which wasn't expected, or isn't valid in this context

You need to tell the program to stop parsing the options list, i.e. rg -- --jobs

You can use this function instead of the default quote_prompt:

local action_state = require("telescope.actions.state")
local function quote_prompt(bufnr)
  local picker = action_state.get_current_picker(bufnr)
  local prompt = picker:_get_prompt()
  prompt = vim.trim(prompt)
  prompt = "-- \"" .. prompt:gsub("\"", "\\\"") .. "\""
  picker:set_prompt(prompt)
  vim.cmd.normal{ "I", bang = true }
end

https://github.com/nvim-telescope/telescope-live-grep-args.nvim/assets/920910/6eab76c2-07eb-4cf8-bf40-b47432c68c78

notpeelz avatar Aug 25 '23 21:08 notpeelz

@notpeelz wow, thank you so much!

mambusskruj avatar Aug 27 '23 11:08 mambusskruj

I have re-opened the issue. Searching for --jobs should work. The comment is a possible workaround. I will take a look and add something to the plugin.

weeman1337 avatar Aug 28 '23 06:08 weeman1337