@@ -552,14 +552,20 @@ docgen.generators = {
552
552
" " ,
553
553
" ### Further Reading" ,
554
554
" " ,
555
- docgen .lookup_modules (mods , " To find out how to rebind the available keys consult the [`core.keybinds`](@core.keybinds) wiki entry." ),
555
+ docgen .lookup_modules (
556
+ mods ,
557
+ " To find out how to rebind the available keys consult the [`core.keybinds`](@core.keybinds) wiki entry."
558
+ ),
556
559
" " ,
557
560
}
558
561
559
562
local main_preset = " neorg"
560
563
561
564
for preset_name , preset_data in vim .spairs (keybind_data ) do
562
- table.insert (layout , string.format (" ## Preset `%s`%s" , preset_name , preset_name == main_preset and " (default)" or " " ))
565
+ table.insert (
566
+ layout ,
567
+ string.format (" ## Preset `%s`%s" , preset_name , preset_name == main_preset and " (default)" or " " )
568
+ )
563
569
table.insert (layout , " " )
564
570
565
571
for neorg_mode_name , neorg_mode_data in vim .spairs (preset_data ) do
@@ -583,9 +589,11 @@ docgen.generators = {
583
589
584
590
for key , data in vim .spairs (mode_data ) do
585
591
if not vim .tbl_isempty (data .comments ) then
586
- local comments = vim .iter (data .comments ):map (function (comment )
587
- return (comment :gsub (" ^%s*%-%-%s*" , " " ))
588
- end ):totable ()
592
+ local comments = vim .iter (data .comments )
593
+ :map (function (comment )
594
+ return (comment :gsub (" ^%s*%-%-%s*" , " " ))
595
+ end )
596
+ :totable ()
589
597
590
598
local mnemonic = docgen .extract_mnemonic (comments )
591
599
@@ -599,7 +607,10 @@ docgen.generators = {
599
607
table.insert (layout , string.format (" - `%s` - %s" , key , description ))
600
608
table.insert (layout , string.format (" - Default map: `%s`" , data .rhs ))
601
609
if mnemonic then
602
- table.insert (layout , string.format (" - Mnemonic: %s" , docgen .format_mnemonic (mnemonic )))
610
+ table.insert (
611
+ layout ,
612
+ string.format (" - Mnemonic: %s" , docgen .format_mnemonic (mnemonic ))
613
+ )
603
614
end
604
615
605
616
table.insert (layout , " " )
@@ -610,7 +621,7 @@ docgen.generators = {
610
621
end
611
622
612
623
return layout
613
- end
624
+ end ,
614
625
}
615
626
616
627
--- Check the integrity of the description comments found in configuration blocks
@@ -788,55 +799,66 @@ end
788
799
--- @param buffer number The buffer ID to extract information from.
789
800
--- @return table<string , table>
790
801
docgen .parse_keybind_data = function (buffer )
791
- local query = utils .ts_parse_query (" lua" , [[
802
+ local query = utils .ts_parse_query (
803
+ " lua" ,
804
+ [[
792
805
(field
793
806
name: (identifier) @_ident
794
807
(#eq? @_ident "presets")) @presets
795
- ]] )
796
-
797
- local root = assert (vim .treesitter .get_parser (buffer , " lua" ):parse ()[1 ]:root (), " unable to parse keybinds!" )
798
-
799
- local _ , presets = query :iter_captures (root , buffer )()
800
- assert (presets , " could not find presets" )
801
-
802
- local available_keys = neorg .modules .loaded_modules [" core.keybinds" ].private .presets
803
-
804
- local output = vim .defaulttable ()
805
-
806
- for preset in presets :named_child (1 ):iter_children () do
807
- if preset :type () == " field" then
808
- local preset_name , preset_data = vim .treesitter .get_node_text (assert (preset :named_child (0 )), buffer ), preset :named_child (1 )
809
-
810
- for neorg_mode in assert (preset_data ):iter_children () do
811
- if neorg_mode :type () == " field" then
812
- local neorg_mode_name , neorg_mode_data = vim .treesitter .get_node_text (assert (neorg_mode :named_child (0 )), buffer ), neorg_mode :named_child (1 )
813
-
814
- for neovim_mode in assert (neorg_mode_data ):iter_children () do
815
- if neovim_mode :type () == " field" then
816
- local mode_name , mode_data = vim .treesitter .get_node_text (assert (neovim_mode :named_child (0 )), buffer ), neovim_mode :named_child (1 )
817
-
818
- local comments = {}
819
- local i , keybind_data
808
+ ]]
809
+ )
820
810
821
- for comment_or_data in assert (mode_data ):iter_children () do
822
- if comment_or_data :type () == " comment" then
823
- table.insert (comments , vim .trim (vim .treesitter .get_node_text (comment_or_data , buffer )))
824
- elseif comment_or_data :type () == " field" then
825
- i , keybind_data = next (available_keys [preset_name ][neorg_mode_name ][mode_name ], i )
826
- output [preset_name ][neorg_mode_name ][mode_name ][keybind_data [1 ]] = {
827
- comments = comments ,
828
- rhs = keybind_data [2 ],
829
- }
830
- comments = {}
831
- end
811
+ local root = assert (vim .treesitter .get_parser (buffer , " lua" ):parse ()[1 ]:root (), " unable to parse keybinds!" )
812
+
813
+ local _ , presets = query :iter_captures (root , buffer )()
814
+ assert (presets , " could not find presets" )
815
+
816
+ local available_keys = neorg .modules .loaded_modules [" core.keybinds" ].private .presets
817
+
818
+ local output = vim .defaulttable ()
819
+
820
+ for preset in presets :named_child (1 ):iter_children () do
821
+ if preset :type () == " field" then
822
+ local preset_name , preset_data =
823
+ vim .treesitter .get_node_text (assert (preset :named_child (0 )), buffer ), preset :named_child (1 )
824
+
825
+ for neorg_mode in assert (preset_data ):iter_children () do
826
+ if neorg_mode :type () == " field" then
827
+ local neorg_mode_name , neorg_mode_data =
828
+ vim .treesitter .get_node_text (assert (neorg_mode :named_child (0 )), buffer ),
829
+ neorg_mode :named_child (1 )
830
+
831
+ for neovim_mode in assert (neorg_mode_data ):iter_children () do
832
+ if neovim_mode :type () == " field" then
833
+ local mode_name , mode_data =
834
+ vim .treesitter .get_node_text (assert (neovim_mode :named_child (0 )), buffer ),
835
+ neovim_mode :named_child (1 )
836
+
837
+ local comments = {}
838
+ local i , keybind_data
839
+
840
+ for comment_or_data in assert (mode_data ):iter_children () do
841
+ if comment_or_data :type () == " comment" then
842
+ table.insert (
843
+ comments ,
844
+ vim .trim (vim .treesitter .get_node_text (comment_or_data , buffer ))
845
+ )
846
+ elseif comment_or_data :type () == " field" then
847
+ i , keybind_data = next (available_keys [preset_name ][neorg_mode_name ][mode_name ], i )
848
+ output [preset_name ][neorg_mode_name ][mode_name ][keybind_data [1 ]] = {
849
+ comments = comments ,
850
+ rhs = keybind_data [2 ],
851
+ }
852
+ comments = {}
832
853
end
833
854
end
834
855
end
835
856
end
836
857
end
837
858
end
838
859
end
839
- return output
860
+ end
861
+ return output
840
862
end
841
863
842
864
docgen .format_mnemonic = function (str )
0 commit comments