@@ -27,6 +27,7 @@ let s:dirvish_git_highlight_groups = {
27
27
\ ' Unknown' : ' DirvishGitModified'
28
28
\ }
29
29
30
+ let s: sep = exists (' +shellslash' ) && ! &shellslash ? ' \' : ' /'
30
31
let s: git_files = {}
31
32
32
33
function ! dirvish_git#init () abort
@@ -55,18 +56,18 @@ function! dirvish_git#init() abort
55
56
let l: them = l: data [2 ]
56
57
let l: file = l: data [3 ]
57
58
58
- if index ( argv (), l: file ) > -1
59
+ if s: is_in_arglist ( l: file )
59
60
continue
60
61
endif
61
62
62
63
let l: file = fnamemodify (l: file , ' :p' )
63
- let l: file = matchstr (l: file , escape (l: current_dir .' [^/]*/ \?' , ' ./ ' ))
64
+ let l: file = matchstr (l: file , escape (l: current_dir .' [^' . s: sep . ' ]* ' . s: sep . ' \?' , ' .' . s: sep ))
64
65
65
66
if index (values (s: git_files ), l: file ) > -1
66
67
continue
67
68
endif
68
69
69
- let l: line_number = search (escape (l: file , ' ./ ' ), ' n' )
70
+ let l: line_number = search (escape (l: file , ' .' . s: sep ), ' n' )
70
71
let s: git_files [l: line_number ] = l: file
71
72
72
73
if isdirectory (l: file )
@@ -114,9 +115,9 @@ function! s:get_highlight_group(us, them, is_directory) abort
114
115
endfunction
115
116
116
117
function ! s: highlight_file (dir , file_name, us, them, is_directory) abort
117
- let l: file_rgx = escape (printf (' \(%s\)\@<=/%s ' , a: dir , a: file_name ), ' ./' )
118
- let l: dir_rgx = escape (printf (' %s\(/%s \)\@=' , a: dir , a: file_name ), ' ./' )
119
- let l: slash_rgx = escape (printf (' \(%s\)\@<=/ \(%s\)\@=' , a: dir , a: file_name ), ' ./' )
118
+ let l: file_rgx = escape (printf (' \(%s\)\@<=%s%s ' , a: dir, s: sep , a: file_name ), ' ./' )
119
+ let l: dir_rgx = escape (printf (' %s\(%s%s \)\@=' , a: dir, s: sep , a: file_name ), ' ./' )
120
+ let l: slash_rgx = escape (printf (' \(%s\)\@<=%s \(%s\)\@=' , a: dir, s: sep , a: file_name ), ' ./' )
120
121
121
122
silent exe ' syn match DirvishGitDir "' .l: dir_rgx .' " conceal cchar=' .s: get_indicator (a: us , a: them )
122
123
silent exe ' syn match ' .s: get_highlight_group (a: us , a: them , a: is_directory ).' "' .l: file_rgx .' " contains=DirvishGitSlash'
@@ -138,14 +139,27 @@ function! s:setup_highlighting() abort
138
139
silent exe ' hi default DirvishGitUntracked guifg=NONE guibg=NONE gui=NONE cterm=NONE ctermfg=NONE ctermbg=NONE'
139
140
endfunction
140
141
142
+ function s: is_in_arglist (file ) abort
143
+ let l: file = fnamemodify (a: file , ' :p' )
144
+ let l: cwd = printf (' %s%s' , getcwd (), s: sep )
145
+ for l: arg in argv ()
146
+ if l: arg == # l: cwd
147
+ continue
148
+ endif
149
+ if l: file = ~? l: arg
150
+ return 1
151
+ endif
152
+ endfor
153
+ return 0
154
+ endfunction
155
+
141
156
function ! dirvish_git#jump_to_next_file () abort
142
157
if len (s: git_files ) <=? 0
143
158
return
144
159
endif
145
160
146
161
let l: current_line = line (' .' )
147
162
let l: git_files_line_number = sort (keys (s: git_files ), ' N' )
148
- echo l: git_files_line_number
149
163
150
164
for l: line in l: git_files_line_number
151
165
if l: line > l: current_line
@@ -175,7 +189,7 @@ endfunction
175
189
176
190
function ! dirvish_git#reload () abort
177
191
if &filetype == ? ' dirvish' && len (s: git_files ) > 0
178
- Dirvish %
192
+ call feedkeys ( ' R ' )
179
193
endif
180
194
endfunction
181
195
0 commit comments