mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
implement #26 : follow external urls
This commit is contained in:
@@ -2,17 +2,19 @@
|
|||||||
|
|
||||||
- [ ] maybe a virtual line in the 1st line that shows number of backlinks and maybe other interesting stuff
|
- [ ] maybe a virtual line in the 1st line that shows number of backlinks and maybe other interesting stuff
|
||||||
- or put it as an extmark at the end of the first line, meh.
|
- or put it as an extmark at the end of the first line, meh.
|
||||||
- [ ] better support for #tags
|
- [ ] better support for #tags [see also this comment](https://github.com/renerocksai/telekasten.nvim/discussions/23#discussioncomment-1754511)
|
||||||
- [ ] some cool buffer showing backlinks (and stuff?)
|
- [ ] some cool buffer showing backlinks (and stuff?) [see also this comment](https://github.com/renerocksai/telekasten.nvim/discussions/23#discussioncomment-1754511)
|
||||||
- maybe another one where we dot-render a graph of linked notes and
|
- maybe another one where we dot-render a graph of linked notes and
|
||||||
display it via vimg from telescope_media_files or sth similar
|
display it via vimg from telescope_media_files or sth similar
|
||||||
- these buffers / this buffer should keep its size even when resizing other
|
- these buffers / this buffer should keep its size even when resizing other
|
||||||
splits (like the calendar)
|
splits (like the calendar)
|
||||||
- [ ] really good support for special links: inserting, yanking, ...
|
- [ ] really good support for special links: inserting, yanking, ...
|
||||||
|
- [ ] lsp support, lsp completion of everything: notes, headings, paragraphs, tags, ...
|
||||||
|
|
||||||
- [ ] yt video
|
- [ ] yt video
|
||||||
|
|
||||||
## Dones
|
## Dones
|
||||||
|
- [x] follow external URLs
|
||||||
- [x] telekasten filetype
|
- [x] telekasten filetype
|
||||||
- [x] Telekasten command with completion, command palette
|
- [x] Telekasten command with completion, command palette
|
||||||
- [x] follow #tags
|
- [x] follow #tags
|
||||||
|
|||||||
@@ -695,6 +695,30 @@ local function check_for_link_or_tag()
|
|||||||
return taglinks.is_tag_or_link_at(line, col, M.Cfg)
|
return taglinks.is_tag_or_link_at(line, col, M.Cfg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function follow_url(url)
|
||||||
|
-- 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(["'
|
||||||
|
.. cmd
|
||||||
|
.. '", "'
|
||||||
|
.. url
|
||||||
|
.. '"], {"detach": v:true})'
|
||||||
|
end
|
||||||
|
|
||||||
|
local command
|
||||||
|
if vim.fn.has("mac") == 1 then
|
||||||
|
command = format_command("open")
|
||||||
|
vim.cmd(command)
|
||||||
|
else
|
||||||
|
if vim.fn.has("unix") then
|
||||||
|
command = format_command("xdg-open")
|
||||||
|
vim.cmd(command)
|
||||||
|
else
|
||||||
|
print("Cannot open URLs on your operating system")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- FollowLink:
|
-- FollowLink:
|
||||||
-- -----------
|
-- -----------
|
||||||
@@ -725,10 +749,18 @@ local function FollowLink(opts)
|
|||||||
search_mode = "tag"
|
search_mode = "tag"
|
||||||
title = tag
|
title = tag
|
||||||
else
|
else
|
||||||
-- we are in a link
|
if kind == "link" then
|
||||||
vim.cmd("normal yi]")
|
-- we are in a link
|
||||||
title = vim.fn.getreg('"0')
|
vim.cmd("normal yi]")
|
||||||
title = title:gsub("^(%[)(.+)(%])$", "%2")
|
title = vim.fn.getreg('"0')
|
||||||
|
title = title:gsub("^(%[)(.+)(%])$", "%2")
|
||||||
|
else
|
||||||
|
-- we are in an external [link]
|
||||||
|
vim.cmd("normal yi)")
|
||||||
|
local url = vim.fn.getreg('"0')
|
||||||
|
print(url)
|
||||||
|
return follow_url(url)
|
||||||
|
end
|
||||||
|
|
||||||
local parts = vim.split(title, "#")
|
local parts = vim.split(title, "#")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user