@@ -25,7 +25,7 @@ interface InlayHint {
25
25
label: string,
26
26
}
27
27
```
28
- --]]
28
+ --]]
29
29
30
30
local util = require (' lsp_extensions.util' )
31
31
@@ -83,8 +83,12 @@ inlay_hints.get_callback = function(opts)
83
83
84
84
for _ , hint in ipairs (result ) do
85
85
local finish = hint .range [" end" ].line
86
- if not hint_store [finish ] and in_list (enabled )(hint .kind ) then
87
- hint_store [finish ] = hint
86
+ if in_list (enabled )(hint .kind ) then
87
+ if not hint_store [finish ] then
88
+ hint_store [finish ] = {hint }
89
+ elseif hint_store [finish ][1 ].kind == hint .kind then
90
+ table.insert (hint_store [finish ], hint )
91
+ end
88
92
89
93
if aligned then
90
94
longest_line = math.max (longest_line ,
@@ -93,8 +97,8 @@ inlay_hints.get_callback = function(opts)
93
97
end
94
98
end
95
99
96
- local display_virt_text = function (hint )
97
- local end_line = hint .range [" end" ].line
100
+ local display_virt_text = function (hints )
101
+ local end_line = hints [ 1 ] .range [" end" ].line
98
102
99
103
-- Check for any existing / more important virtual text on the line.
100
104
-- TODO: Figure out how stackable virtual text works? What happens if there is more than one??
@@ -103,25 +107,27 @@ inlay_hints.get_callback = function(opts)
103
107
if not vim .tbl_isempty (existing_virt_text ) then return end
104
108
105
109
local text
106
- if aligned then
107
- local line_length = # vim .api .nvim_buf_get_lines (ctx .bufnr , end_line , end_line + 1 , false )[1 ]
108
- text = string.format (" %s %s" , (" " ):rep (longest_line - line_length ), prefix .. hint .label )
109
- else
110
- text = prefix .. hint .label
110
+ for _ , hint in ipairs (hints ) do
111
+ if aligned then
112
+ local line_length = # vim .api .nvim_buf_get_lines (bufnr , end_line , end_line + 1 , false )[1 ]
113
+ text = string.format (" %s %s" , (" " ):rep (longest_line - line_length ), prefix .. hint .label )
114
+ else
115
+ text = (text or " " ) .. prefix .. hint .label
116
+ end
111
117
end
112
118
vim .api .nvim_buf_set_virtual_text (ctx .bufnr , inlay_hints_ns , end_line , {{text , highlight }}, {})
113
119
end
114
120
115
121
if only_current_line then
116
- local hint = hint_store [vim .api .nvim_win_get_cursor (0 )[1 ] - 1 ]
122
+ local hints = hint_store [vim .api .nvim_win_get_cursor (0 )[1 ] - 1 ]
117
123
118
- if not hint then
124
+ if not hints then
119
125
return
120
126
else
121
- display_virt_text (hint )
127
+ display_virt_text (hints )
122
128
end
123
129
else
124
- for _ , hint in pairs (hint_store ) do display_virt_text (hint ) end
130
+ for _ , hints in pairs (hint_store ) do display_virt_text (hints ) end
125
131
end
126
132
end )
127
133
end
0 commit comments