34
34
local function get_linkables (bufnr , file , workspace )
35
35
local ret = {}
36
36
37
+ local path
37
38
local lines
38
39
if file then
39
40
lines = vim .fn .readfile (file :tostring (" /" ))
40
- file = file : remove_suffix ( " .norg " )
41
- file = " $/" .. file :relative_to (workspace )
41
+ path = file
42
+ file = " $/" .. file :relative_to (workspace ): remove_suffix ( " .norg " )
42
43
else
43
44
lines = vim .api .nvim_buf_get_lines (bufnr , 0 , - 1 , true )
44
45
end
45
46
46
47
for i , line in ipairs (lines ) do
47
48
local heading = { line :match (" ^%s*(%*+%s+(.+))$" ) }
48
49
if not vim .tbl_isempty (heading ) then
49
- table.insert (ret , { line = i , linkable = heading [2 ], display = heading [1 ], file = file })
50
+ table.insert (ret , { line = i , linkable = heading [2 ], display = heading [1 ], file = file , path = path })
50
51
end
51
52
52
53
local marker_or_drawer = { line :match (" ^%s*(%|%|?%s+(.+))$" ) }
53
54
if not vim .tbl_isempty (marker_or_drawer ) then
54
- table.insert (ret , { line = i , linkable = marker_or_drawer [2 ], display = marker_or_drawer [1 ], file = file })
55
+ table.insert (
56
+ ret ,
57
+ { line = i , linkable = marker_or_drawer [2 ], display = marker_or_drawer [1 ], file = file , path = path }
58
+ )
55
59
end
56
60
end
57
61
@@ -111,16 +115,16 @@ return function(opts)
111
115
results = links ,
112
116
entry_maker = function (entry )
113
117
local displayer = entry_display .create ({
114
- separator = " : " ,
118
+ separator = " " ,
115
119
items = {
116
- { width = 30 },
120
+ { width = 55 },
117
121
{ remaining = true },
118
122
},
119
123
})
120
124
local function make_display (ent )
121
125
if entry .file then
122
126
return displayer ({
123
- { ent .file : sub ( - 30 , - 1 ) , " NeorgLinkFile" },
127
+ { ent .file , " NeorgLinkFile" },
124
128
{ ent .ordinal , " NeorgLinkText" },
125
129
})
126
130
else
@@ -129,6 +133,7 @@ return function(opts)
129
133
})
130
134
end
131
135
end
136
+
132
137
-- if not entry.file then
133
138
-- entry.file = vim.fn.expand("%:r")
134
139
-- end
@@ -139,11 +144,11 @@ return function(opts)
139
144
lnum = entry .line ,
140
145
file = entry .file and tostring (entry .file ) or nil ,
141
146
linkable = entry .linkable ,
147
+ path = entry .path :tostring (),
142
148
}
143
149
end ,
144
150
}),
145
- -- I couldn't get syntax highlight to work with this :(
146
- previewer = nil ,
151
+ previewer = conf .file_previewer (opts ),
147
152
sorter = conf .generic_sorter (opts ),
148
153
attach_mappings = function (prompt_bufnr )
149
154
actions_set .select :replace (function ()
0 commit comments