Mercurial > vim-lawrencium
comparison autoload/lawrencium/vimutils.vim @ 139:065625e1bb31
Split plugin file into multiple extensions.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 13 Jun 2016 09:32:34 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
138:a2d823c82e5f | 139:065625e1bb31 |
---|---|
1 | |
2 function! lawrencium#vimutils#init() abort | |
3 call lawrencium#add_command("-bang -nargs=1 -complete=customlist,lawrencium#list_repo_files Hgedit :call lawrencium#vimutils#HgEdit(<bang>0, <f-args>)") | |
4 | |
5 call lawrencium#add_command("-bang -nargs=? -complete=customlist,lawrencium#list_repo_dirs Hgcd :cd<bang> `=lawrencium#hg_repo().GetFullPath(<q-args>)`") | |
6 call lawrencium#add_command("-bang -nargs=? -complete=customlist,lawrencium#list_repo_dirs Hglcd :lcd<bang> `=lawrencium#hg_repo().GetFullPath(<q-args>)`") | |
7 | |
8 call lawrencium#add_command("-bang -nargs=+ -complete=customlist,lawrencium#list_repo_files Hgvimgrep :call lawrencium#vimutils#HgVimGrep(<bang>0, <f-args>)") | |
9 endfunction | |
10 | |
11 " Hgedit {{{ | |
12 | |
13 function! lawrencium#vimutils#HgEdit(bang, filename) abort | |
14 let l:full_path = lawrencium#hg_repo().GetFullPath(a:filename) | |
15 if a:bang | |
16 execute "edit! " . fnameescape(l:full_path) | |
17 else | |
18 execute "edit " . fnameescape(l:full_path) | |
19 endif | |
20 endfunction | |
21 | |
22 " }}} | |
23 | |
24 " Hgvimgrep {{{ | |
25 | |
26 function! lawrencium#vimutils#HgVimGrep(bang, pattern, ...) abort | |
27 let l:repo = lawrencium#hg_repo() | |
28 let l:file_paths = [] | |
29 if a:0 > 0 | |
30 for ff in a:000 | |
31 let l:full_ff = l:repo.GetFullPath(ff) | |
32 call add(l:file_paths, l:full_ff) | |
33 endfor | |
34 else | |
35 call add(l:file_paths, l:repo.root_dir . "**") | |
36 endif | |
37 if a:bang | |
38 execute "vimgrep! " . a:pattern . " " . join(l:file_paths, " ") | |
39 else | |
40 execute "vimgrep " . a:pattern . " " . join(l:file_paths, " ") | |
41 endif | |
42 endfunction | |
43 | |
44 " }}} | |
45 |