Skip to content

Instantly share code, notes, and snippets.

@artumi-richard
Created August 30, 2016 14:05
Show Gist options
  • Save artumi-richard/f5545b104e97a9ae444404d9b98f4b95 to your computer and use it in GitHub Desktop.
Save artumi-richard/f5545b104e97a9ae444404d9b98f4b95 to your computer and use it in GitHub Desktop.
.vimrc function for VimWIki Thunderlink
function! VimwikiLinkHandler(link)
" Use Vim to open external files with the 'vfile:' scheme. E.g.:
" 1) [[vfile:~/Code/PythonProject/abc123.py]]
" 2) [[vfile:./|Wiki Home]]
" And thunder links https://github.com/poohsen/thunderlink
let link = a:link
if link =~# '^thunderlink:'
try
exec "silent !setsid gnome-open \'" . a:link ."\'"
exec 'silent !setsid wmctrl -a Thunderbird'
return 1
catch
echo "Thunder link failure!"
endtry
return 0
endif
if link =~# '^vfile:'
let link = link[1:]
else
return 0
endif
let link_infos = vimwiki#base#resolve_link(link)
if link_infos.filename == ''
echomsg 'Vimwiki Error: Unable to resolve link!'
return 0
else
exe 'tabnew ' . fnameescape(link_infos.filename)
return 1
endif
endfunction
@artumi-richard
Copy link
Author

This is only a partial .vimrc !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment