diff options
author | Jersey <fonseca@uchicago.edu> | 2020-06-30 16:42:46 +0000 |
---|---|---|
committer | Jersey <fonseca@uchicago.edu> | 2020-06-30 16:42:46 +0000 |
commit | 8e54b608cb0d1058bd34f475c3ae7c69111e3520 (patch) | |
tree | ac9c0d2692a22d9431781fc1ed253a568f7b6f91 /plugin | |
parent | 46af9f393c9e7044ec66ec7cafdf8370d186d3e5 (diff) |
Added mods and custom width config
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/bujo.vim | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/plugin/bujo.vim b/plugin/bujo.vim index b905b3a..cdc5d53 100644 --- a/plugin/bujo.vim +++ b/plugin/bujo.vim | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | " Get custom configs | 5 | " Get custom configs |
6 | 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") |
7 | let g:bujo#window_width = get(g: "bujo#window_width", 30) | 7 | let g:bujo#window_width = get(g:, "bujo#window_width", 30) |
8 | 8 | ||
9 | " Make bujo directory if it doesn't exist" | 9 | " Make bujo directory if it doesn't exist" |
10 | if empty(glob(g:bujo#todo_file_path)) | 10 | if empty(glob(g:bujo#todo_file_path)) |
@@ -39,26 +39,45 @@ function s:GetToplevelFolder() | |||
39 | return repo_name_clean | 39 | return repo_name_clean |
40 | endfunction | 40 | endfunction |
41 | 41 | ||
42 | " OpenTodo() opens the respective todo.md file from $HOME/.cache/bujo | 42 | |
43 | " If we are in a git repository, we open the todo.md for that git repository. | 43 | " GetBujoFilePath() returns which file path we will be using. If we are in a |
44 | " Otherwise, we open the global todo file. | 44 | " git repository, we return the directory for that specific git repo. |
45 | function s:OpenTodo(...) | 45 | " Otherwise, we return the general file path. |
46 | " If an argument was passed in, we open the general file | 46 | " |
47 | " a:0 will be false if no argument was passed in (a:0 == 0) | 47 | " If we are passed an argument, it means that the user wants to open the |
48 | if a:0 || !s:InGitRepository() | 48 | " general bujo file, so we also return the general file path in that case |
49 | exe ":" . g:bujo#window_width . "vs" . g:bujo#todo_file_path . "/todo.md" | 49 | function s:GetBujoFilePath(general) |
50 | else | 50 | if a:general || !s:InGitRepository() |
51 | let repo_name_clean = s:GetToplevelFolder() | 51 | return g:bujo#todo_file_path . "/todo.md" |
52 | let todo_path = g:bujo#todo_file_path . "/" . repo_name_clean | 52 | else |
53 | let repo_name = s:GetToplevelFolder() | ||
54 | let todo_path = g:bujo#todo_file_path . "/" . repo_name | ||
53 | if empty(glob(todo_path)) | 55 | if empty(glob(todo_path)) |
54 | call mkdir(todo_path) | 56 | call mkdir(todo_path) |
55 | endif | 57 | endif |
56 | exe ":" . g:bujo#window_width "vs" . todo_path . "/todo.md" | 58 | return todo_path . "/todo.md" |
57 | endif | 59 | endif |
58 | endfunction | 60 | endfunction |
59 | 61 | ||
62 | |||
63 | " OpenTodo() opens the respective todo.md file from $HOME/.cache/bujo | ||
64 | " If we are in a git repository, we open the todo.md for that git repository. | ||
65 | " Otherwise, we open the global todo file. | ||
66 | " | ||
67 | " Paramaters : | ||
68 | " | ||
69 | " mods - allows a user to use <mods> (see :h mods) | ||
70 | " | ||
71 | " ... - any parameter after calling :Todo will mean that the user wants | ||
72 | " us to open the general file path. We check this with a:0 | ||
73 | function s:OpenTodo(mods, ...) | ||
74 | let general_bool = a:0 | ||
75 | let todo_path = s:GetBujoFilePath(general_bool) | ||
76 | exe a:mods . " " . g:bujo#window_width "vs" . todo_path | ||
77 | endfunction | ||
78 | |||
60 | if !exists(":Todo") | 79 | if !exists(":Todo") |
61 | command -nargs=? Todo :call s:OpenTodo(<f-args>) | 80 | command -nargs=? Todo :call s:OpenTodo(<q-mods>, <f-args>) |
62 | endif | 81 | endif |
63 | 82 | ||
64 | " Update date upon enter. | 83 | " Update date upon enter. |