mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
fix #45
This commit is contained in:
@@ -21,6 +21,8 @@
|
|||||||
- [ ] yt video
|
- [ ] yt video
|
||||||
|
|
||||||
## Dones
|
## Dones
|
||||||
|
- [x] make `resolve_link()` return the best-match root and use it as `cwd` in `follow_link()`
|
||||||
|
- this better supports out-of-home daily/weekly dirs
|
||||||
- [x] option to show number of links and backlinks in note picker
|
- [x] option to show number of links and backlinks in note picker
|
||||||
- see #36
|
- see #36
|
||||||
- [x] ==backlinks are broken: they contain the home dir==
|
- [x] ==backlinks are broken: they contain the home dir==
|
||||||
|
|||||||
@@ -821,14 +821,17 @@ local function resolve_link(title)
|
|||||||
local fexists = false
|
local fexists = false
|
||||||
local filename = title .. M.Cfg.extension
|
local filename = title .. M.Cfg.extension
|
||||||
filename = filename:gsub("^%./", "") -- strip potential leading ./
|
filename = filename:gsub("^%./", "") -- strip potential leading ./
|
||||||
|
local best_root = M.Cfg.home
|
||||||
|
|
||||||
if M.Cfg.weeklies and file_exists(M.Cfg.weeklies .. "/" .. filename) then
|
if M.Cfg.weeklies and file_exists(M.Cfg.weeklies .. "/" .. filename) then
|
||||||
filename = M.Cfg.weeklies .. "/" .. filename
|
filename = M.Cfg.weeklies .. "/" .. filename
|
||||||
fexists = true
|
fexists = true
|
||||||
|
best_root = M.Cfg.weeklies
|
||||||
end
|
end
|
||||||
if M.Cfg.dailies and file_exists(M.Cfg.dailies .. "/" .. filename) then
|
if M.Cfg.dailies and file_exists(M.Cfg.dailies .. "/" .. filename) then
|
||||||
filename = M.Cfg.dailies .. "/" .. filename
|
filename = M.Cfg.dailies .. "/" .. filename
|
||||||
fexists = true
|
fexists = true
|
||||||
|
best_root = M.Cfg.dailies
|
||||||
end
|
end
|
||||||
if file_exists(M.Cfg.home .. "/" .. filename) then
|
if file_exists(M.Cfg.home .. "/" .. filename) then
|
||||||
filename = M.Cfg.home .. "/" .. filename
|
filename = M.Cfg.home .. "/" .. filename
|
||||||
@@ -855,7 +858,7 @@ local function resolve_link(title)
|
|||||||
-- default fn for creation
|
-- default fn for creation
|
||||||
filename = M.Cfg.home .. "/" .. filename
|
filename = M.Cfg.home .. "/" .. filename
|
||||||
end
|
end
|
||||||
return fexists, filename
|
return fexists, filename, best_root
|
||||||
end
|
end
|
||||||
|
|
||||||
-- local function check_for_link_or_tag()
|
-- local function check_for_link_or_tag()
|
||||||
@@ -907,6 +910,7 @@ local function FollowLink(opts)
|
|||||||
|
|
||||||
-- first: check if we're in a tag or a link
|
-- first: check if we're in a tag or a link
|
||||||
local kind, atcol, tag
|
local kind, atcol, tag
|
||||||
|
local best_root
|
||||||
|
|
||||||
if opts.follow_tag ~= nil then
|
if opts.follow_tag ~= nil then
|
||||||
kind = "tag"
|
kind = "tag"
|
||||||
@@ -952,7 +956,7 @@ local function FollowLink(opts)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #filename > 0 then
|
if #filename > 0 then
|
||||||
fexists, filename = resolve_link(filename)
|
fexists, filename, _ = resolve_link(filename)
|
||||||
if fexists == false then
|
if fexists == false then
|
||||||
-- print("error")
|
-- print("error")
|
||||||
filename = ""
|
filename = ""
|
||||||
@@ -962,7 +966,7 @@ local function FollowLink(opts)
|
|||||||
|
|
||||||
if search_mode == "files" then
|
if search_mode == "files" then
|
||||||
-- check if fname exists anywhere
|
-- check if fname exists anywhere
|
||||||
fexists, filename = resolve_link(title)
|
fexists, filename, best_root = resolve_link(title)
|
||||||
if
|
if
|
||||||
(fexists ~= true)
|
(fexists ~= true)
|
||||||
and (
|
and (
|
||||||
@@ -981,7 +985,7 @@ local function FollowLink(opts)
|
|||||||
|
|
||||||
find_files_sorted({
|
find_files_sorted({
|
||||||
prompt_title = "Follow link to note...",
|
prompt_title = "Follow link to note...",
|
||||||
cwd = M.Cfg.home,
|
cwd = best_root,
|
||||||
default_text = title,
|
default_text = title,
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
attach_mappings = function(_, map)
|
attach_mappings = function(_, map)
|
||||||
|
|||||||
Reference in New Issue
Block a user