1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 09:20:04 +08:00

Update floating support (#2789)

close #2688
This commit is contained in:
Wang Shidong 2019-05-06 12:50:10 +08:00 committed by GitHub
parent b581ac4c77
commit e6e6b6d76c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 63 additions and 3 deletions

View File

@ -0,0 +1,58 @@
"=============================================================================
" floating.vim --- neovim#floating api
" Copyright (c) 2016-2017 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg at 163.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
let s:self = {}
" in old version nvim_open_win api is:
" call nvim_open_win(s:bufnr, v:true, &columns, 12,
" \ {
" \ 'relative': 'editor',
" \ 'row': &lines - 14,
" \ 'col': 0
" \ })
" if exists('*nvim_open_win')
" call nvim_win_set_config(win_getid(s:gwin),
" \ {
" \ 'relative': 'editor',
" \ 'width' : &columns,
" \ 'height' : layout.win_dim + 2,
" \ 'row' : &lines - layout.win_dim - 4,
" \ 'col' : 0
" \ })
function! s:self.open_win(buf, focuce, opt) abort
try
call nvim_open_win(a:buf, a:focuce, a:opt)
catch /^Vim\%((\a\+)\)\=:E119/
call nvim_open_win(a:buf, a:focuce, get(a:opt, 'width', 5), get(a:opt, 'height', 5),
\ {
\ 'relative' : get(a:opt, 'relative', 'editor'),
\ 'row' : get(a:opt, 'row', 5),
\ 'col' : get(a:opt, 'col', 5),
\ })
endtry
endfunction
function! s:self.win_config(winid, opt) abort
try
call nvim_win_config(a:winid, a:opt)
catch /^Vim\%((\a\+)\)\=:E119/
call nvim_win_config(a:winid, get(a:opt, 'width', 5), get(a:opt, 'height', 5),
\ {
\ 'relative' : get(a:opt, 'relative', 'editor'),
\ 'row' : get(a:opt, 'row', 5),
\ 'col' : get(a:opt, 'col', 5),
\ })
endtry
endfunction
function! SpaceVim#api#neovim#floating#get() abort
return deepcopy(s:self)
endfunction

View File

@ -15,6 +15,7 @@ scriptencoding utf-8
let s:CMP = SpaceVim#api#import('vim#compatible')
let s:STR = SpaceVim#api#import('data#string')
let s:KEY = SpaceVim#api#import('vim#key')
let s:FLOATING = SpaceVim#api#import('neovim#floating')
function! SpaceVim#mapping#guide#has_configuration() abort "{{{
return exists('s:desc_lookup')
@ -393,7 +394,7 @@ function! s:start_buffer() abort " {{{
setlocal modifiable
if exists('*nvim_open_win')
call nvim_win_set_config(win_getid(s:gwin),
call s:FLOATING.win_config(win_getid(s:gwin),
\ {
\ 'relative': 'editor',
\ 'width' : &columns,
@ -509,7 +510,7 @@ function! s:winopen() abort " {{{
if !bufexists(s:bufnr)
let s:bufnr = nvim_create_buf(v:false,v:false)
endif
call nvim_open_win(s:bufnr, v:true,
call s:FLOATING.open_win(s:bufnr, v:true,
\ {
\ 'relative': 'editor',
\ 'width' : &columns,

View File

@ -14,6 +14,7 @@ let s:SYS = SpaceVim#api#import('system')
let s:BUFFER = SpaceVim#api#import('vim#buffer')
let s:LIST = SpaceVim#api#import('data#list')
let s:HI = SpaceVim#api#import('vim#highlight')
let s:FLOATING = SpaceVim#api#import('neovim#floating')
" }}}
let s:grepid = 0
@ -599,7 +600,7 @@ function! SpaceVim#plugins#flygrep#open(agrv) abort
if exists('*nvim_open_win')
let s:buffer_id = nvim_create_buf(v:false, v:false)
let flygrep_win_height = 16
let s:flygrep_win_id = nvim_open_win(s:buffer_id, v:true,
let s:flygrep_win_id = s:FLOATING.open_win(s:buffer_id, v:true,
\ {
\ 'relative': 'editor',
\ 'width' : &columns,