One9398 / vimwiki

Automatically exported from code.google.com/p/vimwiki
0 stars 1 forks source link

Scheme behaviors #338

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Schemes have just been introduced along with other internal re-organizations, 
and developers have been ironing out some of the difficulties.  Vimwiki will 
likely provide better support for schemes in the future.

The discussion in http://code.google.com/p/vimwiki/issues/detail?id=328 has 
raised an interesting point, however.  Consider the provided schemes:

file:   1) requires absolute paths   2) opens resources using system default 
apps
local: 1) requires relative paths   2) opens resources using vim

Perhaps we could provide 4 default schemes: (file:, local:, vfile:, & vlocal:) 
where 'v' stands for open in vim, with the following behaviors:

file:   1) requires absolute paths   2) opens resources using system default 
apps
local: 1) requires relative paths   2) opens resources using system default apps

vfile:   1) requires absolute paths   2) opens resources using vim
vlocal: 1) requires relative paths   2) opens resources using vim

Original issue reported on code.google.com by stu.andrews on 30 May 2012 at 2:25

GoogleCodeExporter commented 8 years ago
I agree, this has to be solved.

Original comment by habamax on 30 May 2012 at 3:01

GoogleCodeExporter commented 8 years ago
I have changed local: behaviour. It opens links using system default apps.

Original comment by habamax on 30 May 2012 at 6:26

GoogleCodeExporter commented 8 years ago
Here's a handler that handles 'vlocal:' and 'vfile:' schemes.  

function! VimwikiLinkHandler(link) "{{{ Use Vim to open links with the
  " 'vlocal:' or 'vfile:' schemes.  E.g.:
  "   1) [[vfile:///~/Code/PythonProject/abc123.py]], and
  "   2) [[vlocal:./|Wiki Home]]
  let link = a:link
  if link =~ "vlocal:" || link =~ "vfile:"
    let link = link[1:]
  else
    return 0
  endif
  let [idx, scheme, path, subdir, lnk, ext, url] = 
       \ vimwiki#base#resolve_scheme(link, 0)
  if g:vimwiki_debug
    echom 'LinkHandler: idx='.idx.', scheme=[v]'.scheme.', path='.path.
         \ ', subdir='.subdir.', lnk='.lnk.', ext='.ext.', url='.url
  endif
  if url == ''
    echom 'Vimwiki Error: Unable to resolve link!'
    return 0
  else
    call vimwiki#base#edit_file('tabnew', url, [], 0)
    return 1
  endif
endfunction " }}}

Original comment by stu.andrews on 31 May 2012 at 2:41

GoogleCodeExporter commented 8 years ago
Including the following line in your vimrc, together with the 
VimwikiLinkHandler defined above, ensures that the vlocal: and vfile: links are 
highlighted as existing links, similar to maxhi=0.

let g:vimwiki_schemes = 'wiki\d\+,diary,local,vlocal,vfile'

Original comment by stu.andrews on 31 May 2012 at 3:22

GoogleCodeExporter commented 8 years ago
Wouldn't it be better to mandatory highlight every link that has scheme as 
existing?
Just to avoid manual g:vimwiki_schemes update?

Original comment by habamax on 31 May 2012 at 3:57

GoogleCodeExporter commented 8 years ago
This four schemes is good.

Original comment by numbch...@gmail.com on 31 May 2012 at 4:47

GoogleCodeExporter commented 8 years ago
@numbchild: keep us informed on how they perform ... we've been known to take 
1-step forward and 2-steps back

@maxim: I agree that updating g:vimwiki_schemes like this is a little technical 
and error prone.  Can you be more specific about your highlighting suggestion?

Since ':' is now a valid filename character, how would we distinguish the file 
[[issue316_:_g]] from the "issue316_"-scheme that is pointing to the file "_g"?

Just to clarify: In my tests with maxhi=1, the link [[vlocal:index.wiki]] was 
highlighted as missing.  Then, by adding the g:vimwiki_schemes lines, it is 
highlighted as existing.

... there is also the idea from 
http://code.google.com/p/vimwiki/source/detail?r=9567e6083b7c

Original comment by stu.andrews on 31 May 2012 at 2:08

GoogleCodeExporter commented 8 years ago
Stuart, I don't know yet. We should think about it. Let us wait with it till 
vimwiki2.0 is released.

Original comment by habamax on 31 May 2012 at 5:07