mirror of
https://github.com/neovim/neovim.git
synced 2024-12-25 05:35:10 -07:00
fix(uri): use valid EmmyLua annotations (#16359)
See: - https://emmylua.github.io/annotations/param.html - https://emmylua.github.io/annotations/return.html
This commit is contained in:
parent
722647dd8c
commit
d249e18bbf
@ -1658,40 +1658,38 @@ uri_from_bufnr({bufnr}) *vim.uri_from_bufnr()*
|
|||||||
Get a URI from a bufnr
|
Get a URI from a bufnr
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
{bufnr} (number): Buffer number
|
{bufnr} number
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
URI
|
string URI
|
||||||
|
|
||||||
uri_from_fname({path}) *vim.uri_from_fname()*
|
uri_from_fname({path}) *vim.uri_from_fname()*
|
||||||
Get a URI from a file path.
|
Get a URI from a file path.
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
{path} (string): Path to file
|
{path} string Path to file
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
URI
|
string URI
|
||||||
|
|
||||||
uri_to_bufnr({uri}) *vim.uri_to_bufnr()*
|
uri_to_bufnr({uri}) *vim.uri_to_bufnr()*
|
||||||
Return or create a buffer for a uri.
|
Get the buffer for a uri. Creates a new unloaded buffer if no
|
||||||
|
buffer for the uri already exists.
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
{uri} (string): The URI
|
{uri} string
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
bufnr.
|
number bufnr
|
||||||
|
|
||||||
Note:
|
|
||||||
Creates buffer but does not load it
|
|
||||||
|
|
||||||
uri_to_fname({uri}) *vim.uri_to_fname()*
|
uri_to_fname({uri}) *vim.uri_to_fname()*
|
||||||
Get a filename from a URI
|
Get a filename from a URI
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
{uri} (string): The URI
|
{uri} string
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
Filename
|
string filename or unchanged URI for non-file URIs
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
@ -56,8 +56,8 @@ local function is_windows_file_uri(uri)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Get a URI from a file path.
|
--- Get a URI from a file path.
|
||||||
---@param path (string): Path to file
|
---@param path string Path to file
|
||||||
---@return URI
|
---@return string URI
|
||||||
local function uri_from_fname(path)
|
local function uri_from_fname(path)
|
||||||
local volume_path, fname = path:match("^([a-zA-Z]:)(.*)")
|
local volume_path, fname = path:match("^([a-zA-Z]:)(.*)")
|
||||||
local is_windows = volume_path ~= nil
|
local is_windows = volume_path ~= nil
|
||||||
@ -78,8 +78,8 @@ local URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*):.*'
|
|||||||
local WINDOWS_URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*):[a-zA-Z]:.*'
|
local WINDOWS_URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*):[a-zA-Z]:.*'
|
||||||
|
|
||||||
--- Get a URI from a bufnr
|
--- Get a URI from a bufnr
|
||||||
---@param bufnr (number): Buffer number
|
---@param bufnr number
|
||||||
---@return URI
|
---@return string URI
|
||||||
local function uri_from_bufnr(bufnr)
|
local function uri_from_bufnr(bufnr)
|
||||||
local fname = vim.api.nvim_buf_get_name(bufnr)
|
local fname = vim.api.nvim_buf_get_name(bufnr)
|
||||||
local volume_path = fname:match("^([a-zA-Z]:).*")
|
local volume_path = fname:match("^([a-zA-Z]:).*")
|
||||||
@ -99,8 +99,8 @@ local function uri_from_bufnr(bufnr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Get a filename from a URI
|
--- Get a filename from a URI
|
||||||
---@param uri (string): The URI
|
---@param uri string
|
||||||
---@return Filename
|
---@return string filename or unchanged URI for non-file URIs
|
||||||
local function uri_to_fname(uri)
|
local function uri_to_fname(uri)
|
||||||
local scheme = assert(uri:match(URI_SCHEME_PATTERN), 'URI must contain a scheme: ' .. uri)
|
local scheme = assert(uri:match(URI_SCHEME_PATTERN), 'URI must contain a scheme: ' .. uri)
|
||||||
if scheme ~= 'file' then
|
if scheme ~= 'file' then
|
||||||
@ -117,17 +117,13 @@ local function uri_to_fname(uri)
|
|||||||
return uri
|
return uri
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Return or create a buffer for a uri.
|
--- Get the buffer for a uri.
|
||||||
---@param uri (string): The URI
|
--- Creates a new unloaded buffer if no buffer for the uri already exists.
|
||||||
---@return bufnr.
|
--
|
||||||
---@note Creates buffer but does not load it
|
---@param uri string
|
||||||
|
---@return number bufnr
|
||||||
local function uri_to_bufnr(uri)
|
local function uri_to_bufnr(uri)
|
||||||
local scheme = assert(uri:match(URI_SCHEME_PATTERN), 'URI must contain a scheme: ' .. uri)
|
|
||||||
if scheme == 'file' then
|
|
||||||
return vim.fn.bufadd(uri_to_fname(uri))
|
return vim.fn.bufadd(uri_to_fname(uri))
|
||||||
else
|
|
||||||
return vim.fn.bufadd(uri)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user