Skip to content

Commit e33c7ce

Browse files
authored
Merge pull request #741 from nickspoons/unset_nvim_options
neovim: Unset window-local window options on popup close
2 parents 9439b36 + fde21ef commit e33c7ce

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

autoload/OmniSharp/popup.vim

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ endfunction
8080
function s:CloseLast(redraw) abort
8181
if exists('s:lastwinid')
8282
if has('nvim')
83+
try
84+
let options = s:nvim_window_options[s:lastwinid]
85+
for opt in keys(options)
86+
call nvim_win_set_option(s:lastwinid, opt, s:nvim_window_options[s:lastwinid][opt])
87+
endfor
88+
catch | endtry
8389
call nvim_win_close(s:lastwinid, v:true)
8490
if exists('#OmniSharp_nvim_popup')
8591
autocmd! OmniSharp_nvim_popup
@@ -155,20 +161,20 @@ function s:NvimGetOptions() abort
155161
endfunction
156162

157163
function! s:NvimOpen(what, opts) abort
164+
let config = {
165+
\ 'focusable': v:false
166+
\}
158167
if type(a:what) == v:t_number
159168
let bufnr = a:what
160169
let lines = getbufline(bufnr, 1, '$')
161170
else
162171
let bufnr = nvim_create_buf(v:false, v:true)
163172
call setbufline(bufnr, 1, a:what)
164173
let lines = a:what
174+
let config.style = 'minimal'
165175
endif
166176
let content_height = len(lines)
167177
let position = get(g:, 'OmniSharp_popup_position', 'atcursor')
168-
let config = {
169-
\ 'focusable': v:false,
170-
\ 'style': 'minimal'
171-
\}
172178
" Positions 'peek' and 'full' only apply to file buffers, not documentation
173179
" buffers
174180
if type(a:what) == v:t_number && position ==? 'peek'
@@ -198,8 +204,13 @@ function! s:NvimOpen(what, opts) abort
198204
let s:parentwinid = win_getid(winnr())
199205
let winid = nvim_open_win(bufnr, v:false, config)
200206
let options = s:NvimGetOptions()
207+
let s:nvim_window_options = get(s:, 'nvim_window_options', {})
208+
let s:nvim_window_options[winid] = {}
201209
for opt in keys(options)
202-
call nvim_win_set_option(winid, opt, options[opt])
210+
if nvim_win_get_option(winid, opt) != options[opt]
211+
let s:nvim_window_options[winid][opt] = nvim_win_get_option(winid, opt)
212+
call nvim_win_set_option(winid, opt, options[opt])
213+
endif
203214
endfor
204215
call nvim_set_current_win(winid)
205216
if exists('calculatingHeight')

0 commit comments

Comments
 (0)