From e5786259c45ecf02158f13703cf191a429ce8b98 Mon Sep 17 00:00:00 2001 From: Jersey Date: Fri, 26 Jun 2020 14:03:53 -0500 Subject: Project specific integration --- plugin/bujo.vim | 53 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/plugin/bujo.vim b/plugin/bujo.vim index f29d268..983c832 100644 --- a/plugin/bujo.vim +++ b/plugin/bujo.vim @@ -3,19 +3,54 @@ let g:bujo#todo_file_path = get(g:, "bujo#todo_file_path", $HOME . "/.cache/bujo if empty(glob(g:bujo#todo_file_path)) call mkdir(g:bujo#todo_file_path) endif -autocmd bufnewfile todo.md call append(0, '#Todo') -autocmd bufnewfile todo.md call append(1, 'Date: ') -autocmd bufnewfile,bufread,filewritepre todo.md exe "g/Date: */s/Date: *.*/Date: " .strftime("%a %d %b %Y") -autocmd bufnewfile,Bufwritepre,filewritepre todo.md execute "normal Go" +" InGitRepository() tells us if the directory we are currently working in +" is a git repository. It makes use of the 'git rev-parse --is-inside-work-tree' +" command. This command outputs true to the shell if so, and a STDERR message +" otherwise. +" +" We will use this function to know whether we should open a specific +" project's todo list, or a global todo list. +function s:InGitRepository() + :silent let bool = system("git rev-parse --is-inside-work-tree") + + " The git function will return true with some leading characters + " if we are in a repository. So, we split off those characters + " and just check the first word. + if split(bool, '\v\n')[0] == 'true' + return 1 + endif +endfunction -" Open the bujo todo list file -function s:OpenTodo() - "30 makes it open at width 30 - exe ":30vs" . g:bujo#todo_file_path . "/todo.md" +" GetToplevelFolder() gives us a clean name of the git repository that we are +" currently working in +function s:GetToplevelFolder() + let absolute_path = system("git rev-parse --show-toplevel") + let repo_name = split(absolute_path, "/") + let repo_name_clean = split(repo_name[-1], '\v\n')[0] + return repo_name_clean +endfunction + +" OpenTodo() opens the respective todo.md file from $HOME/.cache/bujo +" If we are in a git repository, we open the todo.md for that git repository. +" Otherwise, we open the global todo file. +function s:OpenTodo(...) + " If an argument was passed in, we open the general file + " a:0 will be false if no argument was passed in (a:0 == 0) + if a:0 || !s:InGitRepository() + exe ":30vs" . g:bujo#todo_file_path . "/todo.md" + else + let repo_name_clean = s:GetToplevelFolder() + exe ":30vs" . g:bujo#todo_file_path . "/" . repo_name_clean . "/todo.md" + endif endfunction if !exists(":Todo") - command Todo :call s:OpenTodo() + command -nargs=? Todo :call s:OpenTodo() endif + +autocmd bufnewfile todo.md call append(0, '#' . split(expand('%:p:h:t'), '\v\n')[0] . " todo") +autocmd bufnewfile todo.md call append(1, 'Date: ') +autocmd bufnewfile,bufread,filewritepre todo.md exe "g/Date: */s/Date: *.*/Date: " .strftime("%a %d %b %Y") +autocmd bufnewfile,Bufwritepre,filewritepre todo.md execute "normal Go" -- cgit v1.2.3 From 0807b7aed40a1c9758f6944e0ee8c8f448ff6c58 Mon Sep 17 00:00:00 2001 From: Jersey Date: Fri, 26 Jun 2020 14:20:02 -0500 Subject: Updated README and doc --- README.md | 14 +++++++++++--- doc/bujo.txt | 10 +++++++--- plugin/bujo.vim | 4 ++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7dd5a31..b76f3b9 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ # vim-bujo -This plugin allows people to easily access and manage a minimalist todo list from vim. +This plugin allows people to easily access and manage todo lists for their projects from vim. +This plugin allows people to easily access and manage todo lists for their projects. + +You can access Todo lists of specific projects just by being inside of that git repo. In addition, you can access a general todo list from any folder. + ## Installation If you use a plugin manager, such as [vim-plug], follow its instructions on how to install plugins from github. @@ -17,9 +21,13 @@ Plug 'vuciv/vim-bujo' ## Use / Mappings -* Run: +* Open general Todo: + ``` + :Todo g + ``` +* Open Todo of git repo: ``` - :Todo + :Todo // from git repo ``` * Insert a new task: ``` 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 @@ Author: Jersey Fonseca -Version: 0.1 +Version: 0.2 1. Overview 2. Features @@ -15,9 +15,13 @@ Version: 0.1 1. Overview~ This plugin allows people to easily access and -manage a todo list. +manage todo lists for their projects. -You can stable versions of this plugin at: +You can access Todo lists of specific projects just +by being inside of that git repo. In addition, you +can access a general todo list from any folder. + +You can find stable versions of this plugin at: https://github.com/jfonseca8/vim-bujo diff --git a/plugin/bujo.vim b/plugin/bujo.vim index 983c832..e8b7077 100644 --- a/plugin/bujo.vim +++ b/plugin/bujo.vim @@ -1,3 +1,7 @@ +" bujo.vim - A minimalist todo list manager +" Maintainer: Jersey Fonseca +" Version: 0.5 + "Make bujo directory if it doesn't exist" let g:bujo#todo_file_path = get(g:, "bujo#todo_file_path", $HOME . "/.cache/bujo") if empty(glob(g:bujo#todo_file_path)) -- cgit v1.2.3 From 8249dbf99f739360defdabc8da964ce9268781f3 Mon Sep 17 00:00:00 2001 From: Jersey Fonseca Date: Fri, 26 Jun 2020 14:21:40 -0500 Subject: Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b76f3b9..9241978 100644 --- a/README.md +++ b/README.md @@ -21,13 +21,13 @@ Plug 'vuciv/vim-bujo' ## Use / Mappings -* Open general Todo: +* Open Todo of current git repo: ``` - :Todo g + :Todo // from git repo ``` -* Open Todo of git repo: +* Open general Todo: ``` - :Todo // from git repo + :Todo g ``` * Insert a new task: ``` @@ -50,7 +50,7 @@ Plug 'vuciv/vim-bujo' ## Screenshots -This gif shows how the TODO list opens up in vim. +This gif shows how the Todo list opens up in vim. ![Gif of Bujo use](https://raw.githubusercontent.com/jfonseca8/vim-bujo/master/screenshots/bujo.gif) -- cgit v1.2.3 From 7573cf6459273425d10a5972a76f1a2a7b376063 Mon Sep 17 00:00:00 2001 From: Jersey Fonseca Date: Fri, 26 Jun 2020 14:22:32 -0500 Subject: Update README.md --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 9241978..468887b 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,7 @@ This plugin allows people to easily access and manage todo lists for their projects from vim. - -This plugin allows people to easily access and manage todo lists for their projects. - -You can access Todo lists of specific projects just by being inside of that git repo. In addition, you can access a general todo list from any folder. +You can easily access and manage Todo lists of specific projects or a general Todo list. ## Installation -- cgit v1.2.3