diff --git a/README.md b/README.md index 568c9de..2005912 100644 --- a/README.md +++ b/README.md @@ -456,7 +456,8 @@ require('mkdnflow').setup({ text = text:lower() text = os.date('%Y-%m-%d_')..text return(text) - end + end, + create_on_follow_failure = true }, new_file_template = { use_template = false, @@ -632,6 +633,10 @@ function(input) end ``` +* 🆕 `links.create_on_follow_failure` (boolean): Whether a link should be created if there is no link to follow under the cursor. + * `true` (default): Create a link if there's no link to follow + * `false`: Do not create a link if there's no link to follow + #### `new_file_template` (dictionary-like table) * `new_file_template.use_template` (boolean) * `true`: the template is filled in (if it contains placeholders) and inserted into any new buffers entered by following a link to a buffer that doesn't exist yet diff --git a/lua/mkdnflow.lua b/lua/mkdnflow.lua index 079cc3c..62ea620 100644 --- a/lua/mkdnflow.lua +++ b/lua/mkdnflow.lua @@ -64,7 +64,8 @@ local default_config = { text = text:lower() text = os.date('%Y-%m-%d_') .. text return text - end + end, + create_on_follow_failure = true }, new_file_template = { use_template = false, diff --git a/lua/mkdnflow/links.lua b/lua/mkdnflow/links.lua index 07fc690..d6804d1 100644 --- a/lua/mkdnflow/links.lua +++ b/lua/mkdnflow/links.lua @@ -999,7 +999,7 @@ M.followLink = function(args) true, {} ) - else + elseif links.create_on_follow_failure then M.createLink({ range = range }) end end