@@ -116,16 +116,19 @@ module.load = function()
116
116
end
117
117
end )
118
118
local result = {}
119
- local prefix = string.rep (" * " , heading_level )
119
+ local prefix = string.rep (" " , heading_level )
120
120
121
121
for category , data in vim .spairs (categories ) do
122
- table.insert (result , prefix .. " " .. category )
123
-
122
+ if # result > 0 then
123
+ table.insert (result , " " )
124
+ end
125
+ table.insert (result , prefix .. " #cat " .. category )
124
126
for _ , datapoint in ipairs (data ) do
125
127
table.insert (
126
128
result ,
127
129
table.concat ({
128
- " - {:$" ,
130
+ prefix ,
131
+ " {:$" ,
129
132
datapoint .norgname ,
130
133
" :}[" ,
131
134
neorg .lib .title (datapoint .title ),
@@ -200,7 +203,27 @@ module.on_event = function(event)
200
203
return
201
204
end
202
205
203
- vim .api .nvim_buf_set_lines (buffer , event .cursor_position [1 ], event .cursor_position [1 ], true , generated )
206
+ -- surround with a ranged tag
207
+ table.insert (generated , 1 , " |group summary" )
208
+ table.insert (generated , " |end" )
209
+
210
+ local start_line = event .cursor_position [1 ]
211
+ local end_line = start_line
212
+ -- find * replace an existing ranged tag
213
+ local node_line_below = ts .get_first_node_on_line (buffer , start_line )
214
+ if node_line_below and node_line_below :type () == " _paragraph_break" then
215
+ -- allow for a line break between heading and tag
216
+ node_line_below = ts .get_first_node_on_line (buffer , start_line + 1 )
217
+ end
218
+ if node_line_below and node_line_below :type () == " ranged_tag" then
219
+ start_line , _ = node_line_below :start ()
220
+ end_line , _ = node_line_below :end_ ()
221
+ end_line = end_line + 1
222
+ else
223
+ neorg .utils .notify (node_line_below :type ())
224
+ end
225
+
226
+ vim .api .nvim_buf_set_lines (buffer , start_line , end_line , true , generated )
204
227
end
205
228
end
206
229
0 commit comments