From 7374472a610dffd627ca147eb4ddca42574c6148 Mon Sep 17 00:00:00 2001 From: kohnish Date: Tue, 15 Aug 2023 20:34:44 +0200 Subject: [PATCH] Add grep support --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index afd2b57..0a314cc 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,23 @@ def ListFiles(root_dir: string, target_dir: string): dict enddef g:Vim9_fuzzy_list_func = (root_dir, target_dir) => ListFiles(root_dir, target_dir) + +# Override grep command +def GrepCmd(keyword: string, root_dir: string, target_dir: string): dict + var dir = TargetDir(root_dir, target_dir) + if IsInGitDir(dir) + return { + "trim_target_dir": true, + "cmd": "cd " .. dir .. " && " .. g_git_cmd .. " grep -n " .. keyword + } + endif + return { + "trim_target_dir": false, + "cmd": "rg --color=never -Hn --no-heading " .. keyword .. " ." + } +enddef + +g:Vim9_fuzzy_grep_func = (keyword, root_dir, target_dir) => GrepCmd(keyword, root_dir, target_dir) ``` Build requirements