commit 13bdb43a5477f08728bc086e12b468dc8b28f485
parent e34e160a34a18f41b0e65ee91d3a9f37f9ccd6f7
Author: Ivan <ivan.t7ko@gmail.com>
Date: Wed, 4 Feb 2015 23:58:04 +0300
Merge pull request #113 from t7ko/auto-cd
Option to enable auto-change-dir when opening a wiki index page with <Leader>ww
Diffstat:
3 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim
@@ -131,6 +131,10 @@ function! vimwiki#base#setup_buffer_state(idx) " {{{ Init page-specific variable
call VimwikiSet('subdir', subdir, a:idx)
call VimwikiSet('invsubdir', vimwiki#base#invsubdir(subdir), a:idx)
+ if g:vimwiki_auto_chdir == 1
+ exe 'lcd' VimwikiGet('path')
+ endif
+
" update cache
call vimwiki#base#cache_buffer_state()
endfunction " }}}
diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt
@@ -2556,6 +2556,19 @@ before the plugin loads. >
The default is '<Leader>w'.
+------------------------------------------------------------------------------
+*g:vimwiki_auto_chdir*
+
+When set to 1, enables auto-cd feature. Whenever vimwiki page is opened,
+vimwiki performs an |:lcd| to the vimwiki folder to where the page belongs.
+
+
+Value Description~
+0 Do not change directory.
+1 Change directory to vimwiki folder on opening page.
+
+Default: 0
+
==============================================================================
13. Miscellaneous *vimwiki-misc*
@@ -2595,6 +2608,7 @@ Vim plugins: http://www.vim.org/scripts/script.php?script_id=2226
???~
+ * Spport for |g:vimwiki_auto_chdir| option.
* Support for anchors, see |vimwiki-anchors|
* in this context, add support for TOC, see |vimwiki-toc|
* remove the now useless %toc placeholder
diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim
@@ -469,6 +469,8 @@ call s:default('map_prefix', '<Leader>w')
call s:default('current_idx', 0)
+call s:default('auto_chdir', 0)
+
" Scheme regexes should be defined even if syntax file is not loaded yet
" cause users should be able to <leader>w<leader>w without opening any
" vimwiki file first