From 9ae32ef0ef92b37296d50dc35bd038aaebeabff6 Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 15 Oct 2023 18:09:01 +0200 Subject: [PATCH] Create custom grep function --- after/plugin/telescope.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua index 67cdaa4..b82bc0c 100644 --- a/after/plugin/telescope.lua +++ b/after/plugin/telescope.lua @@ -1,5 +1,17 @@ local builtin = require('telescope.builtin') vim.keymap.set('n', 'ff', builtin.find_files, {}) + vim.keymap.set('n', 'fs', function() - builtin.grep_string({ search = vim.fn.input("Find: ") }); + local searchstring + vim.ui.input({ prompt = 'Grep: ' }, function(input) + searchstring = input + end); + + if (searchstring == nil or searchstring == '') then + return + end + + builtin.grep_string({ search = searchstring }); end) + +vim.keymap.set('v', 'fs', builtin.grep_string);