From 70b8da54f74d6b58ede866de17ede2bff0f99f9c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Sat, 1 Jul 2017 21:50:50 -0400 Subject: [PATCH] vim: improve NitGitGrep MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * Print line number after the file path, so you can use `gF` here too. * Show the introduction(s) before the redefs. * Search for the complete word under the cursor. * Search only in Nit source files. * Avoid duplicating results. Signed-off-by: Alexis Laferrière --- misc/vim/plugin/nit.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/misc/vim/plugin/nit.vim b/misc/vim/plugin/nit.vim index 582e5fb..c810664 100644 --- a/misc/vim/plugin/nit.vim +++ b/misc/vim/plugin/nit.vim @@ -358,12 +358,13 @@ endfun " Call `git grep` on the word under the cursor " -" Shows declarations first, then all matches, in the preview window. +" In the preview window, list introductions, declarations and then all matches. fun NitGitGrep() let word = expand("") let out = tempname() - execute 'silent !(git grep "\\(module\\|class\\|universal\\|interface\\|var\\|fun\\) '.word.'";'. - \'echo; git grep '.word.') > '.out + execute 'silent !(git grep -n -e "\<\\(module\\|class\\|universal\\|interface\\|subset\\|var\\|fun\\)\> \<'.word.'\>" --and --not -e redef -- ''*.nit'';'. + \'git grep -n "redef \<\\(class\\|universal\\|interface\\|subset\\|var\\|fun\\)\> \<'.word.'\>" -- ''*.nit'';'. + \'echo; git grep -n -e "\<'.word.'\>" --and --not -e "\<\\(module\\|class\\|universal\\|interface\\|subset\\|var\\|fun\\)\> \<'.word.'\>" -- ''*.nit'') > '.out " Open the preview window on a temp file execute "silent pedit " . out -- 1.7.9.5