dirvish.vim 842 B

123456789101112131415161718192021
  1. if 'dirvish' !=# get(b:, 'current_syntax', 'dirvish')
  2. finish
  3. endif
  4. let s:sep = exists('+shellslash') && !&shellslash ? '\\' : '/'
  5. let s:escape = 'substitute(escape(v:val, ".$~"), "*", ".*", "g")'
  6. " Define once (per buffer).
  7. if !exists('b:current_syntax')
  8. exe 'syntax match DirvishPathHead =.*'.s:sep.'\ze[^'.s:sep.']\+'.s:sep.'\?$= conceal'
  9. exe 'syntax match DirvishPathTail =[^'.s:sep.']\+'.s:sep.'$='
  10. exe 'syntax match DirvishSuffix =[^'.s:sep.']*\%('.join(map(split(&suffixes, ','), s:escape), '\|') . '\)$='
  11. endif
  12. " Define (again). Other windows (different arglists) need the old definitions.
  13. " Do these last, else they may be overridden (see :h syn-priority).
  14. for s:p in argv()
  15. exe 'syntax match DirvishArg ,'.escape(fnamemodify(s:p,':p'),'[,*.^$~\').'$, contains=DirvishPathHead'
  16. endfor
  17. let b:current_syntax = 'dirvish'