@@ -72,7 +72,7 @@ function! s:encode_uri(path, start_pos_encode, default_prefix) abort
72
72
endfunction
73
73
74
74
let s: path_to_uri_cache = {}
75
- if has (' win32' ) || has (' win64' )
75
+ if has (' win32' ) || has (' win64' ) || has ( ' win32unix ' )
76
76
function ! lsp#utils#path_to_uri (path ) abort
77
77
if has_key (s: path_to_uri_cache , a: path )
78
78
return s: path_to_uri_cache [a: path ]
@@ -82,16 +82,22 @@ if has('win32') || has('win64')
82
82
let s: path_to_uri_cache [a: path ] = a: path
83
83
return s: path_to_uri_cache [a: path ]
84
84
else
85
+ " Transform cygwin paths to windows paths
86
+ let l: path = a: path
87
+ if has (' win32unix' )
88
+ let l: path = substitute (a: path , ' \c^/\([a-z]\)/' , ' \U\1:/' , ' ' )
89
+ endif
90
+
85
91
" You must not encode the volume information on the path if
86
92
" present
87
- let l: end_pos_volume = matchstrpos (a : path , ' \c[A-Z]:' )[2 ]
93
+ let l: end_pos_volume = matchstrpos (l : path , ' \c[A-Z]:' )[2 ]
88
94
89
95
if l: end_pos_volume == -1
90
96
let l: end_pos_volume = 0
91
97
endif
92
98
93
- let s: path_to_uri_cache [a : path ] = s: encode_uri (substitute (a : path , ' \' , ' /' , ' g' ), l: end_pos_volume , ' file:///' )
94
- return s: path_to_uri_cache [a : path ]
99
+ let s: path_to_uri_cache [l : path ] = s: encode_uri (substitute (l : path , ' \' , ' /' , ' g' ), l: end_pos_volume , ' file:///' )
100
+ return s: path_to_uri_cache [l : path ]
95
101
endif
96
102
endfunction
97
103
else
@@ -111,13 +117,21 @@ else
111
117
endif
112
118
113
119
let s: uri_to_path_cache = {}
114
- if has (' win32' ) || has (' win64' )
120
+ if has (' win32' ) || has (' win64' ) || has ( ' win32unix ' )
115
121
function ! lsp#utils#uri_to_path (uri) abort
116
122
if has_key (s: uri_to_path_cache , a: uri )
117
123
return s: uri_to_path_cache [a: uri ]
118
124
endif
119
125
120
- let s: uri_to_path_cache [a: uri ] = substitute (s: decode_uri (a: uri [len (' file:///' ):]), ' /' , ' \\' , ' g' )
126
+ let l: path = substitute (s: decode_uri (a: uri [len (' file:///' ):]), ' /' , ' \\' , ' g' )
127
+
128
+ " Transform windows paths to cygwin paths
129
+ if has (' win32unix' )
130
+ let l: path = substitute (l: path , ' \c^\([A-Z]\):\\' , ' /\l\1/' , ' ' )
131
+ let l: path = substitute (l: path , ' \\' , ' /' , ' g' )
132
+ endif
133
+
134
+ let s: uri_to_path_cache [a: uri ] = l: path
121
135
return s: uri_to_path_cache [a: uri ]
122
136
endfunction
123
137
else
0 commit comments