@@ -48,12 +48,6 @@ local function render_match_line(item, ctx)
4848 local location = string.format (' :%d:%d' , item .line_number or 0 , (item .col or 0 ) + 1 )
4949 local separator = ' '
5050
51- -- Add definition indicator if this is a definition
52- local def_indicator = ' '
53- if item .is_definition then
54- def_indicator = ' [def]'
55- end
56-
5751 -- vim.json.decode may return Blobs for strings with NUL bytes; coerce to string.
5852 local raw_content = item .line_content
5953 if type (raw_content ) ~= ' string' then raw_content = raw_content and tostring (raw_content ) or ' ' end
@@ -81,13 +75,12 @@ local function render_match_line(item, ctx)
8175 content = vim .fn .strcharpart (content , 0 , lo ) .. ' …'
8276 end
8377
84- local line = indent .. location .. separator .. content .. def_indicator
78+ local line = indent .. location .. separator .. content
8579 local padding = math.max (0 , ctx .win_width - vim .fn .strdisplaywidth (line ) + 5 )
8680
8781 item ._match_indent = # indent
8882 item ._content_offset = prefix_display_w -- byte offset where content starts in the line
8983 item ._trimmed_content = content -- trimmed content string for treesitter parsing
90- item ._def_indicator = def_indicator
9184
9285 return line .. string.rep (' ' , padding )
9386end
@@ -202,18 +195,13 @@ local function apply_match_highlights(item, ctx, item_idx, buf, ns_id, row, line
202195 end
203196 end
204197
205- -- 7. Definition indicator highlight
206- if item .is_definition and item ._def_indicator and # item ._def_indicator > 0 then
207- local def_start = # line_content - # item ._def_indicator - (math.max (0 , ctx .win_width - vim .fn .strdisplaywidth (line_content ) + 5 ))
208- -- Actually, it's easier to find it in the string
209- local s , e = line_content :find (' %[def%]$' )
210- if s then
211- pcall (vim .api .nvim_buf_set_extmark , buf , ns_id , row , s - 1 , {
212- end_col = e ,
213- hl_group = config .hl .combo_header or ' Number' ,
214- priority = 250 ,
215- })
216- end
198+ -- 7. Definition indicator as virtual text
199+ if item .is_definition then
200+ pcall (vim .api .nvim_buf_set_extmark , buf , ns_id , row , 0 , {
201+ virt_text = { { ' [def]' , config .hl .combo_header or ' Number' } },
202+ virt_text_pos = ' eol' ,
203+ priority = 250 ,
204+ })
217205 end
218206end
219207
0 commit comments