From 2e0a98bcf88473b6069fe34a71123fc222336bd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Richter?= <3201406+matmatyk@users.noreply.github.com> Date: Tue, 2 Jan 2024 16:29:16 +0000 Subject: [PATCH] Convert file path returned from LSP in Cygwin --- autoload/lsp/util.vim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/autoload/lsp/util.vim b/autoload/lsp/util.vim index eb0a64fb..7620eb47 100644 --- a/autoload/lsp/util.vim +++ b/autoload/lsp/util.vim @@ -85,7 +85,12 @@ export def LspUriToFile(uri: string): string if uri_decoded =~? '^file:///\a:' # MS-Windows URI uri_decoded = uri_decoded[8 : ] - uri_decoded = uri_decoded->substitute('/', '\\', 'g') + if has("win32unix") # we're in Cygwin + # The substitution is to remove the '^@' escape character from the end of line. + uri_decoded = system($'cygpath --unix {uri_decoded}')->substitute('^\(\p*\).*$', '\=submatch(1)', "") + else + uri_decoded = uri_decoded->substitute('/', '\\', 'g') + endif # On GNU/Linux (pattern not end with `:`) elseif uri_decoded =~? '^file:///\a' uri_decoded = uri_decoded[7 : ]