From ad8e1d30bf217e2985671652960d28ecedb6ea75 Mon Sep 17 00:00:00 2001 From: Steven Stallion Date: Mon, 18 Mar 2019 14:35:28 -0700 Subject: [PATCH] Add g:vimwiki_create_link option to prevent link creation. Adds a new global option named create_link, which allows the user to control :VimwikiFollowLink behavior when attempting to follow a non-existent link. The original behavior of creating a new link is preserved. However, by setting this option to 0, new links will not be created when pressing return over regular text. Closes #528. --- autoload/vimwiki/base.vim | 2 +- autoload/vimwiki/vars.vim | 1 + doc/vimwiki.txt | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index bbb1963..4f6e234 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1200,7 +1200,7 @@ function! vimwiki#base#follow_link(split, ...) else if a:0 >= 3 execute "normal! ".a:3 - else + elseif vimwiki#vars#get_global('create_link') call vimwiki#base#normalize_link(0) endif endif diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index d60a561..a9d82a2 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -145,6 +145,7 @@ function! s:read_global_settings_from_user() \ 'auto_chdir': {'type': type(0), 'default': 0, 'min': 0, 'max': 1}, \ 'autowriteall': {'type': type(0), 'default': 1, 'min': 0, 'max': 1}, \ 'conceallevel': {'type': type(0), 'default': 2, 'min': 0, 'max': 3}, + \ 'create_link': {'type': type(0), 'default': 1, 'min':0, 'max': 1}, \ 'diary_months': {'type': type({}), 'default': \ { \ 1: 'January', 2: 'February', 3: 'March', diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index e8de748..8b956c1 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -2541,6 +2541,18 @@ Value Description~ Default: 1 +------------------------------------------------------------------------------ +*g:vimwiki_create_link* + +Create target wiki page if it does not exist. See |:VimwikiFollowLink|. + +Value Description~ +0 Do not create target wiki page. +1 Create target wiki page. + +Default: 1 + + ------------------------------------------------------------------------------ *VimwikiLinkHandler*