@@ -4,7 +4,7 @@ local tree_utils = require('orgmode.utils.treesitter')
44local Date = require (' orgmode.objects.date' )
55local Range = require (' orgmode.parser.range' )
66local config = require (' orgmode.config' )
7- local query = vim .treesitter . query
7+ local ts = vim .treesitter
88
99--- @class Headline
1010--- @field headline userdata
4646--- @return number
4747function Headline :level ()
4848 local stars = self :stars ()
49- return query .get_node_text (stars , 0 ):len ()
49+ return ts .get_node_text (stars , 0 ):len ()
5050end
5151
5252function Headline :priority ()
9494
9595function Headline :_handle_promote_demote (recursive , modifier )
9696 local whole_subtree = function ()
97- local text = query .get_node_text (self .headline :parent (), 0 )
97+ local text = ts .get_node_text (self .headline :parent (), 0 )
9898 local lines = modifier (vim .split (text , ' \n ' , true ))
9999 tree_utils .set_node_lines (self .headline :parent (), lines )
100100 return self :refresh ()
@@ -128,7 +128,7 @@ function Headline:tags()
128128 local node = self .headline :field (' tags' )[1 ]
129129 local text = ' '
130130 if node then
131- text = query .get_node_text (node , 0 )
131+ text = ts .get_node_text (node , 0 )
132132 end
133133 return node , text
134134end
@@ -142,7 +142,7 @@ function Headline:set_tags(tags)
142142 end
143143 end
144144
145- local txt = query .get_node_text (predecessor , 0 )
145+ local txt = ts .get_node_text (predecessor , 0 )
146146 local pred_end_row , pred_end_col , _ = predecessor :end_ ()
147147 local line = vim .fn .getline (pred_end_row + 1 )
148148 local stars = line :match (' ^%*+%s*' )
@@ -190,13 +190,13 @@ function Headline:set_priority(priority)
190190
191191 local todo = self :todo ()
192192 if todo then
193- local text = query .get_node_text (todo , 0 )
193+ local text = ts .get_node_text (todo , 0 )
194194 tree_utils .set_node_text (todo , (' %s [#%s]' ):format (text , priority ))
195195 return
196196 end
197197
198198 local stars = self :stars ()
199- local text = query .get_node_text (stars , 0 )
199+ local text = ts .get_node_text (stars , 0 )
200200 tree_utils .set_node_text (stars , (' %s [#%s]' ):format (text , priority ))
201201end
202202
@@ -209,7 +209,7 @@ function Headline:set_todo(keyword)
209209 end
210210
211211 local stars = self :stars ()
212- local text = query .get_node_text (stars , 0 )
212+ local text = ts .get_node_text (stars , 0 )
213213 tree_utils .set_node_text (stars , string.format (' %s %s' , text , keyword ))
214214end
215215
@@ -231,7 +231,7 @@ function Headline:todo()
231231 return nil
232232 end
233233
234- local text = query .get_node_text (todo_node , 0 )
234+ local text = ts .get_node_text (todo_node , 0 )
235235 for _ , word in ipairs (keywords ) do
236236 -- there may be multiple substitutions necessary
237237 local escaped_word = vim .pesc (word )
@@ -272,7 +272,7 @@ function Headline:is_done()
272272end
273273
274274function Headline :title ()
275- local title = query .get_node_text (self :item (), 0 ) or ' '
275+ local title = ts .get_node_text (self :item (), 0 ) or ' '
276276 local todo , word = self :todo ()
277277 if todo then
278278 title = title :gsub (' ^' .. vim .pesc (word ) .. ' %s*' , ' ' )
@@ -334,11 +334,11 @@ function Headline:get_property(property_name)
334334 for _ , node in ipairs (ts_utils .get_named_children (properties )) do
335335 local name = node :field (' name' )[1 ]
336336 local value = node :field (' value' )[1 ]
337- if name and query .get_node_text (name , 0 ):lower () == property_name :lower () then
337+ if name and ts .get_node_text (name , 0 ):lower () == property_name :lower () then
338338 return {
339339 node = node ,
340340 name = name ,
341- value = value and query .get_node_text (value , 0 ),
341+ value = value and ts .get_node_text (value , 0 ),
342342 }
343343 end
344344 end
@@ -369,7 +369,7 @@ function Headline:dates()
369369 end
370370
371371 for _ , node in ipairs (ts_utils .get_named_children (plan )) do
372- local name = query .get_node_text (node :named_child (0 ), 0 )
372+ local name = ts .get_node_text (node :named_child (0 ), 0 )
373373 dates [name ] = node
374374 end
375375 return dates
@@ -445,7 +445,7 @@ function Headline:update_cookie(list_node)
445445 local cookie = self :cookie ()
446446 if cookie then
447447 local new_cookie_val
448- if query .get_node_text (cookie , 0 ):find (' %%' ) then
448+ if ts .get_node_text (cookie , 0 ):find (' %%' ) then
449449 new_cookie_val = (' [%d%%]' ):format ((# checked_boxes / # total_boxes ) * 100 )
450450 else
451451 new_cookie_val = (' [%d/%d]' ):format (# checked_boxes , # total_boxes )
456456
457457function Headline :child_checkboxes (list_node )
458458 return vim .tbl_map (function (node )
459- local text = query .get_node_text (node , 0 )
459+ local text = ts .get_node_text (node , 0 )
460460 return text :match (' %[.%]' )
461461 end , ts_utils .get_named_children (list_node ))
462462end
465465function Headline :parse (pattern )
466466 local match = ' '
467467 local matching_nodes = vim .tbl_filter (function (node )
468- local text = query .get_node_text (node , 0 ) or ' '
468+ local text = ts .get_node_text (node , 0 ) or ' '
469469 local m = text :match (pattern )
470470 if m then
471471 match = text :match (pattern )
@@ -487,7 +487,7 @@ function Headline:_get_date(type)
487487 if not timestamp_node then
488488 return nil
489489 end
490- local parsed_date = Date .from_org_date (query .get_node_text (timestamp_node , 0 ), {
490+ local parsed_date = Date .from_org_date (ts .get_node_text (timestamp_node , 0 ), {
491491 range = Range .from_node (timestamp_node ),
492492 })
493493 return parsed_date and parsed_date [1 ] or nil
@@ -522,7 +522,7 @@ function Headline:_add_date(type, date, active)
522522 break
523523 end
524524 end
525- local ptext = query .get_node_text (last_child , 0 )
525+ local ptext = ts .get_node_text (last_child , 0 )
526526 tree_utils .set_node_text (last_child , ptext .. ' ' .. text )
527527 return self :refresh ()
528528end
0 commit comments