@@ -5,11 +5,12 @@ local M = {}
5
5
--- @class UserHighlights
6
6
--- @field public heading ? string
7
7
--- @field public code ? string
8
+ --- @field public bullet ? string
8
9
9
10
--- @class UserConfig
10
11
--- @field public query ? Query
11
12
--- @field public render_modes ? string[]
12
- --- @field public bullets ? string[]
13
+ --- @field public bullet ? string
13
14
--- @field public highlights ? Highlights
14
15
15
16
--- @param opts UserConfig | nil
@@ -28,11 +29,6 @@ function M.setup(opts)
28
29
MatchParen bg = 1f2e3f (deep blue) fg = 31748f (teel)
29
30
]]
30
31
31
- -- Some attempts to handle nested lists
32
- -- (list_item) @item1
33
- -- (list_item (list_item (list_item))) @item3
34
- -- (list) @item1
35
-
36
32
--- @type Config
37
33
local default_config = {
38
34
query = vim .treesitter .query .parse (
@@ -48,13 +44,16 @@ function M.setup(opts)
48
44
] @heading)
49
45
50
46
(fenced_code_block) @code
47
+
48
+ (list_item) @item
51
49
]]
52
50
),
53
51
render_modes = { ' n' , ' c' },
54
- bullets = { ' ◉ ' , ' ○ ' , ' ✸ ' , ' ✿ ' } ,
52
+ bullet = ' ○ ' ,
55
53
highlights = {
56
54
headings = { ' DiffAdd' , ' DiffChange' , ' DiffDelete' },
57
55
code = ' ColorColumn' ,
56
+ bullet = ' Normal' ,
58
57
},
59
58
}
60
59
state .config = vim .tbl_deep_extend (' force' , default_config , opts or {})
@@ -98,7 +97,7 @@ M.refresh = function()
98
97
--- @diagnostic disable-next-line : missing-parameter
99
98
for id , node in state .config .query :iter_captures (root , 0 ) do
100
99
local capture = state .config .query .captures [id ]
101
- local start_row , _ , end_row , _ = node :range ()
100
+ local start_row , start_col , end_row , end_col = node :range ()
102
101
103
102
if capture == ' heading' then
104
103
local level = # vim .treesitter .get_node_text (node , 0 )
@@ -115,9 +114,16 @@ M.refresh = function()
115
114
hl_group = highlights .code ,
116
115
hl_eol = true ,
117
116
})
117
+ elseif capture == ' item' then
118
+ vim .api .nvim_buf_set_extmark (0 , M .namespace , start_row , start_col , {
119
+ end_row = end_row ,
120
+ end_col = end_col ,
121
+ virt_text = { { state .config .bullet , highlights .bullet } },
122
+ virt_text_pos = ' overlay' ,
123
+ })
118
124
else
119
- vim . print ( ' Unknown capture: ' .. capture )
120
- vim .print (vim . treesitter . get_node_text ( node , 0 ) )
125
+ -- Should only get here if user provides custom capture, currently unhandled
126
+ vim .print (' Unhandled capture: ' .. capture )
121
127
end
122
128
end
123
129
end
0 commit comments