From 3705519825c0918cafcdf801ebf609cf2959ccd2 Mon Sep 17 00:00:00 2001 From: sigmaSd Date: Sun, 14 Aug 2022 15:39:04 +0100 Subject: [PATCH] fix(uri): don't use full path for custom schema deno lsp uses a custom schema `deno:` `uri_from_bufnr` returns the full path of the buf file but this doesn't work with custom schema This fixes the last remaining bug here `relative dependencies inside virtual text document is not resolved correctly` Notes: - maybe `if relative_name:match("deno:")` should become `if is_custom_schema(realtive_name)` where is_custom_schema matches `URI_SCHEME_PATTERN` but is not equal to `file:///` - this changes fixes all my issues with denols (with some minor modifications that I can pr later) This is more to start a discussion I thought showing code is easier to discuss then raising an issue --- runtime/lua/vim/uri.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/runtime/lua/vim/uri.lua b/runtime/lua/vim/uri.lua index d6b0b7410eb94f..201c2be9a7c867 100644 --- a/runtime/lua/vim/uri.lua +++ b/runtime/lua/vim/uri.lua @@ -83,6 +83,14 @@ local WINDOWS_URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9.+-]*):[a-zA-Z]:.*' ---@param bufnr number ---@return string URI local function uri_from_bufnr(bufnr) + local relative_name + vim.api.nvim_buf_call(bufnr, function() + relative_name = vim.api.nvim_exec(":echo @%", true) + end) + if relative_name:match("deno:") then + return relative_name + end + local fname = vim.api.nvim_buf_get_name(bufnr) local volume_path = fname:match('^([a-zA-Z]:).*') local is_windows = volume_path ~= nil