From 9d7b4354b16feefea15eadff01a2bcb9858e4e4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ot=C3=A1vio=20Rizzatti?= Date: Sun, 16 Mar 2014 11:32:16 -0400 Subject: [PATCH] Improve DashKeywords Calling DashKeywords without arguments will show the keywords set for the current buffer. --- autoload/dash.vim | 25 ++++++++++++++++++++++--- plugin/dash.vim | 2 +- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/autoload/dash.vim b/autoload/dash.vim index 2fd898e..f5db0a6 100644 --- a/autoload/dash.vim +++ b/autoload/dash.vim @@ -50,9 +50,11 @@ endfunction "}}} function! dash#keywords(...) "{{{ - let keywords = copy(a:000) - call filter(keywords, 'index(s:cache.keywords(), v:val) != -1') - let b:dash_keywords = keywords + if a:0 == 0 + call s:show_buffer_keywords() + else + call s:set_buffer_keywords(a:000) + endif endfunction "}}} @@ -119,4 +121,21 @@ function! s:search(term, keywords) "{{{ endfunction "}}} +function! s:set_buffer_keywords(keyword_list) "{{{ + let keywords = copy(a:keyword_list) + call filter(keywords, 'index(s:cache.keywords(), v:val) != -1') + let b:dash_keywords = keywords +endfunction +"}}} + +function! s:show_buffer_keywords() "{{{ + redraw + if !exists("b:dash_keywords") || empty(b:dash_keywords) + echo "There are no keywords set for the current buffer." + else + echo "Keywords: " . join(b:dash_keywords, " ") + endif +endfunction +"}}} + call s:extend_keywords_map() diff --git a/plugin/dash.vim b/plugin/dash.vim index 80581f7..4a3de5c 100644 --- a/plugin/dash.vim +++ b/plugin/dash.vim @@ -49,7 +49,7 @@ if exists(':DashKeywords') == 2 echomsg 'dash.vim: could not create command DashKeywords' echohl None else - command -complete=customlist,dash#complete -nargs=+ DashKeywords call dash#keywords() + command -complete=customlist,dash#complete -nargs=* DashKeywords call dash#keywords() endif "}}}