@@ -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,18 @@ 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
48
return
49
49
endif
50
- call s: GetCurrentLibrary ()
50
+ let l: lib = s: GetCurrentLibrary ()
51
51
echo ' Current library is set to "' . g: noteworthy_current_library . ' "'
52
+ if a: visualize | call s: Visualize (l: lib ) | endif
52
53
endfunction
53
54
54
- " "
55
+ " "{{{
55
56
" Get or set the extension to use for notes.
56
57
function ! noteworthy#Extension (... ) abort
57
58
if a: 0
@@ -74,12 +75,30 @@ function! noteworthy#Delimiter(...) abort
74
75
echo ' Current delimiter is set to "' .
75
76
\ get (g: , ' noteworthy_delimiter' , s: GetNoteDelimiter ()) . ' "'
76
77
endfunction
77
-
78
+ " }}}
78
79
" PRIVATE API
79
80
81
+ " "
82
+ " TODO Getting closer. The files just don't open when you hit they key.
83
+ " Also, is Netrw just used for stuff like this? Should I not be trying to do
84
+ " this manually?
85
+ function ! s: Visualize (library) abort
86
+ vsplit
87
+ setlocal buftype = nofile
88
+ setlocal modifiable
89
+ let l: files = split (noteworthy#Completion (), " \n " )
90
+ call append (0 , l: files )
91
+ nnoremap <buffer> o call notheworthy#Open(a:library)
92
+ setlocal nomodifiable
93
+ endfunction
94
+
95
+ function ! noteworthy#Open (library) abort
96
+ echo ' edit' a: library . getline (' .' )
97
+ endfunction
98
+
80
99
" "
81
100
" The current library in use.
82
- function ! s: GetCurrentLibrary ()
101
+ function ! s: GetCurrentLibrary () abort
83
102
if ! exists (' g:noteworthy_libraries' )
84
103
call s: Error (" 'g:noteworthy_libraries' is not set!" )
85
104
return 0
@@ -153,7 +172,7 @@ function! s:GetFormattedTitle(title) abort
153
172
return ' # ' . substitute (a: title , ' \<.' , ' \u&' , ' g' )
154
173
endfunction
155
174
156
- function s: Deprecated (from, to ) abort
175
+ function ! s: Deprecated (from, to ) abort
157
176
call s: Warn (a: from . ' is deprecated. Use ' . a: to . ' instead.' )
158
177
endfunction
159
178
0 commit comments