1
1
let s: supports_floating = exists (' *nvim_open_win' ) || has (' patch-8.1.1517' )
2
- let s: win = v: false
2
+ let s: winid = v: false
3
3
let s: prevwin = v: false
4
4
5
5
function ! lsp#ui#vim#output#closepreview () abort
6
- if win_getid () == s: win
6
+ if win_getid () == s: winid
7
7
" Don't close if window got focus
8
8
return
9
9
endif
10
10
" closing floats in vim8.1 must use popup_close() (nvim could use nvim_win_close but pclose
11
11
" works)
12
- if s: supports_floating && s: win && g: lsp_preview_float && ! has (' nvim' )
12
+ if s: supports_floating && s: winid && g: lsp_preview_float && ! has (' nvim' )
13
13
" TODO:
14
- call popup_close (s: win )
14
+ call popup_close (s: winid )
15
15
else
16
16
pclose
17
17
endif
18
- let s: win = v: false
18
+ let s: winid = v: false
19
19
autocmd ! lsp_float_preview_close CursorMoved ,CursorMovedI ,VimResized *
20
20
endfunction
21
21
22
22
function ! lsp#ui#vim#output#focuspreview () abort
23
23
" This does not work for vim8.1 popup but will work for nvim and old preview
24
- if s: win
25
- if win_getid () != s: win
24
+ if s: winid
25
+ if win_getid () != s: winid
26
26
let s: prevwin = win_getid ()
27
- call win_gotoid (s: win )
27
+ call win_gotoid (s: winid )
28
28
elseif s: prevwin
29
29
" Temporarily disable hooks
30
30
" TODO: remove this when closing logic is able to distinguish different move directions
@@ -98,30 +98,30 @@ function! lsp#ui#vim#output#floatingpreview(data) abort
98
98
99
99
let l: opts = s: get_float_positioning (l: height , l: width )
100
100
101
- let s: win = nvim_open_win (buf , v: true , l: opts )
102
- call nvim_win_set_option (s: win , ' winhl' , ' Normal:Pmenu,NormalNC:Pmenu' )
103
- call nvim_win_set_option (s: win , ' foldenable' , v: false )
104
- call nvim_win_set_option (s: win , ' wrap' , v: true )
105
- call nvim_win_set_option (s: win , ' statusline' , ' ' )
106
- call nvim_win_set_option (s: win , ' number' , v: false )
107
- call nvim_win_set_option (s: win , ' relativenumber' , v: false )
108
- call nvim_win_set_option (s: win , ' cursorline' , v: false )
101
+ let s: winid = nvim_open_win (buf , v: true , l: opts )
102
+ call nvim_win_set_option (s: winid , ' winhl' , ' Normal:Pmenu,NormalNC:Pmenu' )
103
+ call nvim_win_set_option (s: winid , ' foldenable' , v: false )
104
+ call nvim_win_set_option (s: winid , ' wrap' , v: true )
105
+ call nvim_win_set_option (s: winid , ' statusline' , ' ' )
106
+ call nvim_win_set_option (s: winid , ' number' , v: false )
107
+ call nvim_win_set_option (s: winid , ' relativenumber' , v: false )
108
+ call nvim_win_set_option (s: winid , ' cursorline' , v: false )
109
109
" Enable closing the preview with esc, but map only in the scratch buffer
110
110
nmap <buffer> <silent> <esc> :pclose<cr>
111
111
else
112
- let s: win = popup_atcursor (' ...' , {
112
+ let s: winid = popup_atcursor (' ...' , {
113
113
\ ' moved' : ' any' ,
114
114
\ ' border' : [1 , 1 , 1 , 1 ],
115
115
\} )
116
116
endif
117
- return s: win
117
+ return s: winid
118
118
endfunction
119
119
120
120
function ! s: setcontent (lines , ft ) abort
121
121
if s: supports_floating && g: lsp_preview_float && ! has (' nvim' )
122
122
" vim popup
123
- call setbufline (winbufnr (s: win ), 1 , a: lines )
124
- call win_execute (s: win , ' setlocal filetype=' . a: ft . ' .lsp-hover' )
123
+ call setbufline (winbufnr (s: winid ), 1 , a: lines )
124
+ call win_execute (s: winid , ' setlocal filetype=' . a: ft . ' .lsp-hover' )
125
125
else
126
126
" nvim floating
127
127
call setline (1 , a: lines )
@@ -133,10 +133,10 @@ endfunction
133
133
function ! s: adjust_float_placement (bufferlines, maxwidth) abort
134
134
if has (' nvim' )
135
135
let l: win_config = {}
136
- let l: height = min ([winheight (s: win ), a: bufferlines ])
137
- let l: width = min ([winwidth (s: win ), a: maxwidth ])
136
+ let l: height = min ([winheight (s: winid ), a: bufferlines ])
137
+ let l: width = min ([winwidth (s: winid ), a: maxwidth ])
138
138
let l: win_config = s: get_float_positioning (l: height , l: width )
139
- call nvim_win_set_config (s: win , l: win_config )
139
+ call nvim_win_set_config (s: winid , l: win_config )
140
140
endif
141
141
endfunction
142
142
@@ -156,10 +156,10 @@ function! lsp#ui#vim#output#preview(data) abort
156
156
let l: current_window_id = win_getid ()
157
157
158
158
if s: supports_floating && g: lsp_preview_float
159
- let s: win = lsp#ui#vim#output#floatingpreview (a: data )
159
+ let s: winid = lsp#ui#vim#output#floatingpreview (a: data )
160
160
else
161
161
execute &previewheight .' new'
162
- let s: win = win_getid ()
162
+ let s: winid = win_getid ()
163
163
endif
164
164
165
165
let l: lines = []
@@ -177,7 +177,7 @@ function! lsp#ui#vim#output#preview(data) abort
177
177
178
178
echo ' '
179
179
180
- if s: supports_floating && s: win && g: lsp_preview_float && has (' nvim' )
180
+ if s: supports_floating && s: winid && g: lsp_preview_float && has (' nvim' )
181
181
call s: adjust_float_placement (l: bufferlines , l: maxwidth )
182
182
call s: add_float_closing_hooks ()
183
183
endif
0 commit comments