@@ -30,7 +30,7 @@ endfunction
30
30
31
31
" "
32
32
" Completion for :Note.
33
- function ! noteworthy#Completion (arg_lead, cmd_line, cursor_pos ) abort
33
+ function ! noteworthy#Completion (... ) abort
34
34
let l: fext = get (g: , ' noteworthy_ambiguous' , 0 ) ? ' *' : s: GetNoteFileExt ()
35
35
let l: dir = s: GetCurrentLibrary ()
36
36
if ! isdirectory (l: dir ) | return ' ' | endif
@@ -41,17 +41,19 @@ endfunction
41
41
" "
42
42
" Call for :NoteLibrary. Decides if we're getting or setting, and calls the
43
43
" appropriate function.
44
- function ! noteworthy#Library (... ) abort
44
+ function ! noteworthy#Library (visualize, ... ) abort
45
45
if a: 0
46
46
call s: SetCurrentLibrary (a: 1 )
47
47
echo ' Setting library to "' . a: 1 . ' "'
48
- return
48
+ else
49
+ echo ' Current library is set to "' . g: noteworthy_current_library . ' "'
50
+ endif
51
+ if a: visualize
52
+ call s: Visualize (s: GetCurrentLibrary ())
49
53
endif
50
- call s: GetCurrentLibrary ()
51
- echo ' Current library is set to "' . g: noteworthy_current_library . ' "'
52
54
endfunction
53
55
54
- " "
56
+ " "{{{
55
57
" Get or set the extension to use for notes.
56
58
function ! noteworthy#Extension (... ) abort
57
59
if a: 0
@@ -74,12 +76,31 @@ function! noteworthy#Delimiter(...) abort
74
76
echo ' Current delimiter is set to "' .
75
77
\ get (g: , ' noteworthy_delimiter' , s: GetNoteDelimiter ()) . ' "'
76
78
endfunction
77
-
79
+ " }}}
78
80
" PRIVATE API
79
81
82
+ " "
83
+ " TODO Getting closer. The files just don't open when you hit they key.
84
+ " Also, is Netrw just used for stuff like this? Should I not be trying to do
85
+ " this manually?
86
+ function ! s: Visualize (library) abort
87
+ execute ' silent vsplit __' . toupper (g: noteworthy_current_library ) . ' _LIBRARY__'
88
+ setlocal buftype = nofile
89
+ setlocal modifiable
90
+ let l: files = split (noteworthy#Completion (), " \n " )
91
+ call append (0 , l: files )
92
+ nnoremap <buffer> o call noteworthy#Open(a:library)
93
+ silent normal ! gg
94
+ setlocal nomodifiable
95
+ endfunction
96
+
97
+ function ! noteworthy#Open (library) abort
98
+ echo ' edit' a: library . getline (' .' )
99
+ endfunction
100
+
80
101
" "
81
102
" The current library in use.
82
- function ! s: GetCurrentLibrary ()
103
+ function ! s: GetCurrentLibrary () abort
83
104
if ! exists (' g:noteworthy_libraries' )
84
105
call s: Error (" 'g:noteworthy_libraries' is not set!" )
85
106
return 0
@@ -153,7 +174,7 @@ function! s:GetFormattedTitle(title) abort
153
174
return ' # ' . substitute (a: title , ' \<.' , ' \u&' , ' g' )
154
175
endfunction
155
176
156
- function s: Deprecated (from, to ) abort
177
+ function ! s: Deprecated (from, to ) abort
157
178
call s: Warn (a: from . ' is deprecated. Use ' . a: to . ' instead.' )
158
179
endfunction
159
180
0 commit comments