-
-
Notifications
You must be signed in to change notification settings - Fork 958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support msys2 (path format) #3787
Comments
Local validation is correct. Ability to open include files correctly Before modification, 'd:' will be added before the original path, resulting in a wrong path For example: |
Are there any other files besides utils that involve path? diff --git a/autoload/coc/util.vim b/autoload/coc/util.vim
index 95f5fe1..37c4a9b 100644
--- a/autoload/coc/util.vim
+++ b/autoload/coc/util.vim
@@ -3,6 +3,12 @@ let s:root = expand('<sfile>:h:h:h')
let s:is_win = has('win32') || has('win64')
let s:is_vim = !has('nvim')
let s:vim_api_version = 28
+let s:is_msys = has_key(environ(), 'MSYSTEM')
+let s:root_path = ""
+if s:is_msys
+ " remove '/\n'
+ let s:root_path = system('cygpath -m /')[0:-3]
+endif
function! coc#util#api_version() abort
return s:vim_api_version
@@ -33,10 +39,20 @@ function! coc#util#jumpTo(line, character) abort
call coc#cursor#move_to(a:line, a:character)
endfunction
+function! coc#util#path_conversion(path) abort
+ if s:is_msys
+ " remove '\n'
+ let path = system("cygpath -m " . a:path)[0:-2]
+ endif
+ " echom 'cygpath@'. path
+ return path
+endfunction
+
+
function! coc#util#path_replace_patterns() abort
if has('win32unix') && exists('g:coc_cygqwin_path_prefixes')
- echohl WarningMsg
- echon 'g:coc_cygqwin_path_prefixes is deprecated, use g:coc_uri_prefix_replace_patterns instead'
+ echohl WarningMsg
+ echon 'g:coc_cygqwin_path_prefixes is deprecated, use g:coc_uri_prefix_replace_patterns instead'
echohl None
return g:coc_cygqwin_path_prefixes
endif
@@ -249,7 +265,7 @@ function! coc#util#get_bufoptions(bufnr) abort
\ 'filetype': getbufvar(a:bufnr, '&filetype'),
\ 'iskeyword': getbufvar(a:bufnr, '&iskeyword'),
\ 'changedtick': getbufvar(a:bufnr, 'changedtick'),
- \ 'fullpath': empty(bufname) ? '' : fnamemodify(bufname, ':p'),
+ \ 'fullpath': empty(bufname) ? '' : coc#util#path_conversion(fnamemodify(bufname, ':p')),
\}
endfunction
@@ -299,7 +315,7 @@ function! coc#util#preview_info(info, filetype, ...) abort
wincmd p
endfunction
-function! coc#util#get_config_home()
+function! s:get_config_home()
if !empty(get(g:, 'coc_config_home', ''))
return resolve(expand(g:coc_config_home))
endif
@@ -322,6 +338,10 @@ function! coc#util#get_config_home()
endif
endfunction
+function! coc#util#get_config_home()
+ return coc#util#path_conversion(s:get_config_home())
+endfunction
+
function! coc#util#get_data_home()
if !empty(get(g:, 'coc_data_home', ''))
let dir = resolve(expand(g:coc_data_home))
@@ -336,6 +356,7 @@ function! coc#util#get_data_home()
endif
endif
endif
+ let dir = coc#util#path_conversion(dir)
if !isdirectory(dir)
call coc#float#create_notification(['creating data directory: '.dir], {'timeout': 2000})
call mkdir(dir, "p", 0755)
@@ -364,7 +385,7 @@ function! coc#util#get_complete_option()
\ 'input': empty(input) ? '' : input,
\ 'line': line,
\ 'filetype': &filetype,
- \ 'filepath': expand('%:p'),
+ \ 'filepath': coc#util#path_conversion(expand('%:p')),
\ 'bufnr': bufnr('%'),
\ 'linenr': pos[1],
\ 'colnr' : pos[2],
@@ -536,6 +557,8 @@ function! coc#util#getpid()
endfunction
function! coc#util#vim_info()
+ let l:runtimepath = join(map(globpath(&runtimepath, "", 0, 1), {key,path->s:root_path.path}), ',')
+
return {
\ 'apiversion': s:vim_api_version,
\ 'mode': mode(),
@@ -558,9 +581,9 @@ function! coc#util#vim_info()
\ 'colorscheme': get(g:, 'colors_name', ''),
\ 'workspaceFolders': get(g:, 'WorkspaceFolders', v:null),
\ 'background': &background,
- \ 'runtimepath': join(globpath(&runtimepath, '', 0, 1), ','),
+ \ 'runtimepath': l:runtimepath,
\ 'locationlist': get(g:,'coc_enable_locationlist', 1),
- \ 'progpath': v:progpath,
+ \ 'progpath': coc#util#path_conversion(v:progpath),
\ 'guicursor': &guicursor,
\ 'tabCount': tabpagenr('$'),
\ 'updateHighlight': has('nvim-0.5.0') || has('patch-8.1.1719') ? v:true : v:false,
|
Yes! please can we do this. I've just realized that my cygwin |
Of course, it's just that I don't know if I have modified all the path-related functions (all in utils.vim), which needs to be confirmed by the developer. Although I use normal :) |
Because msys simulates the linux environment, the path format used in msys is the same as the linux path format.
But there is a path conversion tool in msys2
cygpath -m /home/name/path
=>D:/msys64_install_path/home/name/path
just need to slightly modified
About the MSYSTEM :https://www.msys2.org/docs/environments/
The text was updated successfully, but these errors were encountered: