From 97024af1aa3e55708f56396b027adc23d7492009 Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Sun, 26 Feb 2023 12:49:28 +0100 Subject: [PATCH] Add prompt_parse_fun option --- README.md | 3 +++ lua/telescope/_extensions/live_grep_args.lua | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 49a6a60..c9694fe 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,9 @@ telescope.setup { -- theme = "dropdown", -- use dropdown theme -- theme = { }, -- use own theme spec -- layout_config = { mirror=true }, -- mirror preview pane + + -- custom prompt parse function + -- prompt_parse_fun = function(prompt, autoquote) … end, } } } diff --git a/lua/telescope/_extensions/live_grep_args.lua b/lua/telescope/_extensions/live_grep_args.lua index 09b07b2..43a2793 100644 --- a/lua/telescope/_extensions/live_grep_args.lua +++ b/lua/telescope/_extensions/live_grep_args.lua @@ -32,6 +32,7 @@ local live_grep_args = function(opts) opts.vimgrep_arguments = opts.vimgrep_arguments or conf.vimgrep_arguments opts.entry_maker = opts.entry_maker or make_entry.gen_from_vimgrep(opts) opts.cwd = opts.cwd and vim.fn.expand(opts.cwd) + opts.prompt_parse_fun = opts.prompt_parse_fun or prompt_parser.parse local cmd_generator = function(prompt) if not prompt or prompt == "" then @@ -39,8 +40,7 @@ local live_grep_args = function(opts) end local args = tbl_clone(opts.vimgrep_arguments) - local prompt_parts = prompt_parser.parse(prompt, opts.auto_quoting) - + local prompt_parts = opts.prompt_parse_fun(prompt, opts.auto_quoting) local cmd = vim.tbl_flatten { args, prompt_parts } return cmd end