Skip to content

Commit 4d4e707

Browse files
authored
handle backslash in pathname #190
fixes #189
1 parent b136fd2 commit 4d4e707

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

autoload/dirvish.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ endif
5353

5454
function! s:list_dir(dir) abort
5555
" Escape for glob().
56-
let dir_esc = escape(substitute(a:dir,'\[','[[]','g'),'{}^$')
56+
let dir_esc = escape(substitute(a:dir,'\[','[[]','g'),'{}^$\')
5757
let paths = s:globlist(dir_esc.'*')
5858
"Append dot-prefixed files. glob() cannot do both in 1 pass.
5959
let paths = paths + s:globlist(dir_esc.'.[^.]*')

ftplugin/dirvish.vim

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ endif
44
let b:did_ftplugin = 1
55

66
let s:nowait = (v:version > 703 ? '<nowait>' : '')
7+
let s:sep = exists('+shellslash') && !&shellslash ? '\' : '/'
78

89
if !hasmapto('<Plug>(dirvish_quit)', 'n')
910
execute 'nmap '.s:nowait.'<buffer> q :echohl WarningMsg<Bar>echo "q is deprecated, use gq instead"<Bar>echohl NONE<cr>'
@@ -48,8 +49,13 @@ execute 'nnoremap <expr>'.s:nowait.'<buffer> . ":<C-u>".(v:count ? "Shdo".(v:cou
4849
execute 'xnoremap <expr>'.s:nowait.'<buffer> . ":Shdo".(v:count?"!":" ")." {}<Left><Left><Left>"'
4950

5051
" Buffer-local / and ? mappings to skip the concealed path fragment.
51-
nnoremap <buffer> / /\ze[^\/]*[\/]\=$<Home>
52-
nnoremap <buffer> ? ?\ze[^\/]*[\/]\=$<Home>
52+
if s:sep == '\'
53+
nnoremap <buffer> / /\ze[^\/]*[\/]\=$<Home>
54+
nnoremap <buffer> ? ?\ze[^\/]*[\/]\=$<Home>
55+
else
56+
nnoremap <buffer> / /\ze[^/]*[/]\=$<Home>
57+
nnoremap <buffer> ? ?\ze[^/]*[/]\=$<Home>
58+
endif
5359

5460
" Force autoload if `ft=dirvish`
5561
if !exists('*dirvish#open')|try|call dirvish#open()|catch|endtry|endif

syntax/dirvish.vim

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ if 'dirvish' !=# get(b:, 'current_syntax', 'dirvish')
33
endif
44

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

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

1516
" Define (again). Other windows (different arglists) need the old definitions.

0 commit comments

Comments
 (0)