From 28679e1df1d72490407d0ae645e52b40b457cf71 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 20 Nov 2021 00:04:40 +0900 Subject: neovim: mapping "tg" now supports neovim --- .vimrc | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/.vimrc b/.vimrc index d022118..be1d3a7 100644 --- a/.vimrc +++ b/.vimrc @@ -966,14 +966,34 @@ function! s:choose_window_interactively() abort let winid = wins[i] let indicator = indicators[i] let [winy, winx, winh, winw] = s:win_getrect(winid) - let popup = popup_create(indicator, #{ - \ line: winy + (winh - 5) / 2, - \ col: winx + (winw - 9) / 2, - \ drag: v:false, - \ resize: v:false, - \ padding: [1, 3, 1, 3], - \ border: [], - \ }) + if has('nvim') + let buf_id = nvim_create_buf(v:false, v:true) + call nvim_buf_set_lines(buf_id, 0, -1, v:true, ['', ' ' . indicator . ' ', '']) + let popup = nvim_open_win( + \ buf_id, + \ v:false, + \ { + \ 'relative': 'win', + \ 'win': winid, + \ 'row': (winh - 5) / 2, + \ 'col': (winw - 9) / 2, + \ 'width': 5, + \ 'height': 3, + \ 'focusable': v:false, + \ 'style': 'minimal', + \ 'border': 'double', + \ 'noautocmd': v:true, + \ }) + else + let popup = popup_create(indicator, #{ + \ line: winy + (winh - 5) / 2, + \ col: winx + (winw - 9) / 2, + \ drag: v:false, + \ resize: v:false, + \ padding: [1, 3, 1, 3], + \ border: [], + \ }) + endif call add(popups, #{ \ winid: popup, \ indicator: indicator, @@ -997,7 +1017,11 @@ function! s:choose_window_interactively() abort " Close popups for popup in popups - call popup_close(popup.winid) + if has('nvim') + call nvim_win_close(popup.winid, v:true) + else + call popup_close(popup.winid) + endif endfor endfunction @@ -1059,7 +1083,7 @@ nnoremap tc c nnoremap to o nnoremap tO :tabonly -if has('popupwin') +if has('popupwin') || has('nvim') nnoremap tg :call choose_window_interactively() endif -- cgit v1.2.3-70-g09d2