changeset 70:16e873b2a4a8

Added `Hgvimgrep` command.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 09 Nov 2013 13:20:17 -0800
parents 8c9aca0e4322
children 1fbba48019b5
files doc/lawrencium.txt plugin/lawrencium.vim
diffstat 2 files changed, 30 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/doc/lawrencium.txt	Wed Sep 25 18:33:33 2013 +0400
+++ b/doc/lawrencium.txt	Sat Nov 09 13:20:17 2013 -0800
@@ -178,6 +178,12 @@
                         are available in this window.
                         See |lawrencium-annotate-window|.
 
+                                                *:Hgvimgrep*
+:Hgvimgrep              Runs a |:vimgrep| command inside the current
+                        repository. The files in which to search can be
+                        provided with repository-relative names. If no file is
+                        given, the search will be run in the whole repository.
+
 
 =============================================================================
 3.  Status Window                               *lawrencium-status-window*
--- a/plugin/lawrencium.vim	Wed Sep 25 18:33:33 2013 +0400
+++ b/plugin/lawrencium.vim	Sat Nov 09 13:20:17 2013 -0800
@@ -1016,6 +1016,30 @@
 
 " }}}
 
+" Hgvimgrep {{{
+
+function! s:HgVimGrep(bang, pattern, ...) abort
+    let l:repo = s:hg_repo()
+    let l:file_paths = []
+    if a:0 > 0
+        for ff in a:000
+            let l:full_ff = l:repo.GetFullPath(ff)
+            call add(l:file_paths, l:full_ff)
+        endfor
+    else
+        call add(l:file_paths, l:repo.root_dir . "**")
+    endif
+    if a:bang
+        execute "vimgrep! " . a:pattern . " " . join(l:file_paths, " ")
+    else
+        execute "vimgrep " . a:pattern . " " . join(l:file_paths, " ")
+    endif
+endfunction
+
+call s:AddMainCommand("-bang -nargs=+ -complete=customlist,s:ListRepoFiles Hgvimgrep :call s:HgVimGrep(<bang>0, <f-args>)")
+
+" }}}
+
 " Hgdiff, Hgvdiff {{{
 
 function! s:HgDiff(filename, vertical, ...) abort