diff options
-rw-r--r-- | README.md | 13 | ||||
-rw-r--r-- | doc/bujo.txt | 10 | ||||
-rw-r--r-- | plugin/bujo.vim | 57 |
3 files changed, 64 insertions, 16 deletions
@@ -1,7 +1,8 @@ | |||
1 | # vim-bujo | 1 | # vim-bujo |
2 | 2 | ||
3 | This plugin allows people to easily access and manage a minimalist todo list from vim. | 3 | This plugin allows people to easily access and manage todo lists for their projects from vim. |
4 | 4 | ||
5 | You 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 | ||
45 | This gif shows how the TODO list opens up in vim. | 50 | This 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 | ||
5 | Author: Jersey Fonseca <jerseyfonseca@gmail.com> | 5 | Author: Jersey Fonseca <jerseyfonseca@gmail.com> |
6 | 6 | ||
7 | Version: 0.1 | 7 | Version: 0.2 |
8 | 8 | ||
9 | 1. Overview | 9 | 1. Overview |
10 | 2. Features | 10 | 2. Features |
@@ -15,9 +15,13 @@ Version: 0.1 | |||
15 | 1. Overview~ | 15 | 1. Overview~ |
16 | 16 | ||
17 | This plugin allows people to easily access and | 17 | This plugin allows people to easily access and |
18 | manage a todo list. | 18 | manage todo lists for their projects. |
19 | 19 | ||
20 | You can stable versions of this plugin at: | 20 | You can access Todo lists of specific projects just |
21 | by being inside of that git repo. In addition, you | ||
22 | can access a general todo list from any folder. | ||
23 | |||
24 | You can find stable versions of this plugin at: | ||
21 | 25 | ||
22 | https://github.com/jfonseca8/vim-bujo | 26 | https://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" |
2 | let g:bujo#todo_file_path = get(g:, "bujo#todo_file_path", $HOME . "/.cache/bujo") | 6 | let g:bujo#todo_file_path = get(g:, "bujo#todo_file_path", $HOME . "/.cache/bujo") |
3 | if empty(glob(g:bujo#todo_file_path)) | 7 | if empty(glob(g:bujo#todo_file_path)) |
4 | call mkdir(g:bujo#todo_file_path) | 8 | call mkdir(g:bujo#todo_file_path) |
5 | endif | 9 | endif |
6 | autocmd bufnewfile todo.md call append(0, '#Todo') | 10 | |
7 | autocmd bufnewfile todo.md call append(1, 'Date: ') | 11 | " InGitRepository() tells us if the directory we are currently working in |
8 | autocmd 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' |
9 | autocmd 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. | ||
18 | function 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 | ||
27 | endfunction | ||
10 | 28 | ||
11 | 29 | ||
30 | " GetToplevelFolder() gives us a clean name of the git repository that we are | ||
31 | " currently working in | ||
32 | function 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 | ||
37 | endfunction | ||
12 | 38 | ||
13 | " Open the bujo todo list file | 39 | " OpenTodo() opens the respective todo.md file from $HOME/.cache/bujo |
14 | function 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" | 42 | function 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 | ||
17 | endfunction | 51 | endfunction |
18 | 52 | ||
19 | if !exists(":Todo") | 53 | if !exists(":Todo") |
20 | command Todo :call s:OpenTodo() | 54 | command -nargs=? Todo :call s:OpenTodo(<f-args>) |
21 | endif | 55 | endif |
56 | |||
57 | autocmd bufnewfile todo.md call append(0, '#' . split(expand('%:p:h:t'), '\v\n')[0] . " todo") | ||
58 | autocmd bufnewfile todo.md call append(1, 'Date: ') | ||
59 | autocmd bufnewfile,bufread,filewritepre todo.md exe "g/Date: */s/Date: *.*/Date: " .strftime("%a %d %b %Y") | ||
60 | autocmd bufnewfile,Bufwritepre,filewritepre todo.md execute "normal Go" | ||