@@ -40,13 +40,15 @@ local function generate_links()
40
40
if not files [2 ] then
41
41
return
42
42
end
43
+ if not (pcall (require , " pathlib" )) then
44
+ error (" neorg-telescope Dependency Error: pysan3/pathlib.nvim is a required dependency." )
45
+ end
43
46
44
47
local ts = neorg .modules .get_module (" core.integrations.treesitter" )
45
48
46
- local workspace_offset = # tostring (files [1 ]) + 1
47
-
49
+ local Path = require (" pathlib" )
48
50
for _ , file in pairs (files [2 ]) do
49
- local bufnr = dirman .get_file_bufnr (file )
51
+ local bufnr = dirman .get_file_bufnr (tostring ( file ) )
50
52
51
53
local title = nil
52
54
local title_display = " "
@@ -59,10 +61,12 @@ local function generate_links()
59
61
end
60
62
61
63
if vim .api .nvim_get_current_buf () ~= bufnr then
64
+ file = Path (file )
65
+ local relative = file :relative_to (Path (files [1 ]))
62
66
local links = {
63
67
file = file ,
64
- display = " $" .. file : sub ( workspace_offset , - 1 ) .. title_display ,
65
- relative = file : sub ( workspace_offset , - 1 ): sub ( 0 , - 6 ),
68
+ display = " $/ " .. relative .. title_display ,
69
+ relative = relative : remove_suffix ( " .norg " ),
66
70
title = title ,
67
71
}
68
72
table.insert (res , links )
@@ -99,24 +103,12 @@ return function(opts)
99
103
actions_set .select :replace (function ()
100
104
local entry = state .get_selected_entry ()
101
105
102
- local path_no_extension
103
-
104
- if entry then
105
- path_no_extension , _ = entry .value .file :gsub (" %.norg$" , " " )
106
- else
107
- path_no_extension = state .get_current_line ()
108
- end
109
-
110
106
actions .close (prompt_bufnr )
111
107
112
- local file_name , _ = path_no_extension :gsub (" .*%/" , " " )
113
-
114
108
vim .api .nvim_put ({
115
- " {" .. " :$" .. entry .relative .. " :" .. " }" .. " [" .. (entry .title or file_name ) .. " ]" ,
116
- }, " c" , true , true )
117
- if mode == " i" then
118
- vim .api .nvim_feedkeys (" a" , " n" , false )
119
- end
109
+ " {" .. " :$/" .. entry .relative .. " :" .. " }" .. " [" .. (entry .title or entry .relative ) .. " ]" ,
110
+ }, " c" , false , true )
111
+ vim .api .nvim_feedkeys (" hf]a" , " t" , false )
120
112
end )
121
113
return true
122
114
end ,
0 commit comments