@@ -11,7 +11,7 @@ local constants = require('orgmode.utils.constants')
11
11
local ts_utils = require (' nvim-treesitter.ts_utils' )
12
12
local utils = require (' orgmode.utils' )
13
13
local tree_utils = require (' orgmode.utils.treesitter' )
14
- local Headline = require (' orgmode.treesitter.headline ' )
14
+ local ts_org = require (' orgmode.treesitter' )
15
15
local Listitem = require (' orgmode.treesitter.listitem' )
16
16
17
17
--- @class OrgMappings
@@ -64,7 +64,7 @@ function OrgMappings:archive()
64
64
end
65
65
66
66
function OrgMappings :set_tags ()
67
- local headline = Headline : new ( tree_utils .closest_headline () )
67
+ local headline = ts_org .closest_headline ()
68
68
local _ , current_tags = headline :tags ()
69
69
70
70
local tags = vim .fn .OrgmodeInput (' Tags: ' , current_tags , Files .autocomplete_tags )
@@ -73,7 +73,7 @@ function OrgMappings:set_tags()
73
73
end
74
74
75
75
function OrgMappings :toggle_archive_tag ()
76
- local headline = Headline : new ( tree_utils .closest_headline () )
76
+ local headline = ts_org .closest_headline ()
77
77
local _ , current_tags = headline :tags ()
78
78
79
79
local parsed = utils .parse_tags_string (current_tags )
@@ -159,10 +159,9 @@ function OrgMappings:toggle_checkbox()
159
159
-- move to the first non-blank character so the current treesitter node is the listitem
160
160
vim .cmd ([[ normal! _]] )
161
161
162
- vim .treesitter .get_parser (0 , ' org' ):parse ()
163
- local listitem = tree_utils .find_parent_type (tree_utils .current_node (), ' listitem' )
162
+ local listitem = ts_org .listitem ()
164
163
if listitem then
165
- Listitem : new ( listitem ) :update_checkbox (' toggle' )
164
+ listitem :update_checkbox (' toggle' )
166
165
end
167
166
168
167
vim .fn .winrestview (win_view )
@@ -313,7 +312,7 @@ function OrgMappings:priority_down()
313
312
end
314
313
315
314
function OrgMappings :set_priority (direction )
316
- local headline = Headline : new ( tree_utils .closest_headline () )
315
+ local headline = ts_org .closest_headline ()
317
316
local _ , current_priority = headline :priority ()
318
317
local priority_state = PriorityState :new (current_priority )
319
318
@@ -368,7 +367,7 @@ function OrgMappings:toggle_heading()
368
367
end
369
368
370
369
function OrgMappings :_todo_change_state (direction )
371
- local headline = Headline : new ( tree_utils .closest_headline () )
370
+ local headline = ts_org .closest_headline ()
372
371
local _ , old_state , was_done = headline :todo ()
373
372
local changed = self :_change_todo_state (direction , true )
374
373
if not changed then
@@ -530,8 +529,10 @@ function OrgMappings:handle_return(suffix)
530
529
531
530
-- update all parents when we insert a new checkbox
532
531
if checkbox then
533
- local new_listitem = tree_utils .find_parent_type (tree_utils .current_node (), ' listitem' )
534
- Listitem :new (new_listitem ):update_checkbox (' off' )
532
+ local new_listitem = ts_org .listitem ()
533
+ if new_listitem then
534
+ new_listitem :update_checkbox (' off' )
535
+ end
535
536
end
536
537
537
538
vim .cmd ([[ startinsert!]] )
764
765
--- @param use_fast_access ? boolean
765
766
--- @return string
766
767
function OrgMappings :_change_todo_state (direction , use_fast_access )
767
- local headline = Headline : new ( tree_utils .closest_headline () )
768
+ local headline = ts_org .closest_headline ()
768
769
local todo , current_keyword = headline :todo ()
769
770
local todo_state = TodoState :new ({ current_state = current_keyword })
770
771
local next_state = nil
0 commit comments