diff options
author | Lewis Russell <lewis6991@gmail.com> | 2023-07-18 15:42:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-18 15:42:30 +0100 |
commit | be74807eef13ff8c90d55cf8b22b01d6d33b1641 (patch) | |
tree | 9f7e1cebdb2677057b066df9fea91bce86b4ab6a /runtime/lua/vim/uri.lua | |
parent | d0ae529861594b2e89a436ed2cfb3d2243f8bfcc (diff) | |
download | rneovim-be74807eef13ff8c90d55cf8b22b01d6d33b1641.tar.gz rneovim-be74807eef13ff8c90d55cf8b22b01d6d33b1641.tar.bz2 rneovim-be74807eef13ff8c90d55cf8b22b01d6d33b1641.zip |
docs(lua): more improvements (#24387)
* docs(lua): teach lua2dox how to table
* docs(lua): teach gen_vimdoc.py about local functions
No more need to mark local functions with @private
* docs(lua): mention @nodoc and @meta in dev-lua-doc
* fixup!
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
---------
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
Diffstat (limited to 'runtime/lua/vim/uri.lua')
-rw-r--r-- | runtime/lua/vim/uri.lua | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/runtime/lua/vim/uri.lua b/runtime/lua/vim/uri.lua index dec7840eb0..eaa64a6fad 100644 --- a/runtime/lua/vim/uri.lua +++ b/runtime/lua/vim/uri.lua @@ -8,7 +8,6 @@ do local schar = string.char --- Convert hex to char - ---@private local function hex_to_char(hex) return schar(tonumber(hex, 16)) end @@ -33,7 +32,6 @@ do local sbyte = string.byte local tohex = require('bit').tohex - ---@private local function percent_encode_char(char) return '%' .. tohex(sbyte(char), 2) end @@ -46,15 +44,16 @@ do end end ----@private local function is_windows_file_uri(uri) return uri:match('^file:/+[a-zA-Z]:') ~= nil end +local M = {} + --- Get a URI from a file path. ---@param path string Path to file ---@return string URI -local function uri_from_fname(path) +function M.uri_from_fname(path) local volume_path, fname = path:match('^([a-zA-Z]:)(.*)') local is_windows = volume_path ~= nil if is_windows then @@ -76,7 +75,7 @@ local WINDOWS_URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9.+-]*):[a-zA-Z]:.*' --- Get a URI from a bufnr ---@param bufnr integer ---@return string URI -local function uri_from_bufnr(bufnr) +function M.uri_from_bufnr(bufnr) local fname = vim.api.nvim_buf_get_name(bufnr) local volume_path = fname:match('^([a-zA-Z]:).*') local is_windows = volume_path ~= nil @@ -90,14 +89,14 @@ local function uri_from_bufnr(bufnr) if scheme then return fname else - return uri_from_fname(fname) + return M.uri_from_fname(fname) end end --- Get a filename from a URI ---@param uri string ---@return string filename or unchanged URI for non-file URIs -local function uri_to_fname(uri) +function M.uri_to_fname(uri) local scheme = assert(uri:match(URI_SCHEME_PATTERN), 'URI must contain a scheme: ' .. uri) if scheme ~= 'file' then return uri @@ -118,13 +117,8 @@ end -- ---@param uri string ---@return integer bufnr -local function uri_to_bufnr(uri) - return vim.fn.bufadd(uri_to_fname(uri)) +function M.uri_to_bufnr(uri) + return vim.fn.bufadd(M.uri_to_fname(uri)) end -return { - uri_from_fname = uri_from_fname, - uri_from_bufnr = uri_from_bufnr, - uri_to_fname = uri_to_fname, - uri_to_bufnr = uri_to_bufnr, -} +return M |