@@ -49,19 +49,22 @@ function docs.show_item(item)
49
49
-- todo: only resolve if documentation does not exist
50
50
sources .resolve (item , function (resolved_item )
51
51
item = resolved_item or item
52
- if item .documentation == nil then
52
+ if item .documentation == nil and item . detail == nil then
53
53
docs .win :close ()
54
54
return
55
55
end
56
56
57
57
local detail_lines = {}
58
58
if item .detail and item .detail ~= ' ' then detail_lines = utils .split_lines (item .detail ) end
59
59
60
- local doc = type (item .documentation ) == ' string' and item .documentation or item .documentation .value
61
- local doc_lines = utils .split_lines (doc )
62
- if type (item .documentation ) ~= ' string' and item .documentation .kind == ' markdown' then
63
- -- if the rendering seems bugged, it's likely due to this function
64
- doc_lines = utils .combine_markdown_lines (doc_lines )
60
+ local doc_lines = {}
61
+ if item .documentation ~= nil then
62
+ local doc = type (item .documentation ) == ' string' and item .documentation or item .documentation .value
63
+ doc_lines = utils .split_lines (doc )
64
+ if type (item .documentation ) ~= ' string' and item .documentation .kind == ' markdown' then
65
+ -- if the rendering seems bugged, it's likely due to this function
66
+ doc_lines = utils .combine_markdown_lines (doc_lines )
67
+ end
65
68
end
66
69
67
70
local combined_lines = vim .list_extend ({}, detail_lines )
@@ -75,13 +78,18 @@ function docs.show_item(item)
75
78
vim .api .nvim_buf_clear_namespace (docs .win :get_buf (), require (' blink.cmp.config' ).highlight .ns , 0 , - 1 )
76
79
if # detail_lines > 0 then
77
80
utils .highlight_with_treesitter (docs .win :get_buf (), vim .bo .filetype , 0 , # detail_lines )
78
- vim .api .nvim_buf_set_extmark (docs .win :get_buf (), require (' blink.cmp.config' ).highlight .ns , # detail_lines , 0 , {
79
- virt_text = { { string.rep (' ─' , docs .win .config .max_width ) } },
80
- virt_text_pos = ' overlay' ,
81
- hl_eol = true ,
82
- hl_group = ' BlinkCmpDocDetail' ,
83
- })
81
+
82
+ -- Only add the separator if there are documentation lines (otherwise only display the detail)
83
+ if # doc_lines > 0 then
84
+ vim .api .nvim_buf_set_extmark (docs .win :get_buf (), require (' blink.cmp.config' ).highlight .ns , # detail_lines , 0 , {
85
+ virt_text = { { string.rep (' ─' , docs .win .config .max_width ) } },
86
+ virt_text_pos = ' overlay' ,
87
+ hl_eol = true ,
88
+ hl_group = ' BlinkCmpDocDetail' ,
89
+ })
90
+ end
84
91
end
92
+
85
93
utils .highlight_with_treesitter (docs .win :get_buf (), ' markdown' , # detail_lines + 1 , # detail_lines + 1 + # doc_lines )
86
94
87
95
if autocomplete .win :get_win () then
0 commit comments