lib.kom : Scripting highly advanced-functions
script karma |
Rating 0/0,
Downloaded by 1148 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Rom Grk |
|
script type |
utility |
|
description |
Much better display on the hub: https://github.com/romgrk/lib.kom
Scripting autoload functions for syntax highlighting and buffer/window management. Also comes with _.vim, which is the start of a kind-of adaptation of lodash/underscore to vimL, that I will hopefully never have to complete.
Example: get objects & use them
let cur_win = win#() " => a Window object (the current by default) (such a loss of time in this nonsense)
let alt_win = win#("#") " => the window where is displayed the alternate buffer
call alt_win.cmd('bnext') " safely executes “bnext” in alt_win context
call cur_win.open( buf#(9) ) " opens buffer 9 in current window
Example: exchange buffers between current window and second window
let other = win#(2).buf()
call win#(2).open(buf#())
call win#().open(other)
" Print all &buflisted buffers, where filetype is "vim" and
" that have a bufnr higher than 10.
echo buf#filter('&buflisted', '&ft=="vim"', 'v:val > 10')
echo win#filter('&buflisted') " => List<Number> of windows containing listed buffers
call win#(2).open(4)
" buffer #4 is opened in window #2
echo color#darken('#599eff', '0.2')
" => #477ecc
echo color#HexToRGB('#599eff')
" => [89, 158, 255]
(if you find this useful, let me know, I might write more documentation)
hi.vim - highlighting
hi#fg and hi#bg ('GoupName' [, color:String]) are both getter and setters hi#( name [, group:[] | fg [,bg [,attr ] ] ] ) can get/set or define your group without error
a group-hl definition may be: (name && ( 1, 2 or 4 arguments)) || (Array of (2, 3 or 4 arguments))
where arguments are assumed to be (in order): gui-foreground-color, gui-background-color, attributes (no cterm handling)
Useful trick example:
<C-r>=hi#fg('Function')<CR>
gives you the foreground color for group Function
fu! hi# (...)
fu! hi#fg (name, ...)
fu! hi#bg (name, ...)
" the rest: check the source for more details
fu! hi#id (name)
fu! hi#attr (name, ...)
fu! hi#name (id)
fu! hi#create (name, ...)
fu! hi#set (name, ...)
fu! hi#exists (r)
fu! hi#islink (name)
fu! hi#isdefined (name)
fu! hi#get (ref)
fu! hi#group (...)
fu! hi#clear (name)
fu! hi#fill (group, ...)
fu! hi#compose (rule, ...)
undocumented:
_.vim
color.vim
buf.vim
win.vim
|
|
install details |
As usual (and I'm not talking about download: install from the repo with some manager: https://github.com/romgrk/lib.kom)
(I always wonder why we still use this atrocity called vim.org)
|
|
script versions (upload new version)
Click on the package to download.
ip used for rating: 142.132.191.50
|