summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md13
-rw-r--r--doc/bujo.txt10
-rw-r--r--plugin/bujo.vim57
3 files changed, 64 insertions, 16 deletions
diff --git a/README.md b/README.md
index 7dd5a31..468887b 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,8 @@
1# vim-bujo 1# vim-bujo
2 2
3This plugin allows people to easily access and manage a minimalist todo list from vim. 3This plugin allows people to easily access and manage todo lists for their projects from vim.
4 4
5You can easily access and manage Todo lists of specific projects or a general Todo list.
5 6
6## Installation 7## Installation
7 8
@@ -17,9 +18,13 @@ Plug 'vuciv/vim-bujo'
17 18
18## Use / Mappings 19## Use / Mappings
19 20
20* Run: 21* Open Todo of current git repo:
21 ``` 22 ```
22 :Todo 23 :Todo // from git repo
24 ```
25* Open general Todo:
26 ```
27 :Todo g
23 ``` 28 ```
24* Insert a new task: 29* Insert a new task:
25 ``` 30 ```
@@ -42,7 +47,7 @@ Plug 'vuciv/vim-bujo'
42 47
43## Screenshots 48## Screenshots
44 49
45This gif shows how the TODO list opens up in vim. 50This gif shows how the Todo list opens up in vim.
46 51
47![Gif of Bujo use](https://raw.githubusercontent.com/jfonseca8/vim-bujo/master/screenshots/bujo.gif) 52![Gif of Bujo use](https://raw.githubusercontent.com/jfonseca8/vim-bujo/master/screenshots/bujo.gif)
48 53
diff --git a/doc/bujo.txt b/doc/bujo.txt
index 1bacef0..cea58be 100644
--- a/doc/bujo.txt
+++ b/doc/bujo.txt
@@ -4,7 +4,7 @@
4 4
5Author: Jersey Fonseca <jerseyfonseca@gmail.com> 5Author: Jersey Fonseca <jerseyfonseca@gmail.com>
6 6
7Version: 0.1 7Version: 0.2
8 8
91. Overview 91. Overview
102. Features 102. Features
@@ -15,9 +15,13 @@ Version: 0.1
151. Overview~ 151. Overview~
16 16
17This plugin allows people to easily access and 17This plugin allows people to easily access and
18manage a todo list. 18manage todo lists for their projects.
19 19
20You can stable versions of this plugin at: 20You can access Todo lists of specific projects just
21by being inside of that git repo. In addition, you
22can access a general todo list from any folder.
23
24You can find stable versions of this plugin at:
21 25
22https://github.com/jfonseca8/vim-bujo 26https://github.com/jfonseca8/vim-bujo
23 27
diff --git a/plugin/bujo.vim b/plugin/bujo.vim
index f29d268..e8b7077 100644
--- a/plugin/bujo.vim
+++ b/plugin/bujo.vim
@@ -1,21 +1,60 @@
1" bujo.vim - A minimalist todo list manager
2" Maintainer: Jersey Fonseca <http://www.jerseyfonseca.com/>
3" Version: 0.5
4
1"Make bujo directory if it doesn't exist" 5"Make bujo directory if it doesn't exist"
2let g:bujo#todo_file_path = get(g:, "bujo#todo_file_path", $HOME . "/.cache/bujo") 6let g:bujo#todo_file_path = get(g:, "bujo#todo_file_path", $HOME . "/.cache/bujo")
3if empty(glob(g:bujo#todo_file_path)) 7if empty(glob(g:bujo#todo_file_path))
4 call mkdir(g:bujo#todo_file_path) 8 call mkdir(g:bujo#todo_file_path)
5endif 9endif
6autocmd bufnewfile todo.md call append(0, '#Todo') 10
7autocmd bufnewfile todo.md call append(1, 'Date: ') 11" InGitRepository() tells us if the directory we are currently working in
8autocmd bufnewfile,bufread,filewritepre todo.md exe "g/Date: */s/Date: *.*/Date: " .strftime("%a %d %b %Y") 12" is a git repository. It makes use of the 'git rev-parse --is-inside-work-tree'
9autocmd bufnewfile,Bufwritepre,filewritepre todo.md execute "normal Go" 13" command. This command outputs true to the shell if so, and a STDERR message
14" otherwise.
15"
16" We will use this function to know whether we should open a specific
17" project's todo list, or a global todo list.
18function s:InGitRepository()
19 :silent let bool = system("git rev-parse --is-inside-work-tree")
20
21 " The git function will return true with some leading characters
22 " if we are in a repository. So, we split off those characters
23 " and just check the first word.
24 if split(bool, '\v\n')[0] == 'true'
25 return 1
26 endif
27endfunction
10 28
11 29
30" GetToplevelFolder() gives us a clean name of the git repository that we are
31" currently working in
32function s:GetToplevelFolder()
33 let absolute_path = system("git rev-parse --show-toplevel")
34 let repo_name = split(absolute_path, "/")
35 let repo_name_clean = split(repo_name[-1], '\v\n')[0]
36 return repo_name_clean
37endfunction
12 38
13" Open the bujo todo list file 39" OpenTodo() opens the respective todo.md file from $HOME/.cache/bujo
14function s:OpenTodo() 40" If we are in a git repository, we open the todo.md for that git repository.
15 "30 makes it open at width 30 41" Otherwise, we open the global todo file.
16 exe ":30vs" . g:bujo#todo_file_path . "/todo.md" 42function s:OpenTodo(...)
43 " If an argument was passed in, we open the general file
44 " a:0 will be false if no argument was passed in (a:0 == 0)
45 if a:0 || !s:InGitRepository()
46 exe ":30vs" . g:bujo#todo_file_path . "/todo.md"
47 else
48 let repo_name_clean = s:GetToplevelFolder()
49 exe ":30vs" . g:bujo#todo_file_path . "/" . repo_name_clean . "/todo.md"
50 endif
17endfunction 51endfunction
18 52
19if !exists(":Todo") 53if !exists(":Todo")
20 command Todo :call s:OpenTodo() 54 command -nargs=? Todo :call s:OpenTodo(<f-args>)
21endif 55endif
56
57autocmd bufnewfile todo.md call append(0, '#' . split(expand('%:p:h:t'), '\v\n')[0] . " todo")
58autocmd bufnewfile todo.md call append(1, 'Date: ')
59autocmd bufnewfile,bufread,filewritepre todo.md exe "g/Date: */s/Date: *.*/Date: " .strftime("%a %d %b %Y")
60autocmd bufnewfile,Bufwritepre,filewritepre todo.md execute "normal Go"