-
Notifications
You must be signed in to change notification settings - Fork 86
Examples
Liu-Cheng Xu edited this page Jun 2, 2021
·
6 revisions
The examples here are community-driven and not guaranteed to be bug-free.
Ensure your code is tested at least by yourself before adding it here.
let g:clap_provider_dotfiles = {
\ 'source': ['~/.vimrc', '~/.spacevim', '~/.bashrc', '~/.tmux.conf'],
\ 'sink': 'e',
\ 'description': 'Open some dotfile',
\ }
Use :Clap dotfiles
to open some dotfiles quickly.
let g:clap_provider_commands = {
\ 'source': ['Clap debug', 'UltiSnipsEdit'],
\ 'sink': { selected -> execute(selected, '')},
\ 'description': 'Execute some command',
\ }
Use :Clap commands
to execute the custom commands.
function! TaskSource() abort
let source_filetype = getbufvar(g:clap.start.bufnr, '&filetype')
" Return the command list according to the filetype.
" You can also use a Dict for easier config.
if source_filetype ==# 'rust'
return ['cargo build', 'cargo run']
elseif source_filetype ==# 'go'
return ['go build']
else
return []
endif
endfunction
function! TaskSink(selected) abort
" Execute the command properly, like run in a terminal buffer or something.
"
" Here is a dead simple example to run the command in a blocking way.
execute '!'.a:selected
endfunction
let g:clap_provider_task = {
\ 'source': function('TaskSource'),
\ 'sink': function('TaskSink'),
\ 'description': 'Task',
\ }