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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
" 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
Execute (Test Plugin Loaded):
AssertEqual 1, filereadable('doc/hackernews.txt')
AssertEqual 1, filereadable('ftplugin/hackernews.py')
AssertEqual 1, filereadable('ftplugin/hackernews.vim')
AssertEqual 1, filereadable('plugin/hackernews.vim')
AssertEqual 1, filereadable('syntax/hackernews.vim')
redir @a
au BufRead *.hackernews
redir @b
au BufNewFile *.hackernews
redir @c
command HackerNews
redir END
Do (Test autocmd BufRead *.hackernews):
"apdd
Expect (set filetype=hackernews):
--- Auto-Commands ---
BufRead
*.hackernews
set filetype=hackernews
Do (Test autocmd BufNewFile *.hackernews):
"bpdd
Expect (set filetype=hackernews):
--- Auto-Commands ---
BufNewFile
*.hackernews
set filetype=hackernews
Do (Test HackerNews Defined):
"cpdddd
:%s/ \{2,}/ /g\<cr>
Expect (HackerNews Defined):
HackerNews ? call HackerNews(<q-args>)
Execute (Test HackerNews Command):
HackerNews
Then (Test Front Page):
AssertEqual getline(1), '┌───┐'
AssertEqual getline(2), '│ Y │ Hacker News (news.ycombinator.com)'
AssertEqual getline(3), '└───┘'
AssertEqual 'Comment', SyntaxAt(5,2), 'Item number syntax'
AssertEqual 'Comment', SyntaxAt(6,5), 'Point/user/comment line syntax'
AssertEqual '', SyntaxAt(5,5), 'Item title syntax'
Do (Test Key Mappings):
:HackerNews\<cr>
ggVGd
:redir @a\<cr>
:map o\<cr>
:map O\<cr>
:map gx\<cr>
:map u\<cr>
:map <C-R>\<cr>
"apdd
:%s/^.*Netrw.*$\n//g\<cr>
Expect (Keys Mapped):
o *@:Python hackernews.link()<CR>
O *@:Python hackernews.link(external=True)<CR>
gx *@:Python hackernews.link(external=True)<CR>
u *@:Python hackernews.save_pos()<CR>u:Python hackernews.recall_pos()<CR>
<C-R> *@:Python hackernews.save_pos()<CR><C-R>:Python hackernews.recall_pos()<CR>
Do (Test opening `link` type):
:HackerNews\<cr>
cc[9015621]\<esc>o
Then (Test `link` opened):
AssertEqual getline(1), 'Show HN: vim-hackernews (github.com)'
|