From d92a3129929751e8a7801446ec6382b6fb243689 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Sat, 6 Apr 2024 15:39:43 +0100 Subject: [PATCH] Add :Rg[!] command :Rg grep for the string and fuzzy find the results, bang to enable regex in search term --- lua/commands.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lua/commands.lua b/lua/commands.lua index 0705ceb..13a23e3 100644 --- a/lua/commands.lua +++ b/lua/commands.lua @@ -83,3 +83,13 @@ end, { -- TODO: :Chmod -- TODO: :Mkdir + +-- :Rg grep for the string and fuzzy find the results, bang to enable +-- regex in search term +vim.api.nvim_create_user_command('Rg', function(opts) + local grep_opts = { search = opts.args } + if opts.bang then + grep_opts['use_regex'] = true + end + require('telescope.builtin').grep_string(grep_opts) +end, { bang = true, nargs = '*' })