summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorryanss2015-09-04 23:59:00 -0400
committerryanss2015-09-04 23:59:00 -0400
commitb4f251bf4ba95d6d9c1b03117274a3470588e5f8 (patch)
tree07ee78d9d3ba9dc2599c28aff94fcc69da3315f4 /plugin
parenteb354aa1716d0fad88b2e59565599020a4af9706 (diff)
downloadvim-hn-b4f251bf4ba95d6d9c1b03117274a3470588e5f8.tar.gz
Improve handling of optional arg
An item_id can now be passed as the optional argument to the `:Hackernews` command which will load that specific item into the .hackernews buffer, whether it be a story, poll, comment thread or individual comment. Ex. `:Hackernews 9015621` Close #35
Diffstat (limited to 'plugin')
-rw-r--r--plugin/hackernews.vim21
1 files changed, 5 insertions, 16 deletions
diff --git a/plugin/hackernews.vim b/plugin/hackernews.vim
index bbe8200..cb0bff1 100644
--- a/plugin/hackernews.vim
+++ b/plugin/hackernews.vim
@@ -16,8 +16,8 @@ au! BufRead,BufNewFile *.hackernews set filetype=hackernews
" Set required defaults
-if !exists("g:hackernews_stories")
- let g:hackernews_stories = 'news'
+if !exists("g:hackernews_arg")
+ let g:hackernews_arg = 'news'
endif
if !exists("g:hackernews_marks")
@@ -27,20 +27,9 @@ endif
function! HackerNews(...)
if a:0 > 0
- let available_lists = ['news', 'newest', 'ask', 'show', 'shownew',
- \'jobs', 'best', 'active', 'noobstories']
- if index(available_lists, a:1) >= 0
- let g:hackernews_stories = a:1
- let stories = a:1
- else
- let g:hackernews_stories = 'news'
- let stories = ''
- end
- else
- let g:hackernews_stories = 'news'
- let stories = ''
- end
- execute "edit " . stories . ".hackernews"
+ let g:hackernews_arg = a:1
+ endif
+ execute "edit .hackernews"
normal! gg
endfunction