40 lines
1.2 KiB
VimL
40 lines
1.2 KiB
VimL
" Go to file command |gf| adjustments
|
|
" This resolves denote links. The function has access to the variable v:fname,
|
|
" which corresponds to the filename under the cursor.
|
|
function s:gotofile()
|
|
return v:fname !~ '^denote:'
|
|
\ ? v:fname
|
|
\ : denote#meta#fileFromNoteId(v:fname[7:]) ?? v:fname
|
|
endfunction
|
|
|
|
" Denote note specifics
|
|
function denote#ft#denote()
|
|
if expand('%:p:h') != g:denote_directory
|
|
return
|
|
endif
|
|
" Link completion
|
|
setlocal omnifunc=denote#completion#get
|
|
" Denote links are of the form 'denote:<note id>'; we require the column.
|
|
setlocal isfname+=:
|
|
" Set the function to resolve the filename under the cursor (see |gf|).
|
|
setlocal includeexpr=s:gotofile()
|
|
" Back references command
|
|
let l:noteid = denote#meta#noteIdFromFile(expand('%:t'))
|
|
exe 'command! DenoteBackReferences DenoteGrep /\<denote:' .. l:noteid .. '\>/gj'
|
|
endfunction
|
|
|
|
" Location-list specifics
|
|
"
|
|
" This will be called for every location and quickfix, when data is loaded into
|
|
" the list. This does nothing for such lists that are note 'denote' lists.
|
|
function denote#ft#qf()
|
|
if getloclist(0, {'context': 1})['context'] != 'denote'
|
|
" Clear settings
|
|
set spell<
|
|
nmapclear <buffer>
|
|
return
|
|
endif
|
|
setlocal nospell
|
|
nnoremap <buffer> q :lclose<CR>
|
|
endfunction
|