Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
166 lines
5.1 KiB
VimL
166 lines
5.1 KiB
VimL
"=============================================================================
|
|
" floating.vim --- vim floating api
|
|
" Copyright (c) 2016-2023 Wang Shidong & Contributors
|
|
" Author: Wang Shidong < wsdjeg@outlook.com >
|
|
" URL: https://spacevim.org
|
|
" License: GPLv3
|
|
"=============================================================================
|
|
scriptencoding utf-8
|
|
|
|
let s:self = {}
|
|
|
|
" this api is based on neovim#floating api
|
|
" options:
|
|
" 1. col
|
|
" 2. row
|
|
" 3. width
|
|
" 3. height
|
|
" 4. relative
|
|
|
|
" {config} Map defining the window configuration. Keys:
|
|
" • `relative`: Sets the window layout to "floating", placed
|
|
" at (row,col) coordinates relative to:
|
|
" • "editor" The global editor grid
|
|
" • "win" Window given by the `win` field, or
|
|
" current window.
|
|
" • "cursor" Cursor position in current window.
|
|
"
|
|
" • `win` : |window-ID| for relative="win".
|
|
" • `anchor`: Decides which corner of the float to place
|
|
" at (row,col):
|
|
" • "NW" northwest (default)
|
|
" • "NE" northeast
|
|
" • "SW" southwest
|
|
" • "SE" southeast
|
|
"
|
|
" • `width` : Window width (in character cells).
|
|
" Minimum of 1.
|
|
" • `height` : Window height (in character cells).
|
|
" Minimum of 1.
|
|
" • `bufpos` : Places float relative to buffer
|
|
" text (only when relative="win"). Takes a tuple
|
|
" of zero-indexed [line, column]. `row` and
|
|
" `col` if given are applied relative to this
|
|
" position, else they default to `row=1` and
|
|
" `col=0` (thus like a tooltip near the buffer
|
|
" text).
|
|
" • `row` : Row position in units of "screen cell
|
|
" height", may be fractional.
|
|
" • `col` : Column position in units of "screen
|
|
" cell width", may be fractional.
|
|
" • `focusable` : Enable focus by user actions
|
|
" (wincmds, mouse events). Defaults to true.
|
|
" Non-focusable windows can be entered by
|
|
" |nvim_set_current_win()|.
|
|
" • `external` : GUI should display the window as
|
|
" an external top-level window. Currently
|
|
" accepts no other positioning configuration
|
|
" together with this.
|
|
" • `style`: Configure the appearance of the window.
|
|
" Currently only takes one non-empty value:
|
|
" • "minimal" Nvim will display the window with
|
|
" many UI options disabled. This is useful
|
|
" when displaying a temporary float where the
|
|
" text should not be edited. Disables
|
|
" 'number', 'relativenumber', 'cursorline',
|
|
" 'cursorcolumn', 'foldcolumn', 'spell' and
|
|
" 'list' options. 'signcolumn' is changed to
|
|
" `auto` and 'colorcolumn' is cleared. The
|
|
" end-of-buffer region is hidden by setting
|
|
" `eob` flag of 'fillchars' to a space char,
|
|
" and clearing the |EndOfBuffer| region in
|
|
" 'winhighlight'.
|
|
"
|
|
" Return: ~
|
|
" Window handle, or 0 on error
|
|
function! s:self.open_win(buffer, focuce, options) abort
|
|
let col = get(a:options, 'col', 1)
|
|
let row = get(a:options, 'row', 1)
|
|
let width = get(a:options, 'width', 1)
|
|
let height = get(a:options, 'height', 1)
|
|
let highlight = get(a:options, 'highlight', 'Normal')
|
|
let relative = get(a:options, 'relative', 'editor')
|
|
if relative ==# 'win'
|
|
let winid = get(a:options, 'win', 0)
|
|
let pos = win_screenpos(win_id2win(winid))
|
|
let opt = {
|
|
\ 'line' : row + 1 + pos[0],
|
|
\ 'col' : col + pos[1],
|
|
\ 'maxheight' : height,
|
|
\ 'minheight' : height,
|
|
\ 'maxwidth' : width,
|
|
\ 'minwidth' : width,
|
|
\ 'highlight' : highlight,
|
|
\ 'scrollbar' : 0,
|
|
\ }
|
|
elseif relative ==# 'cursor'
|
|
elseif relative ==# 'editor'
|
|
let opt = {
|
|
\ 'line' : row + 1,
|
|
\ 'col' : col,
|
|
\ 'maxheight' : height,
|
|
\ 'minheight' : height,
|
|
\ 'maxwidth' : width,
|
|
\ 'minwidth' : width,
|
|
\ 'highlight' : highlight,
|
|
\ 'scrollbar' : 0,
|
|
\ }
|
|
endif
|
|
return popup_create(a:buffer, opt)
|
|
endfunction
|
|
|
|
function! s:self.win_config(winid, options) abort
|
|
let col = get(a:options, 'col', 1)
|
|
let row = get(a:options, 'row', 1)
|
|
let width = get(a:options, 'width', 1)
|
|
let height = get(a:options, 'height', 1)
|
|
let highlight = get(a:options, 'highlight', '')
|
|
let relative = get(a:options, 'relative', 'editor')
|
|
if relative ==# 'win'
|
|
let winid = get(a:options, 'win', 0)
|
|
let pos = win_screenpos(win_id2win(winid))
|
|
let opt = {
|
|
\ 'line' : row + 1 + pos[0],
|
|
\ 'col' : col + pos[1],
|
|
\ 'maxheight' : height,
|
|
\ 'minheight' : height,
|
|
\ 'maxwidth' : width,
|
|
\ 'minwidth' : width,
|
|
\ 'highlight' : highlight,
|
|
\ 'scrollbar' : 0,
|
|
\ }
|
|
elseif relative ==# 'cursor'
|
|
elseif relative ==# 'editor'
|
|
let opt = {
|
|
\ 'line' : row + 1,
|
|
\ 'col' : col,
|
|
\ 'maxheight' : height,
|
|
\ 'minheight' : height,
|
|
\ 'maxwidth' : width,
|
|
\ 'minwidth' : width,
|
|
\ 'highlight' : highlight,
|
|
\ 'scrollbar' : 0,
|
|
\ }
|
|
endif
|
|
return popup_setoptions(a:winid, opt)
|
|
endfunction
|
|
|
|
function! s:self.exists() abort
|
|
return exists('*popup_create')
|
|
endfunction
|
|
|
|
function! s:self.get_width(winid) abort
|
|
return winwidth(a:winid)
|
|
endfunction
|
|
|
|
function! s:self.win_close(id, focuce) abort
|
|
return popup_close(a:id)
|
|
endfunction
|
|
|
|
function! SpaceVim#api#vim#floating#get() abort
|
|
return deepcopy(s:self)
|
|
endfunction
|
|
|
|
|
|
|