justinmk / vim-dirvish

Directory viewer for Vim :zap:
Other
1.18k stars 64 forks source link

pattern delimiter not found #192

Closed habamax closed 4 years ago

habamax commented 4 years ago

With the recent update I get error opening dirvish:

image

OS: Win10 vim: 8.2.1558 nvim: current nightly

justinmk commented 4 years ago

cc @lxhillwind

habamax commented 4 years ago

with

I don't get errors but also no syntax and no conceal:

image

PS, no errors in WSL vim/nvim.

habamax commented 4 years ago

Okay, you have to escape \ in [^\] as was in previous version. Otherwise for windows closing square bracket is escaped and whole regex confuses vim syntax.

habamax commented 4 years ago
" Define once (per buffer).
if !exists('b:current_syntax')
  exe 'syntax match DirvishPathHead =.*'.s:sep_esc.'\ze[^'.s:sep_esc.']\+'.s:sep_esc.'\?$= conceal'
  exe 'syntax match DirvishPathTail =[^'.s:sep_esc.']\+'.s:sep_esc.'$='
  exe 'syntax match DirvishSuffix   =[^'.s:sep_esc.']*\%('.join(map(split(&suffixes, ','), s:escape), '\|') . '\)$='
endif

This works for me

habamax commented 4 years ago

And having this makes s:sep and s:sep_esc redundant, probably better just escape and use it like this:

let s:sep = escape(exists('+shellslash') && !&shellslash ? '\' : '/', '\\')
let s:escape = 'substitute(escape(v:val, ".$~"), "*", ".*", "g")'

" Define once (per buffer).
if !exists('b:current_syntax')
  exe 'syntax match DirvishPathHead =.*'.s:sep.'\ze[^'.s:sep.']\+'.s:sep.'\?$= conceal'
  exe 'syntax match DirvishPathTail =[^'.s:sep.']\+'.s:sep.'$='
  exe 'syntax match DirvishSuffix   =[^'.s:sep.']*\%('.join(map(split(&suffixes, ','), s:escape), '\|') . '\)$='
endif