Skip to content

Commit 1b74fd8

Browse files
committed
Add way to visualize library
1 parent bc7eddf commit 1b74fd8

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

autoload/noteworthy.vim

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ endfunction
3030

3131
""
3232
" Completion for :Note.
33-
function! noteworthy#Completion(arg_lead, cmd_line, cursor_pos) abort
33+
function! noteworthy#Completion(...) abort
3434
let l:fext = get(g:, 'noteworthy_ambiguous', 0) ? '*' : s:GetNoteFileExt()
3535
let l:dir = s:GetCurrentLibrary()
3636
if !isdirectory(l:dir) | return '' | endif
@@ -75,8 +75,22 @@ function! noteworthy#Delimiter(...) abort
7575
\ get(g:, 'noteworthy_delimiter', s:GetNoteDelimiter()) . '"'
7676
endfunction
7777

78+
""
79+
" I don't know what I'm doing :(
80+
function! noteworthy#Visualize() abort
81+
vert split '__NOTES__'
82+
let l:files = split(noteworthy#Completion(), "\n")
83+
call append(0, l:files)
84+
setlocal readonly
85+
nnoremap <buffer> <CR> call s:Open()
86+
endfunction
87+
7888
" PRIVATE API
7989

90+
function! s:Open() abort
91+
execute 'edit' s:GetCurrentLibrary() . getline('.')<CR>
92+
endfunction
93+
8094
""
8195
" The current library in use.
8296
function! s:GetCurrentLibrary()

plugin/noteworthy.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,5 @@ command! -nargs=0 NoteAmbiguousDisable let g:noteworthy_ambiguous = 0
5252
" :NoteDelimiter [{delimiter}]
5353
" Show or change the current delimiter.
5454
command! -nargs=? NoteDelimiter call noteworthy#Delimiter(<f-args>)
55+
56+
command! -nargs=0 NoteVisualize call noteworthy#Visualize()

0 commit comments

Comments
 (0)