Skip to content

Commit b1cea92

Browse files
committed
feat: Make link creation after failed follow optional
- Add new config option in mkdnflow.lua - Modify followLink function to consult config before creating a link - Update README with new config details
1 parent ff300eb commit b1cea92

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,8 @@ require('mkdnflow').setup({
456456
text = text:lower()
457457
text = os.date('%Y-%m-%d_')..text
458458
return(text)
459-
end
459+
end,
460+
create_on_follow_failure = true
460461
},
461462
new_file_template = {
462463
use_template = false,
@@ -632,6 +633,10 @@ function(input)
632633
end
633634
```
634635

636+
* 🆕 `links.create_on_follow_failure` (boolean): Whether a link should be created if there is no link to follow under the cursor.
637+
* `true` (default): Create a link if there's no link to follow
638+
* `false`: Do not create a link if there's no link to follow
639+
635640
#### `new_file_template` (dictionary-like table)
636641
* `new_file_template.use_template` (boolean)
637642
* `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

lua/mkdnflow.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ local default_config = {
6464
text = text:lower()
6565
text = os.date('%Y-%m-%d_') .. text
6666
return text
67-
end
67+
end,
68+
create_on_follow_failure = true
6869
},
6970
new_file_template = {
7071
use_template = false,

lua/mkdnflow/links.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ M.followLink = function(args)
999999
true,
10001000
{}
10011001
)
1002-
else
1002+
elseif links.create_on_follow_failure then
10031003
M.createLink({ range = range })
10041004
end
10051005
end

0 commit comments

Comments
 (0)