Skip to content

Commit 9ef531b

Browse files
committed
Implements taskopen and tasknote
1 parent bc4a017 commit 9ef531b

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

ftplugin/vimwiki/taskwiki.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ execute "command! -nargs=* TaskWikiTags :" . g:taskwiki_py . "SplitTa
6666
" Commands that operate on tasks in the buffer
6767
execute "command! -range TaskWikiInfo :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().info()"
6868
execute "command! -range TaskWikiOpen :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().open()"
69+
execute "command! -range TaskWikiNote :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().note()"
6970
execute "command! -range TaskWikiEdit :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().edit()"
7071
execute "command! -range TaskWikiLink :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().link()"
7172
execute "command! -range TaskWikiGrid :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().grid()"
@@ -121,6 +122,7 @@ if !exists('g:taskwiki_suppress_mappings')
121122
nnoremap <silent><buffer> <LocalLeader>ha :TaskWikiHistoryAnnual<CR>
122123
nnoremap <silent><buffer> <LocalLeader>i :TaskWikiInfo<CR>
123124
nnoremap <silent><buffer> <LocalLeader>o :TaskWikiOpen<CR>
125+
nnoremap <silent><buffer> <LocalLeader>n :TaskWikiNote<CR>
124126
nnoremap <silent><buffer> <LocalLeader>l :TaskWikiLink<CR>
125127
nnoremap <silent><buffer> <LocalLeader>m :TaskWikiMod<CR>
126128
nnoremap <silent><buffer> <LocalLeader>p :TaskWikiProjects<CR>

taskwiki/main.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import six
77
import sys
88
import vim # pylint: disable=F0401
9+
import subprocess
910

1011
# Insert the taskwiki on the python path
1112
BASE_DIR = vim.eval("s:plugin_path")
@@ -126,12 +127,27 @@ def info(self):
126127
@errors.pretty_exception_handler
127128
def open(self):
128129
for vimwikitask in self.tasks:
129-
if "Notes" in [
130+
for annotation in vimwikitask.task["annotations"]:
131+
annotation = annotation["description"]
132+
proc = subprocess.Popen(["xdg-open", annotation])
133+
try:
134+
proc.wait(0.3)
135+
except subprocess.TimeoutExpired:
136+
return
137+
138+
print("No compatible annotation found.")
139+
140+
@errors.pretty_exception_handler
141+
def note(self):
142+
for vimwikitask in self.tasks:
143+
if "Notes" not in [
130144
a["description"] for a in vimwikitask.task["annotations"]
131145
]:
132-
note_path = "/home/nikos/.local/share/taskwarrior/notes/"
133-
note_path += vimwikitask.task["uuid"] + ".md"
134-
vim.command("edit " + note_path)
146+
self.annotate("Notes")
147+
148+
note_path = "/home/nikos/.local/share/taskwarrior/notes/"
149+
note_path += vimwikitask.task["uuid"] + ".md"
150+
vim.command("edit " + note_path)
135151

136152
@errors.pretty_exception_handler
137153
def edit(self):

0 commit comments

Comments
 (0)