mirror of
https://github.com/rizzatti/dash.vim.git
synced 2026-03-03 18:24:03 +01:00
Improve DashKeywords
Calling DashKeywords without arguments will show the keywords set for the current buffer.
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
"}}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user