Skip to content

vim-fugitive fails unless taskwiki_disable not empty #455

@jfishe

Description

@jfishe

https://github.com/tpope/vim-fugitive/ fails and creates a fugitive:/ folder, in the project root, of a git repo, when taskwiki auto loads tasks. Gdiffsplit and G cause taskwiki to update vimwiki format and markdown format, when managed by vimwiki.

The simple manual work around is let taskwiki_disable=1, before a fugitive:* buffer is loaded. Below is an attempt to automate this.

This may help with #377.

Is this something we should include in taskwiki?

~/.vim/plugin/vimwiki.vim:

" Disable Taskwiki when Diff and Fugitive buffers exist. {{{
function! s:disable_taskwiki() abort
  let l:disable_status = [
        \ get(g:, 'taskwiki_disable', ''),
        \ get(g:, 'undo_taskwiki_disable', '')
        \ ]
  if empty(list2str(l:disable_status))
    let g:undo_taskwiki_disable = 'empty'
    let g:taskwiki_disable = 1
  elseif l:disable_status[1] == 'empty'
    let g:taskwiki_disable = 1
  elseif ! empty(l:disable_status[0])
    let g:undo_taskwiki_disable = g:taskwiki_disable
  endif
endfunction

function! s:restore_disable_taskwiki() abort
  let l:disable_status = [
        \ get(g:, 'taskwiki_disable', ''),
        \ get(g:, 'undo_taskwiki_disable', '')
        \ ]
  if empty(list2str(l:disable_status))
    return
  elseif l:disable_status[1] == 'empty'
    unlet g:taskwiki_disable
    unlet g:undo_taskwiki_disable
  elseif ! empty(l:disable_status[1])
    let g:taskwiki_disable = g:undo_taskwiki_disable
    unlet g:undo_taskwiki_disable
  endif
endfunction

augroup myTaskwiki
  autocmd!
  autocmd BufEnter,BufWinEnter,BufNew * if buffer_name() =~ 'fugitive:' | call s:disable_taskwiki() | endif
  autocmd BufUnload,BufHidden * if buffer_name() =~ 'fugitive:' | call s:restore_disable_taskwiki() | endif
augroup END " }}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions