mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
Add follow_url_fallback config option (#172)
* Add follow_link_fallback config option * Update README.md * Rename follow_link_fallback to follow_url_fallback. Change logic of configuring
This commit is contained in:
committed by
GitHub
parent
923274dfb8
commit
60808e8e59
@@ -411,6 +411,9 @@ require('telekasten').setup({
|
||||
-- "telescope-media-files" if you have telescope-media-files.nvim installed
|
||||
-- "catimg-previewer" if you have catimg installed
|
||||
media_previewer = "telescope-media-files",
|
||||
|
||||
-- A customizable fallback handler for urls.
|
||||
follow_url_fallback = nil,
|
||||
})
|
||||
END
|
||||
```
|
||||
@@ -475,6 +478,7 @@ END
|
||||
| `media_previewer` | how to preview media files | default: `telescope-media-files` |
|
||||
|| - `telescope-media-files` if you have telescope-media-files.nvim installed |
|
||||
|| - `catimg-previewer` if you have catimg installed |
|
||||
| `follow_url_fallback ` | A customizable fallback handler for urls. | default: `nil` |
|
||||
|
||||
The calendar support has its own options, contained in `calendar_opts`:
|
||||
|
||||
|
||||
@@ -418,6 +418,13 @@ telekasten.setup({opts})
|
||||
|
||||
Default: `telescope-media-files`
|
||||
|
||||
*telekasten.settings.follow_url_fallback*
|
||||
follow_url_fallback:~
|
||||
A customizable fallback handler for urls.
|
||||
When it set to nil, Telekasten will use `xdg-open` or `open`
|
||||
|
||||
Default: `nil`
|
||||
Example: `"call jobstart('firefox --new-window {{url}}')"`
|
||||
*telekasten.calendar_opts*
|
||||
-----------------------------------
|
||||
Valid keys for {opts.calendar_opts}
|
||||
|
||||
@@ -156,6 +156,9 @@ local function defaultConfig(home)
|
||||
-- "catimg-previewer" if you have catimg installed
|
||||
-- "viu-previewer" if you have viu installed
|
||||
media_previewer = "telescope-media-files",
|
||||
|
||||
-- A customizable fallback handler for urls.
|
||||
follow_url_fallback = nil,
|
||||
}
|
||||
M.Cfg = cfg
|
||||
M.note_type_templates = {
|
||||
@@ -1473,6 +1476,11 @@ local function check_for_link_or_tag()
|
||||
end
|
||||
|
||||
local function follow_url(url)
|
||||
if M.Cfg.follow_url_fallback then
|
||||
local cmd = string.gsub(M.Cfg.follow_url_fallback, "{{url}}", url)
|
||||
return vim.cmd(cmd)
|
||||
end
|
||||
|
||||
-- we just leave it to the OS's handler to deal with what kind of URL it is
|
||||
local function format_command(cmd)
|
||||
return 'call jobstart(["'
|
||||
|
||||
Reference in New Issue
Block a user