Browse Source

vimwiki: open file: links in vim itself

This could probably be improved on.  Maybe with a handler that checks if,
say, Perl thinks it's text and otherwise kicks off to xdg stuff.
main
Brennen Bearnes 11 months ago
parent
commit
ea27567c29
1 changed files with 11 additions and 4 deletions
  1. +11
    -4
      home/.vim/vimrc

+ 11
- 4
home/.vim/vimrc View File

@ -151,7 +151,7 @@ let mapleader = ","
nmap <C-]> <Plug>(fzf_tags)
" }}}
" Distraction-free mode:
" distraction-free mode:
Plugin 'junegunn/goyo.vim'
" preview contents of named registers
@ -354,14 +354,21 @@ let mapleader = ","
" custom link types, etc. Right now all it does is use vim itself
" to handle files, crudely.
function! VimwikiLinkHandler(link)
if a:link =~# 'file:'
if a:link =~# '^file:'
try
" chop off the leading file: - see :h expr-[:] for syntax:
execute ':e ' . a:link[5:]
execute ':split ' . a:link[5:]
return 1
catch
echo "Something went wrong..."
echo "Failed opening file in vim."
endtry
" elseif a:link =~# '^https\?:'
" try
" execute ':terminal lynx ' . a:link
" return 1
" catch
" echo "Failed executing Lynx."
" endtry
endif
return 0
endfunction


Loading…
Cancel
Save