Mercurial > vim-lawrencium
comparison plugin/lawrencium.vim @ 43:fc20a265551d
Added auto cd'ing into the repo root for `:Hg`.
This can be disabled with the `lawrencium_auto_cd` global.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 14 Aug 2012 22:26:59 -0700 |
parents | decbefcf74db |
children | 95f8e7cb5ca2 |
comparison
equal
deleted
inserted
replaced
42:2ab1b802c070 | 43:fc20a265551d |
---|---|
16 endif | 16 endif |
17 let g:loaded_lawrencium = 1 | 17 let g:loaded_lawrencium = 1 |
18 | 18 |
19 if !exists('g:lawrencium_hg_executable') | 19 if !exists('g:lawrencium_hg_executable') |
20 let g:lawrencium_hg_executable = 'hg' | 20 let g:lawrencium_hg_executable = 'hg' |
21 endif | |
22 | |
23 if !exists('g:lawrencium_auto_cd') | |
24 let g:lawrencium_auto_cd = 1 | |
21 endif | 25 endif |
22 | 26 |
23 if !exists('g:lawrencium_trace') | 27 if !exists('g:lawrencium_trace') |
24 let g:lawrencium_trace = 0 | 28 let g:lawrencium_trace = 0 |
25 endif | 29 endif |
255 | 259 |
256 " Hg {{{ | 260 " Hg {{{ |
257 | 261 |
258 function! s:Hg(bang, ...) abort | 262 function! s:Hg(bang, ...) abort |
259 let l:repo = s:hg_repo() | 263 let l:repo = s:hg_repo() |
264 if g:lawrencium_auto_cd: | |
265 " Temporary set the current directory to the root of the repo | |
266 " to make auto-completed paths work magically. | |
267 execute 'cd! ' . l:repo.root_dir | |
268 endif | |
260 let l:output = call(l:repo.RunCommand, a:000, l:repo) | 269 let l:output = call(l:repo.RunCommand, a:000, l:repo) |
270 if g:lawrencium_auto_cd: | |
271 execute 'cd! -' | |
272 endif | |
261 if a:bang | 273 if a:bang |
262 " Open the output of the command in a temp file. | 274 " Open the output of the command in a temp file. |
263 let l:temp_file = s:tempname('hg-output-', '.txt') | 275 let l:temp_file = s:tempname('hg-output-', '.txt') |
264 execute 'pedit ' . l:temp_file | 276 execute 'pedit ' . l:temp_file |
265 wincmd p | 277 wincmd p |