@@ -17,6 +17,7 @@ function! lsp#ui#vim#output#closepreview() abort
17
17
endif
18
18
let s: winid = v: false
19
19
autocmd ! lsp_float_preview_close CursorMoved ,CursorMovedI ,VimResized *
20
+ doautocmd User lsp_float_closed
20
21
endfunction
21
22
22
23
function ! lsp#ui#vim#output#focuspreview () abort
@@ -149,18 +150,27 @@ function! s:add_float_closing_hooks() abort
149
150
endif
150
151
endfunction
151
152
153
+ function ! lsp#ui#vim#output#getpreviewwinid () abort
154
+ return s: winid
155
+ endfunction
156
+
157
+ function ! s: open_preview (data) abort
158
+ if s: supports_floating && g: lsp_preview_float
159
+ let l: winid = lsp#ui#vim#output#floatingpreview (a: data )
160
+ else
161
+ execute &previewheight .' new'
162
+ let l: winid = win_getid ()
163
+ endif
164
+ return l: winid
165
+ endfunction
166
+
152
167
function ! lsp#ui#vim#output#preview (data) abort
153
168
" Close any previously opened preview window
154
169
pclose
155
170
156
171
let l: current_window_id = win_getid ()
157
172
158
- if s: supports_floating && g: lsp_preview_float
159
- let s: winid = lsp#ui#vim#output#floatingpreview (a: data )
160
- else
161
- execute &previewheight .' new'
162
- let s: winid = win_getid ()
163
- endif
173
+ let s: winid = s: open_preview (a: data )
164
174
165
175
let l: lines = []
166
176
let l: ft = s: append (a: data , l: lines )
@@ -177,9 +187,12 @@ function! lsp#ui#vim#output#preview(data) abort
177
187
178
188
echo ' '
179
189
180
- if s: supports_floating && s: winid && g: lsp_preview_float && has (' nvim' )
181
- call s: adjust_float_placement (l: bufferlines , l: maxwidth )
182
- call s: add_float_closing_hooks ()
190
+ if s: supports_floating && s: winid && g: lsp_preview_float
191
+ if has (' nvim' )
192
+ call s: adjust_float_placement (l: bufferlines , l: maxwidth )
193
+ call s: add_float_closing_hooks ()
194
+ endif
195
+ doautocmd User lsp_float_opened
183
196
endif
184
197
return ' '
185
198
endfunction
0 commit comments