neovim-gtk/runtime/plugin/nvim_gui_shim.vim

60 lines
1.5 KiB
VimL
Raw Normal View History

" A Neovim plugin that implements GUI helper commands
if !has('nvim') || exists('g:GuiLoaded')
2018-01-02 19:38:35 +00:00
finish
endif
let g:GuiLoaded = 1
if exists('g:GuiInternalClipboard')
let s:LastRegType = 'v'
2017-12-31 23:23:37 +00:00
function! provider#clipboard#Call(method, args) abort
if a:method == 'get'
return [rpcrequest(1, 'Gui', 'Clipboard', 'Get', a:args[0]), s:LastRegType]
2017-12-31 23:23:37 +00:00
elseif a:method == 'set'
let s:LastRegType = a:args[1]
2018-01-02 19:38:35 +00:00
call rpcnotify(1, 'Gui', 'Clipboard', 'Set', a:args[2], join(a:args[0], ' '))
2017-12-31 23:23:37 +00:00
endif
endfunction
endif
" Set GUI font
function! GuiFont(fname, ...) abort
call rpcnotify(1, 'Gui', 'Font', s:NvimQtToPangoFont(a:fname))
endfunction
" Some subset of parse command from neovim-qt
" to support interoperability
function s:NvimQtToPangoFont(fname)
let l:attrs = split(a:fname, ':')
let l:size = -1
for part in l:attrs
if len(part) >= 2 && part[0] == 'h'
let l:size = strpart(part, 1)
endif
endfor
if l:size > 0
return l:attrs[0] . ' ' . l:size
endif
return l:attrs[0]
endf
" The GuiFont command. For compatibility there is also Guifont
function s:GuiFontCommand(fname, bang) abort
if a:fname ==# ''
if exists('g:GuiFont')
echo g:GuiFont
else
echo 'No GuiFont is set'
endif
else
call GuiFont(a:fname, a:bang ==# '!')
endif
endfunction
command! -nargs=? -bang Guifont call s:GuiFontCommand("<args>", "<bang>")
command! -nargs=? -bang GuiFont call s:GuiFontCommand("<args>", "<bang>")
2018-03-30 20:54:37 +00:00
command! NGToggleSidebar call rpcnotify(1, 'Gui', 'Command', 'ToggleSidebar')