haya14busa / Underscore.vim
Licence: mit
Vim script utility library π The sky is the limit!
Stars: β 72
Labels
Projects that are alternatives of or similar to Underscore.vim
Tcomment
An extensible & universal comment plugin that also handles embedded filetypes
Stars: β 64 (-11.11%)
Mutual labels: viml
Bringing Vim To The People
An lo, on the fourth day he did step down from the mountain, and with him VIM did follow . . . .
Stars: β 69 (-4.17%)
Mutual labels: viml
Bufkill.vim
Unload/delete/wipe a buffer, keep its window(s), display last accessed buffer(s)
Stars: β 61 (-15.28%)
Mutual labels: viml
Hypergit.vim
This git plugin provides many awesome features so that you don't need to type commands anymore..
Stars: β 59 (-18.06%)
Mutual labels: viml
Javascript Indent
Javascript indenter (HTML indent is included)
Stars: β 71 (-1.39%)
Mutual labels: viml
Archidroid Legacy
Legacy ArchiDroid Repo / New -> https://github.com/ArchiDroid/ArchiDroid
Stars: β 68 (-5.56%)
Mutual labels: viml
Xvim
Powerfull vim configuration for C/C++/GO/JS coderοΌε₯½η¨ηvimζδ»Άιζε
οΌζ―ζC/C++/GO/JSοΌ
Stars: β 65 (-9.72%)
Mutual labels: viml
Vim Ruby Conque
Vim plugin to display ruby, rake, and rspec output colorized in ConqueTerm. Note: repeated runs of conqueterm may cause it to eat your shell ttys. I am no longer maintaining this.
Stars: β 61 (-15.28%)
Mutual labels: viml
Vimmate
Custom vim like Textmate for Ruby on Rails development
Stars: β 70 (-2.78%)
Mutual labels: viml
Vim Blockle
Brace yourself, it's time to toggle your ruby blocks!
Stars: β 60 (-16.67%)
Mutual labels: viml
Camelcasemotion
Motion through CamelCaseWords and underscore_notation.
Stars: β 64 (-11.11%)
Mutual labels: viml
Vim Git Branch Info
A Vim script to return info about the Git branches.
Stars: β 71 (-1.39%)
Mutual labels: viml
Vim Scmdiff
Vim script to highlight lines changed from a base version in SCM
Stars: β 65 (-9.72%)
Mutual labels: viml
underscore.vim
Vim script utility library π The sky is the limit!
underscore.vim is a Vim script library that provides a whole mess of useful functional programming helpers.
echo s:_.reject([1, 2, 3, 4, 5, 6], 'v:val % 2 == 0')
" => [1, 3, 5]
function! s:toFizzBuzz(x)
return a:x%15 ? a:x%3 ? a:x%5 ? a:x : 'Buzz' : 'Fizz' : 'FizzBuzz'
endfunction
echo s:_._(range(20))
\.chain()
\.map('v:val + 1')
\.filter('v:val % 2')
\.map(function('s:toFizzBuzz'))
\.value()
" => [1, 'Fizz', 'Buzz', 7, 'Fizz', 11, 13, 'FizzBuzz', 17, 19]
π¦ Installation π¦
- Install vital.vim and underscore.vim with your favorite plugin manager.
NeoBundle 'vim-jp/vital.vim'
NeoBundle 'haya14busa/underscore.vim'
Plugin 'vim-jp/vital.vim'
Plugin 'haya14busa/underscore.vim'
Plug 'vim-jp/vital.vim'
Plug 'haya14busa/underscore.vim'
- Embed underscore.vim into your plugin with
:Vitalize
.
:Vitalize . --name={plugin_name} Underscore
- Import underscore.vim in your plugins
let s:V = vital#of('vital')
let s:_ = s:V.import('Underscore').import()
echo s:_.filter([1, '2', '3', 4.0, 5], s:_.is_string)
" => ['2', '3']
π Documentation π
π Examples π
###π Real world(?) usage π
let s:V = vital#of('vital')
let s:_ = s:V.import('Underscore').import()
function! s:scouter(...)
let lines = readfile(expand(get(a:, 1, $MYVIMRC)))
let p = '^\s*$\|^\s*["\\]'
return s:_.chain(lines).reject(printf("v:val =~# '%s'", p)).length().value()
endfunction
" Count LOC of your vimrc
echo s:scouter()
" Return list of plugins in the given file or your vimrc
function! s:plugins(...)
let lines = readfile(expand(get(a:, 1, $MYVIMRC)))
let ignore = '^\s*$\|^\s*["\\]'
let bundle = "\\v%(%(Neo)?Bundle%(Lazy)|Plug%(in)?) ''([^'']+%(/[^'']+)?)"
return s:_.chain(lines)
\.reject(printf("v:val =~# '%s'", ignore))
\.select(printf("v:val =~# '%s'", bundle))
\.map(printf("matchlist(v:val, '%s')[1]", bundle))
\.sort()
\.value()
endfunction
" Get installed plugins in vimrc
echo s:plugins()
echo len(s:plugins())
π Memoize fibonacch π
let s:V = vital#of('vital')
let s:_ = s:V.import('Underscore').import()
function! s:_fib(n) abort
return a:n < 2 ? a:n : s:fib(a:n-1) + s:fib(a:n-2)
endfunction
let s:fib = s:_.memoize(function('s:_fib'))
echo s:fib(24)
" => 46368
βοΈ With Vital.Data.Closure βοΈ
let s:V = vital#of('vital')
let s:_ = s:V.import('Underscore').import()
let s:Closure = s:V.import('Data.Closure')
function! s:lambda(x, ...) abort
return call(s:Closure.build, [a:x] + a:000).to_function()
endfunction
echo s:_.chain(range(1,100))
\.select(s:lambda('= a:1 % 3 == 0'))
\.tap(s:lambda(":echo 'len: ' . len(a:1)"))
\.map(s:lambda('= a:1 * a:1'))
\.reject(s:lambda('= a:1 < 500'))
\.drop(3)
\.foldl(0, s:lambda('+'))
\.value()
" =>
" len: 33
" 109296
β‘οΈ Extend to work with other library β‘οΈ
You can extend underscore.vim with _.mixin()
β¨
See :h _.mixin()
underscore-string.vim
let s:V = vital#of('vital')
let s:_ = s:V.import('Underscore').import()
call s:_.mixin(s:V.import('Data.String'))
call s:_.mixin(s:V.import('Data.String.Interpolation'))
echo s:_.chain(" underscore-${module}.js! \r\n")
\.format({'module': 'string'})
\.replace('.js', '.vim')
\.chomp()
\.trim()
\.pad_left(25, '.')
\.value()
underscore-random.vim with closure
let s:V = vital#of('vital')
let s:_ = s:V.import('Underscore').import()
call s:_.mixin(s:V.import('Random'))
let s:Closure = s:V.import('Data.Closure')
function! s:lambda(x, ...) abort
return call(s:Closure.build, [a:x] + a:000).to_function()
endfunction
echo s:_.chain(range(100))
\.shuffle()
\.take(3)
\.foldl(0, s:lambda('+'))
\.value()
" => random: 155
If you want to see more examples, please see /example directory.
π Links π
The api and documentation are heavily inspired by Underscore.js, lodash and Underscore.lua. It's implementation are heavily inspired by and taken from vital.vim.
π¦ Author π¦
haya14busa (https://github.com/haya14busa)
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].