forked from daa84/neovim-gtk
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathnvim_gui_shim.vim
More file actions
73 lines (63 loc) · 2.46 KB
/
Copy pathnvim_gui_shim.vim
File metadata and controls
73 lines (63 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
" A Neovim plugin that implements GUI helper commands
if !has('nvim') || exists('g:GuiLoaded')
finish
endif
let g:GuiLoaded = 1
if exists('g:GuiInternalClipboard')
let g:clipboard = {
\ 'name': 'neovim-gtk',
\ 'copy': {
\ '+': { lines, regtype -> rpcnotify(1, 'Gui', 'Clipboard', 'Set', regtype, join(lines, '')) },
\ '*': { lines, regtype -> rpcnotify(1, 'Gui', 'Clipboard', 'Set', regtype, join(lines, '')) },
\ },
\ 'paste': {
\ '+': { -> rpcrequest(1, 'Gui', 'Clipboard', 'Get', '+') },
\ '*': { -> rpcrequest(1, 'Gui', 'Clipboard', 'Get', '*') },
\ },
\ }
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=1 -bang Guifont call s:GuiFontCommand("<args>", "<bang>")
command! -nargs=1 -bang GuiFont call s:GuiFontCommand("<args>", "<bang>")
command! -nargs=? GuiFontFeatures call rpcnotify(1, 'Gui', 'FontFeatures', <q-args>)
command! -nargs=1 GuiLinespace call rpcnotify(1, 'Gui', 'Linespace', <q-args>)
command! -nargs=1 GuiPopupmenu call rpcnotify(1, 'Gui', 'Option', 'Popupmenu', <args>)
command! -nargs=1 GuiTabline call rpcnotify(1, 'Gui', 'Option', 'Tabline', <args>)
command! -nargs=1 GuiCmdline call rpcnotify(1, 'Gui', 'Option', 'Cmdline', <args>)
command! NGToggleSidebar call rpcnotify(1, 'Gui', 'Command', 'ToggleSidebar')
command! NGShowProjectView call rpcnotify(1, 'Gui', 'Command', 'ShowProjectView')
command! -nargs=+ NGTransparency call rpcnotify(1, 'Gui', 'Command', 'Transparency', <f-args>)
command! -nargs=1 NGPreferDarkTheme call rpcnotify(1, 'Gui', 'Command', 'PreferDarkTheme', <q-args>)
command! -nargs=1 NGSetCursorBlink call rpcnotify(1, 'Gui', 'Command', 'SetCursorBlink', <q-args>)