Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hack to enable neovim support #136

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 44 additions & 25 deletions autoload/taskwarrior/action.vim
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,34 @@ function! taskwarrior#action#modify(mode)
endfunction

function! taskwarrior#action#delete()
let uuid = taskwarrior#data#get_uuid()
if uuid == ''
call taskwarrior#action#annotate('del')
else
let ccol = taskwarrior#data#current_column()
if index(['project', 'tags', 'due', 'priority', 'start', 'depends'], ccol) != -1
call taskwarrior#system_call(uuid, 'modify', ccol.':', 'silent')
let uuid = taskwarrior#data#get_uuid()
if uuid == ''
call taskwarrior#action#annotate('del')
else
execute '!task '.uuid.' delete'
let ccol = taskwarrior#data#current_column()
if index(['project', 'tags', 'due', 'priority', 'start', 'depends'], ccol) != -1
call taskwarrior#system_call(uuid, 'modify', ccol.':', 'silent')
else
if !has('nvim')
execute '!task '.uuid.' delete'
else
execute terminal 'task'.uuid.'delete'
endif
endif
endif
if !has('nvim')
call taskwarrior#refresh()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you have in indentation problem here

endif
endif
call taskwarrior#refresh()
endfunction

function! taskwarrior#action#remove()
execute '!task '.taskwarrior#data#get_uuid().' delete'
call taskwarrior#list()
if !has('nvim')
execute '!task '.taskwarrior#data#get_uuid().' delete'
call taskwarrior#list()
else
execute 'terminal task '.taskwarrior#data#get_uuid().' delete'
endif

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's generally better if you start with the positive route if has('nvim')

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback, I think I have fixed/improved the bits of code that you picked up.

endfunction

function! taskwarrior#action#annotate(op)
Expand Down Expand Up @@ -297,21 +308,27 @@ function! taskwarrior#action#move_cursor(direction, mode)
endfunction

function! taskwarrior#action#undo()
if has("gui_running")
if exists('g:task_gui_term') && g:task_gui_term == 1
!task rc.color=off undo
elseif executable('xterm')
silent !xterm -e 'task undo'
elseif executable('urxvt')
silent !urxvt -e task undo
elseif executable('gnome-terminal')
silent !gnome-terminal -e 'task undo'
endif
if has('nvim')
terminal task undo
else
sil !clear
!task undo
if has("gui_running")
if exists('g:task_gui_term') && g:task_gui_term == 1
!task rc.color=off undo
elseif executable('xterm')
silent !xterm -e 'task undo'
elseif executable('urxvt')
silent !urxvt -e task undo
elseif executable('gnome-terminal')
silent !gnome-terminal -e 'task undo'
endif
else
sil !clear
!task undo
endif
if has('nvim')
call taskwarrior#refresh()
endif
endif
call taskwarrior#refresh()
endfunction

function! taskwarrior#action#clear_completed()
Expand All @@ -321,7 +338,9 @@ endfunction

function! taskwarrior#action#sync(action)
execute '!task '.a:action.' '
call taskwarrior#refresh()
if !has('nvim')
call taskwarrior#refresh()
endif
endfunction

function! taskwarrior#action#select()
Expand Down
7 changes: 7 additions & 0 deletions ftplugin/taskreport.vim
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,10 @@ endif
command! -buffer TWToggleReadonly :let g:task_readonly = (g:task_readonly ? 0 : 1) | call taskwarrior#refresh()
command! -buffer TWToggleHLField :let g:task_highlight_field = (g:task_highlight_field ? 0 : 1) | call taskwarrior#refresh()
command! -buffer -nargs=? -complete=customlist,taskwarrior#complete#sort TWReportSort :call taskwarrior#action#sort_by_arg(<q-args>)

if has('nvim')
augroup taskwarrior#neovim
autocmd!
autocmd BufEnter task*report call taskwarrior#refresh()
augroup end
endif