From 3adcb18a5b21baa0a0b8147c669fdbeb942d3510 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/commands.lua b/lua/commands.lua index 0705ceb..80d84db 100644 --- a/lua/commands.lua +++ b/lua/commands.lua @@ -83,3 +83,14 @@ 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 + print(vim.inspect(grep_opts)) + -- require('telescope.builtin').grep_string(grep_opts) +end, { bang = true, nargs = '*' })