refacotred and split
This commit is contained in:
40
autoload/denote/notes.vim
Normal file
40
autoload/denote/notes.vim
Normal file
@@ -0,0 +1,40 @@
|
||||
" 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 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 fpat=map(copy(g:denote_note_file_extensions), {_, e -> g:denote_directory .. "/*." .. e})->join()
|
||||
execute "silent! lvimgrep " .. a:re .. " " .. 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 identifier=denote#meta#identifier_generate()
|
||||
let fn=identifier .. '--' .. a:title
|
||||
\ ->tolower()
|
||||
\ ->substitute('[^[:fname:]]\|/', '-', 'g')
|
||||
\ ->substitute('-\+', '-', 'g')
|
||||
\ ->substitute('_\+', '_', 'g')
|
||||
\ ->substitute('=\+', '=', 'g')
|
||||
\ ->substitute('@\+', '@', 'g')
|
||||
\ ->trim('-_@=') .. '.' .. a:ft
|
||||
execute "edit " .. g:denote_directory .. "/" .. fn
|
||||
call setline(1, denote#frontmatter#new(a:ft, identifier, a:title))
|
||||
endfunction
|
||||
Reference in New Issue
Block a user