41 lines
1.7 KiB
VimL
41 lines
1.7 KiB
VimL
" Put all notes of the given tag to the location list. The search argument may be
|
|
" empty. For improving search, white spaces are replaced by the * |wildcard|.
|
|
function denote#notes#list(search)
|
|
let l:s = substitute(' ' .. a:search .. ' ', ' ', '*', 'g')
|
|
let l:files = glob(g:denote_directory .. '/' .. l:s, 0, v:true)
|
|
let l:title = 'Denote notes search:' .. a:search
|
|
call denote#loclist#fill(l:title, l:files)
|
|
endfunction
|
|
|
|
" Put all notes of the given tag to the location list. The tag argument is
|
|
" mandatory.
|
|
function denote#notes#bytag(tag)
|
|
let l:files = glob(g:denote_directory .. '/*_' .. a:tag .. '*', 0, v:true)->filter('v:val->split("/")[-1] =~ "_' .. a:tag .. '\\(==\\|@@\\|__\\|_\\|\\.\\)"')
|
|
let l:title = 'Denote notes: ' .. a:tag
|
|
call denote#loclist#fill(l:title, l:files)
|
|
endfunction
|
|
|
|
" Search in denote notes
|
|
function denote#notes#grep(re)
|
|
let l:title = 'Grep results for: ' .. a:re
|
|
let l:fpat=map(copy(g:denote_note_file_extensions), {_, e -> g:denote_directory .. '/*.' .. e})->join()
|
|
execute 'silent! lvimgrep ' .. a:re .. ' ' .. l:fpat
|
|
call denote#loclist#setgrep(l:title)
|
|
endfunction
|
|
|
|
" This creates a new denote entry with the given title and of the given
|
|
" filetype. The title may be empty.
|
|
function denote#notes#new(title, ft=g:denote_new_ft)
|
|
let l:identifier=denote#meta#identifier_generate()
|
|
let l:fn=l:identifier .. '--' .. a:title
|
|
\ ->tolower()
|
|
\ ->substitute('[^[:fname:]]\|/', '-', 'g')
|
|
\ ->substitute('-\+', '-', 'g')
|
|
\ ->substitute('_\+', '_', 'g')
|
|
\ ->substitute('=\+', '=', 'g')
|
|
\ ->substitute('@\+', '@', 'g')
|
|
\ ->trim('-_@=') .. '.' .. a:ft
|
|
execute 'edit ' .. g:denote_directory .. '/' .. l:fn
|
|
call setline(1, denote#frontmatter#new(a:ft, l:identifier, a:title))
|
|
endfunction
|