Improve DashKeywords

Calling DashKeywords without arguments will show the keywords set for
the current buffer.
This commit is contained in:
José Otávio Rizzatti
2014-03-16 11:32:16 -04:00
parent cdf9df09e5
commit 9d7b4354b1
2 changed files with 23 additions and 4 deletions

View File

@@ -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()

View File

@@ -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(<f-args>)
command -complete=customlist,dash#complete -nargs=* DashKeywords call dash#keywords(<f-args>)
endif
"}}}