Files
vim-denote/autoload/denote/ft.vim
2026-02-26 14:20:03 +01:00

48 lines
1.5 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()
let l:context = getloclist(0, {'context': 1})['context']
if type(l:context) != v:t_dict || !has_key(l:context, 'denote')
" Clear settings
set spell<
nmapclear <buffer>
return
endif
setlocal nospell
nnoremap <buffer> q :lclose<CR>
if has_key(l:context, 'gfun')
nnoremap <buffer> <silent> r :call denote#loclist#reload()<CR>
endif
" Denote-list specific configuration
" if l:context == 'denote-list'
" call denote#commands#loadll()
" endif
endfunction