├── README.md └── autoload └── usa_president_2016.vim /README.md: -------------------------------------------------------------------------------- 1 | # vim-usa-president-2016 2 | 3 | Indicate USA President 2016 in Vim 4 | 5 | ![vim-usa-president-2016](http://go-gyazo.appspot.com/0b7b38aee4eeaf2b.png) 6 | 7 | ## Usage 8 | 9 | set `usa_president_2016#status()` into you `statusline` like below. 10 | 11 | ```vim 12 | set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\[%{usa_president_2016#status()}\]\ %P 13 | ``` 14 | 15 | ## Requirements 16 | 17 | * https://github.com/mattn/webapi-vim 18 | 19 | ## License 20 | 21 | MIT 22 | 23 | ## Author 24 | 25 | Yasuhiro Matsumoto (a.k.a. mattn) 26 | -------------------------------------------------------------------------------- /autoload/usa_president_2016.vim: -------------------------------------------------------------------------------- 1 | let s:status = '' 2 | 3 | function! usa_president_2016#status() 4 | return s:status 5 | endfunction 6 | 7 | function! usa_president_2016#update() 8 | let a = webapi#json#decode(webapi#http#get('http://elections.huffingtonpost.com/2016/results/president.json').content) 9 | let s:status = printf('Clinton(%d) vs Trump(%d)', 10 | \ a.summaries.president.nClintonElectoralVotes, 11 | \ a.summaries.president.nTrumpElectoralVotes) 12 | call timer_start(60000, {x->usa_president_2016#update()}) 13 | endfunction 14 | 15 | call usa_president_2016#update() 16 | --------------------------------------------------------------------------------