From 0511b51a5fc52ba1d5d9a31bb216fc205cd81700 Mon Sep 17 00:00:00 2001 From: Ivan Tishchenko Date: Sat, 24 Jan 2015 10:49:20 +0300 Subject: [PATCH 1/2] Implement auto-chdir option --- autoload/vimwiki/base.vim | 4 ++++ doc/vimwiki.txt | 13 +++++++++++++ plugin/vimwiki.vim | 2 ++ 3 files changed, 19 insertions(+) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 5696a1f..232e0b8 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -151,6 +151,10 @@ function! vimwiki#base#setup_buffer_state(idx) " {{{ Init page-specific variable call VimwikiSet('invsubdir', vimwiki#base#invsubdir(subdir), a:idx) call VimwikiSet('url', vimwiki#html#get_wikifile_url(expand('%:p')), 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 index 8b7a1b3..2593f4f 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -2556,6 +2556,19 @@ before the plugin loads. > The default is '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* diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim index fc2e6aa..3a9b9b4 100644 --- a/plugin/vimwiki.vim +++ b/plugin/vimwiki.vim @@ -452,6 +452,8 @@ call s:default('map_prefix', '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 ww without opening any " vimwiki file first From be9667cfa6a12cd53f1a9cc887ea828b485c42ec Mon Sep 17 00:00:00 2001 From: Ivan Tishchenko Date: Sat, 24 Jan 2015 10:55:22 +0300 Subject: [PATCH 2/2] Documented the fix in ChangeLog --- doc/vimwiki.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 2593f4f..dcfc54a 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -2608,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