Skip to content

Instantly share code, notes, and snippets.

@mattn
Created January 29, 2016 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattn/e12aa8c2c231be1aa58b to your computer and use it in GitHub Desktop.
Save mattn/e12aa8c2c231be1aa58b to your computer and use it in GitHub Desktop.
function! s:append(line)
let wn = bufwinnr("tweets")
if wn == -1
return 0
endif
exe wn 'wincmd w'
try
let o = jsondecode(a:line)
let ts = type(o) == 3 ? o : [o]
for t in ts
1put!=t.user.screen_name . ': ' . t.text
endfor
finally
wincmd p
endtry
endfunction
if bufwinnr("tweets") == -1
10new tweets
setlocal buftype=nofile bufhidden=hide noswapfile
wincmd p
endif
function! TweetsCallback(handle, msg)
for line in split(a:msg, "\n")
call s:append(line)
endfor
redraw
endfunction
let handle = connect("127.0.0.1:7777", "raw", "TweetsCallback")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment