Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lua): vim.uri #24527

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

feat(lua): vim.uri #24527

wants to merge 1 commit into from

Conversation

justinmk
Copy link
Member

@justinmk justinmk commented Aug 1, 2023

( followup to #24491 )

  • Introduce vim.uri module.
  • Deprecate old top-level vim.uri_x functions

TODO:

  • test coverage for encode/decode
  • deprecate() ?
  • migrate all internal usages of the old deprecated functions
  • introduce Uri container object which unambiguously represents a path, reference https://github.com/microsoft/vscode-uri

TODO:

- test coverage for encode/decode
- deprecate() ?
- migrate all internal usages of the old deprecated functions
- introduce `Uri` container object which unambiguously represents
  a path, reference https://github.com/microsoft/vscode-uri
@github-actions github-actions bot added the lua stdlib label Aug 1, 2023
vim.loop = vim.uv

local uri = require('vim.uri')
Copy link
Member

@lewis6991 lewis6991 Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes the uri module to be unconditionally required even if it doesn't get used.

I think we need to keep the code as it was and just add deprecated tags to meta files via #24525

@@ -1,5 +1,5 @@
local uv = vim.uv
local uri_encode = vim.uri_encode
local uri_encode = vim.uri.encode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the loader now depends on the uri module then we should inline the uri module into the nvim binary.

This would make my other comment moot since requiring it essentially becomes free.

Comment on lines 66 to +67
if is_windows then
path = volume_path .. M.uri_encode(fname:gsub('\\', '/'))
path = volume_path .. M.encode(fname:gsub('\\', '/'))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be possible to include correct uri encoding of the volume_path and possibly add a vscode-like normalization?

volume_path = volume_path:lower():gsub(":", "%%3A") 

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I think that the M.encode should use pattern "^A-Za-z0-9%-_.!~*'()/" (rfc2396 + "/" = keep "unreserved chars" and slashes), so that odd filenames like #@file@# are not translated into an uri-fragment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lua stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants