Skip to content

Commit

Permalink
fix(uri): don't use full path for custom schema
Browse files Browse the repository at this point in the history
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 <neovim/nvim-lspconfig#2005> `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
  • Loading branch information
sigmaSd authored Aug 14, 2022
1 parent b1faf5f commit 3705519
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions runtime/lua/vim/uri.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3705519

Please sign in to comment.