blob: 2c94832c51d517865e19d5afb7c7dc80d6710620 (
plain)
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
|
" vim-hackernews
" --------------
" Browse Hacker News (news.ycombinator.com) inside Vim.
"
" Author: ryanss <ryanssdev@icloud.com>
" Website: https://github.com/ryanss/vim-hackernews
" License: MIT (see LICENSE file)
" Version: 0.1.1
if !has('python')
echo "HackerNews.vim Error: Requires Vim compiled with +python"
finish
endif
if !exists("g:hackernews_marks")
let g:hackernews_marks = {}
endif
" Import Python code
execute "python import sys"
execute "python sys.path.append(r'" . expand("<sfile>:p:h") . "')"
python << EOF
if 'hackernews' not in sys.modules:
import hackernews
else:
# Reload python module to avoid errors when updating plugin
hackernews = reload(hackernews)
EOF
" Load front page
execute "python hackernews.main()"
noremap <buffer> o :python hackernews.link()<cr>
noremap <buffer> O :python hackernews.link(external=True)<cr>
noremap <buffer> gx :python hackernews.link(external=True)<cr>
noremap <buffer> u u:python hackernews.recall_pos()<cr>
noremap <buffer> <C-r> <C-r>:python hackernews.recall_pos()<cr>
|