Created
August 30, 2016 14:05
-
-
Save artumi-richard/f5545b104e97a9ae444404d9b98f4b95 to your computer and use it in GitHub Desktop.
.vimrc function for VimWIki Thunderlink
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is only a partial .vimrc !