Skip to content

Commit

Permalink
feat: Make link creation after failed follow optional
Browse files Browse the repository at this point in the history
- Add new config option in mkdnflow.lua
- Modify followLink function to consult config before creating a link
- Update README with new config details
  • Loading branch information
jakewvincent committed Jun 3, 2024
1 parent ff300eb commit b1cea92
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lua/mkdnflow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lua/mkdnflow/links.lua
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ M.followLink = function(args)
true,
{}
)
else
elseif links.create_on_follow_failure then
M.createLink({ range = range })
end
end
Expand Down

0 comments on commit b1cea92

Please sign in to comment.