Skip to content

Commit b524b2d

Browse files
author
skywind3000
committed
minor update
1 parent 9f5b4ec commit b524b2d

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

autoload/asyncrun/compat.vim

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"======================================================================
2+
"
3+
" compat.vim -
4+
"
5+
" Created by skywind on 2023/08/03
6+
" Last Modified: 2023/08/03 23:45:25
7+
"
8+
"======================================================================
9+
10+
11+
"----------------------------------------------------------------------
12+
" glob files
13+
"----------------------------------------------------------------------
14+
function! asyncrun#compat#glob( ... )
15+
let l:nosuf = (a:0 > 1 && a:2)
16+
let l:list = (a:0 > 2 && a:3)
17+
if l:nosuf
18+
let l:save_wildignore = &wildignore
19+
set wildignore=
20+
endif
21+
try
22+
let l:result = call('glob', [a:1])
23+
return (l:list ? split(l:result, '\n') : l:result)
24+
finally
25+
if exists('l:save_wildignore')
26+
let &wildignore = l:save_wildignore
27+
endif
28+
endtry
29+
endfunc
30+
31+
32+
"----------------------------------------------------------------------
33+
" list files
34+
"----------------------------------------------------------------------
35+
function! asyncrun#compat#list(path, ...)
36+
let nosuf = (a:0 > 0)? (a:1) : 0
37+
if !isdirectory(a:path)
38+
return []
39+
endif
40+
let path = a:path . '/*'
41+
let part = asyncrun#compat#glob(path, nosuf)
42+
let candidate = []
43+
for n in split(part, "\n")
44+
let f = fnamemodify(n, ':t')
45+
if !empty(f)
46+
let candidate += [f]
47+
endif
48+
endfor
49+
return candidate
50+
endfunc
51+
52+

autoload/asyncrun/utils.vim

+22
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
" vim: set ts=4 sw=4 tw=78 noet :
1111

1212

13+
"----------------------------------------------------------------------
14+
" internal
15+
"----------------------------------------------------------------------
16+
let s:windows = has('win32') || has('win95') || has('win64') || has('win16')
17+
18+
1319
"----------------------------------------------------------------------
1420
" output msg
1521
"----------------------------------------------------------------------
@@ -129,4 +135,20 @@ function! asyncrun#utils#quickfix_request()
129135
endfunc
130136

131137

138+
"----------------------------------------------------------------------
139+
" compare path
140+
"----------------------------------------------------------------------
141+
function! asyncrun#utils#path_equal(path1, path2) abort
142+
let p1 = fnamemodify(a:path1, ':p')
143+
let p2 = fnamemodify(a:path2, ':p')
144+
if has('win32') || has('win16') || has('win64') || has('win95')
145+
let p1 = tolower(substitute(p1, '\/', '\\', 'g'))
146+
let p2 = tolower(substitute(p2, '\/', '\\', 'g'))
147+
else
148+
let p1 = substitute(p1, '\\', '\/', 'g')
149+
let p2 = substitute(p2, '\\', '\/', 'g')
150+
endif
151+
return (p1 == p2)? 1 : 0
152+
endfunc
153+
132154

0 commit comments

Comments
 (0)