fix: handle non-file uris for lsp (#2604)
This commit is contained in:
@@ -53,7 +53,12 @@ lsp.references = function(opts)
|
|||||||
local location = locations[1]
|
local location = locations[1]
|
||||||
local bufnr = opts.bufnr
|
local bufnr = opts.bufnr
|
||||||
if location.filename then
|
if location.filename then
|
||||||
bufnr = vim.uri_to_bufnr(vim.uri_from_fname(location.filename))
|
local uri = location.filename
|
||||||
|
if not utils.is_uri(uri) then
|
||||||
|
uri = vim.uri_from_fname(uri)
|
||||||
|
end
|
||||||
|
|
||||||
|
bufnr = vim.uri_to_bufnr(uri)
|
||||||
end
|
end
|
||||||
vim.api.nvim_win_set_buf(0, bufnr)
|
vim.api.nvim_win_set_buf(0, bufnr)
|
||||||
vim.api.nvim_win_set_cursor(0, { location.lnum, location.col - 1 })
|
vim.api.nvim_win_set_cursor(0, { location.lnum, location.col - 1 })
|
||||||
|
|||||||
@@ -173,8 +173,9 @@ utils.is_path_hidden = function(opts, path_display)
|
|||||||
or type(path_display) == "table" and (vim.tbl_contains(path_display, "hidden") or path_display.hidden)
|
or type(path_display) == "table" and (vim.tbl_contains(path_display, "hidden") or path_display.hidden)
|
||||||
end
|
end
|
||||||
|
|
||||||
local is_uri = function(filename)
|
local URI_SCHEME_PATTERN = "^([a-zA-Z]+[a-zA-Z0-9.+-]*):.*"
|
||||||
return string.match(filename, "^%w+://") ~= nil
|
utils.is_uri = function(filename)
|
||||||
|
return filename:match(URI_SCHEME_PATTERN) ~= nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local calc_result_length = function(truncate_len)
|
local calc_result_length = function(truncate_len)
|
||||||
@@ -197,7 +198,7 @@ utils.transform_path = function(opts, path)
|
|||||||
if path == nil then
|
if path == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if is_uri(path) then
|
if utils.is_uri(path) then
|
||||||
return path
|
return path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user