@@ -40,30 +40,27 @@ M.render_node = function(namespace, buf, capture, node)
40
40
local background = list .clamp (heading .backgrounds , level )
41
41
local foreground = list .clamp (heading .foregrounds , level )
42
42
43
- local heading_text = { str .pad (icon , padding ), { foreground , background } }
44
43
vim .api .nvim_buf_set_extmark (buf , namespace , start_row , 0 , {
45
44
end_row = end_row + 1 ,
46
45
end_col = 0 ,
47
46
hl_group = background ,
48
- virt_text = { heading_text },
47
+ virt_text = { { str . pad ( icon , padding ), { foreground , background } } },
49
48
virt_text_pos = ' overlay' ,
50
49
hl_eol = true ,
51
50
})
52
51
elseif capture == ' dash' then
53
52
local dash = state .config .dash
54
53
local width = vim .api .nvim_win_get_width (util .buf_to_win (buf ))
55
54
56
- local dash_text = { dash .icon :rep (width ), dash .highlight }
57
55
vim .api .nvim_buf_set_extmark (buf , namespace , start_row , 0 , {
58
- virt_text = { dash_text },
56
+ virt_text = { { dash . icon : rep ( width ), dash . highlight } },
59
57
virt_text_pos = ' overlay' ,
60
58
})
61
59
elseif capture == ' code' then
62
60
local code = state .config .code
63
61
if not vim .tbl_contains ({ ' normal' , ' full' }, code .style ) then
64
62
return
65
63
end
66
-
67
64
vim .api .nvim_buf_set_extmark (buf , namespace , start_row , 0 , {
68
65
end_row = end_row ,
69
66
end_col = 0 ,
@@ -79,15 +76,12 @@ M.render_node = function(namespace, buf, capture, node)
79
76
if not util .has_10 then
80
77
return
81
78
end
82
-
83
79
local icon , icon_highlight = icons .get (value )
84
80
if icon == nil or icon_highlight == nil then
85
81
return
86
82
end
87
-
88
- local icon_text = { icon .. ' ' .. value , { icon_highlight , code .highlight } }
89
83
vim .api .nvim_buf_set_extmark (buf , namespace , start_row , start_col , {
90
- virt_text = { icon_text },
84
+ virt_text = { { icon .. ' ' .. value , { icon_highlight , code . highlight } } },
91
85
virt_text_pos = ' inline' ,
92
86
})
93
87
elseif capture == ' list_marker' then
@@ -107,11 +101,10 @@ M.render_node = function(namespace, buf, capture, node)
107
101
local level = ts .level_in_section (node , ' list' )
108
102
local icon = list .cycle (bullet .icons , level )
109
103
110
- local list_marker_text = { str .pad (icon , leading_spaces ), bullet .highlight }
111
104
vim .api .nvim_buf_set_extmark (buf , namespace , start_row , start_col , {
112
105
end_row = end_row ,
113
106
end_col = end_col ,
114
- virt_text = { list_marker_text },
107
+ virt_text = { { str . pad ( icon , leading_spaces ), bullet . highlight } },
115
108
virt_text_pos = ' overlay' ,
116
109
})
117
110
end
@@ -130,32 +123,29 @@ M.render_node = function(namespace, buf, capture, node)
130
123
highlight = callout .highlight
131
124
end
132
125
end
133
-
134
- local quote_marker_text = { value :gsub (' >' , quote .icon ), highlight }
135
126
vim .api .nvim_buf_set_extmark (buf , namespace , start_row , start_col , {
136
127
end_row = end_row ,
137
128
end_col = end_col ,
138
- virt_text = { quote_marker_text },
129
+ virt_text = { { value : gsub ( ' > ' , quote . icon ), highlight } },
139
130
virt_text_pos = ' overlay' ,
140
131
})
141
132
elseif vim .tbl_contains ({ ' checkbox_unchecked' , ' checkbox_checked' }, capture ) then
142
133
local checkbox = state .config .checkbox .unchecked
143
134
if capture == ' checkbox_checked' then
144
135
checkbox = state .config .checkbox .checked
145
136
end
146
-
147
- local checkbox_text = { str .pad_to (value , checkbox .icon ), checkbox .highlight }
148
137
vim .api .nvim_buf_set_extmark (buf , namespace , start_row , start_col , {
149
138
end_row = end_row ,
150
139
end_col = end_col ,
151
- virt_text = { checkbox_text },
140
+ virt_text = { { str . pad_to ( value , checkbox . icon ), checkbox . highlight } },
152
141
virt_text_pos = ' overlay' ,
153
142
})
154
143
elseif capture == ' table' then
155
144
local pipe_table = state .config .pipe_table
156
145
if pipe_table .style ~= ' full' then
157
146
return
158
147
end
148
+ local boarder = pipe_table .boarder
159
149
160
150
--- @param row integer
161
151
--- @param s string
@@ -183,26 +173,27 @@ M.render_node = function(namespace, buf, capture, node)
183
173
if delim_width == start_width and start_width == end_width then
184
174
local headings = vim .split (delim_value , ' |' , { plain = true , trimempty = true })
185
175
local lengths = vim .tbl_map (function (part )
186
- return string. rep (' ─ ' , vim .fn .strdisplaywidth (part ))
176
+ return boarder [ 11 ]: rep (vim .fn .strdisplaywidth (part ))
187
177
end , headings )
188
178
189
- local line_above = { { ' ┌ ' .. table.concat (lengths , ' ┬ ' ) .. ' ┐ ' , pipe_table . head } }
179
+ local line_above = boarder [ 1 ] .. table.concat (lengths , boarder [ 2 ] ) .. boarder [ 3 ]
190
180
vim .api .nvim_buf_set_extmark (buf , namespace , start_row , start_col , {
191
181
virt_lines_above = true ,
192
- virt_lines = { line_above },
182
+ virt_lines = { { { line_above , pipe_table . head } } },
193
183
})
194
184
195
- local line_below = { { ' └ ' .. table.concat (lengths , ' ┴ ' ) .. ' ┘ ' , pipe_table . row } }
185
+ local line_below = boarder [ 7 ] .. table.concat (lengths , boarder [ 8 ] ) .. boarder [ 9 ]
196
186
vim .api .nvim_buf_set_extmark (buf , namespace , end_row , start_col , {
197
187
virt_lines_above = true ,
198
- virt_lines = { line_below },
188
+ virt_lines = { { { line_below , pipe_table . row } } },
199
189
})
200
190
end
201
191
elseif vim .tbl_contains ({ ' table_head' , ' table_delim' , ' table_row' }, capture ) then
202
192
local pipe_table = state .config .pipe_table
203
193
if pipe_table .style == ' none' then
204
194
return
205
195
end
196
+ local boarder = pipe_table .boarder
206
197
207
198
local highlight = pipe_table .head
208
199
if capture == ' table_row' then
@@ -212,37 +203,32 @@ M.render_node = function(namespace, buf, capture, node)
212
203
if capture == ' table_delim' then
213
204
-- Order matters here, in particular handling inner intersections before left & right
214
205
local row = value
215
- :gsub (' |' , ' │' )
216
- :gsub (' -' , ' ─' )
217
- :gsub (' ' , ' ─' )
218
- :gsub (' ─│─' , ' ─┼─' )
219
- :gsub (' │─' , ' ├─' )
220
- :gsub (' ─│' , ' ─┤' )
206
+ :gsub (' ' , ' -' )
207
+ :gsub (' %-|%-' , boarder [11 ] .. boarder [5 ] .. boarder [11 ])
208
+ :gsub (' |%-' , boarder [4 ] .. boarder [11 ])
209
+ :gsub (' %-|' , boarder [11 ] .. boarder [6 ])
210
+ :gsub (' %-' , boarder [11 ])
221
211
222
- local table_delim_text = { row , highlight }
223
212
vim .api .nvim_buf_set_extmark (buf , namespace , start_row , start_col , {
224
213
end_row = end_row ,
225
214
end_col = end_col ,
226
- virt_text = { table_delim_text },
215
+ virt_text = { { row , highlight } },
227
216
virt_text_pos = ' overlay' ,
228
217
})
229
218
elseif pipe_table .cell == ' overlay' then
230
- local table_row_text = { value :gsub (' |' , ' │' ), highlight }
231
219
vim .api .nvim_buf_set_extmark (buf , namespace , start_row , start_col , {
232
220
end_row = end_row ,
233
221
end_col = end_col ,
234
- virt_text = { table_row_text },
222
+ virt_text = { { value : gsub ( ' | ' , boarder [ 10 ]), highlight } },
235
223
virt_text_pos = ' overlay' ,
236
224
})
237
225
elseif pipe_table .cell == ' raw' then
238
226
for i = 1 , # value do
239
- local ch = value :sub (i , i )
240
- if ch == ' |' then
241
- local table_pipe_text = { ' │' , highlight }
227
+ if value :sub (i , i ) == ' |' then
242
228
vim .api .nvim_buf_set_extmark (buf , namespace , start_row , i - 1 , {
243
229
end_row = end_row ,
244
230
end_col = i - 1 ,
245
- virt_text = { table_pipe_text },
231
+ virt_text = { { boarder [ 10 ], highlight } },
246
232
virt_text_pos = ' overlay' ,
247
233
})
248
234
end
0 commit comments