Repository: neovim
Issue: Buffer name with scheme containing numbers or + is treated as relative `file` scheme by `vim.uri_from_bufnr`
Labels: bug,filesystem,editor

# Problem

When trying out a scheme with non-alphabetic characters, it appears that the uri of the buffer gets translated into a relative path that gets resolved into an absolute path. Calls to functions like `vim.uri_from_bufnr` will prepend an absolute path to the name, breaking a variety of logic (e.g. `myscheme://hellotxt` becomes `file://path/to/myscheme1234://hello.txt`).

According to [RFC 2396](http://www.ietf.org/rfc/rfc2396.txt), Appendix A:

> scheme        = alpha *( alpha | digit | "+" | "-" | "." )

The scheme should start with a letter (upper or lower case), and can contains letters (still upper and lower case), number, "+", "-" and ".".

It appears that providing characters other than alphabetic (numbers, +, etc) will cause issues. Happens with `nvim -u NONE`.

# Steps to reproduce

### Step 1: Test `vim.uri_from_bufnr` using regular name

Open a fresh buffer and set its name to the relative path of "hello.txt":

```lua
vim.api.nvim_buf_set_name(0, 'hello.txt')
```

Print out the uri to observe the default is to include both the `file` scheme and provide an absolute path relative to the `cwd` of neovim:

```lua
-- Prints file:///path/to/hello.txt
-- where /path/to is the cwd
print(vim.uri_from_bufnr(0))
```

### Step 2: Test `vim.uri_from_bufnr` using alphabetic scheme

Set the buffer name to some scheme with just alphabetic characters like `distant`:

```lua
vim.api.nvim_buf_set_name(0, 'distant://hello.txt')
```

Print out the uri to observe that a scheme is detected and properly used:

```lua
-- Prints distant://hello.txt
print(vim.uri_from_bufnr(0))
```

### Step 3: Test `vim.uri_from_bufnr` using alphabetic scheme that includes +, number, or some combination

Set the buffer name to some scheme with a `+` character in the middle like `distant+1234`:

```lua
vim.api.nvim_buf_set_name(0, 'distant+1234://hello.txt')
```

Print out the uri to observe that a scheme is not properly detected and an absolute path is still provided:

```lua
-- Prints file:///path/to/distant+1234://hello.txt
-- where /path/to is the cwd
print(vim.uri_from_bufnr(0))
```

Note that you can remove the + and just include numbers AFTER the first letter have have the same issue.

# Expected behavior

Setting the buffer name to something like `distant+1234://hello.txt` should not result in functions like `vim.uri_from_bufnr` treating them like a relative file path with a scheme of `file`.

### Step 3: Test `vim.uri_from_bufnr` using alphabetic scheme that includes +, number, or some combination

Set the buffer name to some scheme with a `+` character in the middle like `distant+1234`:

```lua
vim.api.nvim_buf_set_name(0, 'distant+1234://hello.txt')
```

Print out the uri to observe that it is respected:

```lua
-- Prints distant+1234://hello.txt
print(vim.uri_from_bufnr(0))
```

# System Details

### Neovim version (nvim -v)

0.9.0

### Vim (not Nvim) behaves the same?

No, vim works using `:file` and `:echo bufname()`.

VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Aug 17 2022 21:21:22)

```vim
" Prints out distant://hello.txt
:file distant://hello.txt
:echo bufname()

" Prints out distant+1234://hello.txt
:file distant+1234://hello.txt
:echo bufname()
```

### Operating system/version

macOS 12.6

### Terminal name/version

wezterm 20221119-145034-49b9839f

### $TERM environment variable

xterm-256color

### Installation

homebrew