blindFS / vim-taskwarrior

vim interface for taskwarrior
Other
518 stars 42 forks source link

vim-taskwarrior overrides all mappings and there's no way to prevent it #127

Open Ram-Z opened 8 years ago

Ram-Z commented 8 years ago

I have <space> as my leader key and I can't use it inside taskreport files.

Adding an option to prevent any mappings to be set, or checking whether a key is already mapped using maparg would be very welcomed.

tecfu commented 8 years ago

I found two different workarounds for this.

  1. You can create the file .vim/after/ftplugin/taskreport.vim and put any desired mappings/remappings there.
  2. You can use the async api to run a job to change the keymappings after a taskreport buffer is loaded, since the keymappings are created after all of Vim's event options.
function! TWUnmap(a,b)
    unmap <buffer> J
    unmap <buffer> K
endfunction

function! TWUnmapChooser()
    if has("nvim")
        call jobstart(['bash','-c','echo "-"; exit;'],{'on_stdout':'TWUnmap'})
    else
        call job_start(['bash','-c','echo "-"; exit;'],{'out_cb':'TWUnmap'})
    endif
endfunction

augroup TaskwarriorMapping
    autocmd!
    autocmd FileType taskreport :call TWUnmapChooser() 
augroup END