diff options
author | Alessandro Pezzoni <alessandro.pezzoni@runbox.com> | 2021-07-07 23:34:22 +0100 |
---|---|---|
committer | Alessandro Pezzoni <alessandro.pezzoni@runbox.com> | 2021-07-10 18:27:37 +0100 |
commit | a2c2a086528d74bb0f6b2b68745b015f22ddd68a (patch) | |
tree | eecb6870c3382f3e83836f773de98973b445e4f4 /runtime/lua/vim/uri.lua | |
parent | 4547137aaff32b20172870a549d3a28a3c7adf1c (diff) | |
download | rneovim-a2c2a086528d74bb0f6b2b68745b015f22ddd68a.tar.gz rneovim-a2c2a086528d74bb0f6b2b68745b015f22ddd68a.tar.bz2 rneovim-a2c2a086528d74bb0f6b2b68745b015f22ddd68a.zip |
fix(lsp): accept file URIs without a hostname
RFC 8089, which defines the file URI scheme, also allows URIs without a
hostname, i.e. of the form file:/path/to/file. These are returned by
some language servers and accepted by other LSP implementations, such as
VSCode's, so it is reasonable for us to accept them as well.
Diffstat (limited to 'runtime/lua/vim/uri.lua')
-rw-r--r-- | runtime/lua/vim/uri.lua | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/runtime/lua/vim/uri.lua b/runtime/lua/vim/uri.lua index f1a12c72ec..b7805e0cae 100644 --- a/runtime/lua/vim/uri.lua +++ b/runtime/lua/vim/uri.lua @@ -52,7 +52,7 @@ end --@private local function is_windows_file_uri(uri) - return uri:match('^file:///[a-zA-Z]:') ~= nil + return uri:match('^file:/+[a-zA-Z]:') ~= nil end --- Get a URI from a file path. @@ -74,7 +74,7 @@ local function uri_from_fname(path) return table.concat(uri_parts) end -local URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*)://.*' +local URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*):/+.*' --- Get a URI from a bufnr --@param bufnr (number): Buffer number @@ -100,10 +100,10 @@ local function uri_to_fname(uri) uri = uri_decode(uri) -- TODO improve this. if is_windows_file_uri(uri) then - uri = uri:gsub('^file:///', '') + uri = uri:gsub('^file:/+', '') uri = uri:gsub('/', '\\') else - uri = uri:gsub('^file://', '') + uri = uri:gsub('^file:/+', '/') end return uri end |