Commits

Ludovic Chabant committed 16e873b

Added `Hgvimgrep` command.

  • Participants
  • Parent commits 8c9aca0

Comments (0)

Files changed (2)

doc/lawrencium.txt

                         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*

plugin/lawrencium.vim

 
 " }}}
 
+" 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