neovim/runtime/lua/vim
Justin M. Keyes 67b2ed1004 fix(gx): visual selection, expand env vars
---
Rejected experiment: move vim.ui.open() to vim.env.open()

Problem:
`vim.ui` is where user-interface "providers" live, which can be
overridden. It would also be useful to have a "providers" namespace for
platform-specific features such as "open", clipboard, python, and the other
providers listed in `:help providers`. We could overload `vim.ui` to
serve that purpose as the single "providers" namespace, but
`vim.ui.nodejs()` for example seems awkward.

Solution:
`vim.env` currently has too narrow of a purpose. Overload it to also be
a namespace for `vim.env.open`.

diff --git a/runtime/lua/vim/_meta.lua b/runtime/lua/vim/_meta.lua
index 913f1fe20348..17d05ff37595 100644
--- a/runtime/lua/vim/_meta.lua
+++ b/runtime/lua/vim/_meta.lua
@@ -37,8 +37,28 @@ local options_info = setmetatable({}, {
   end,
 })

-vim.env = setmetatable({}, {
-  __index = function(_, k)
+vim.env = setmetatable({
+  open = setmetatable({}, {
+      __call = function(_, uri)
+        print('xxxxx'..uri)
+        return true
+      end,
+      __tostring = function()
+        local v = vim.fn.getenv('open')
+        if v == vim.NIL then
+          return nil
+        end
+        return v
+      end,
+    })
+  },
+  {
+  __index = function(t, k, ...)
+    if k == 'open' then
+      error()
+      -- vim.print({...})
+      -- return rawget(t, k)
+    end
     local v = vim.fn.getenv(k)
     if v == vim.NIL then
       return nil
2023-07-04 23:45:35 +02:00
..
filetype vim-patch:9.0.1620: Nix files are not recognized from the hashbang line (#23961) 2023-06-09 08:59:28 +02:00
lsp fix(gx): visual selection, expand env vars 2023-07-04 23:45:35 +02:00
treesitter perf(treesitter): cache fold query (#24222) 2023-07-02 16:44:21 +01:00
_editor.lua docs: autocmds, misc 2023-06-25 17:25:47 +02:00
_init_packages.lua refactor(build): include lpeg as a library 2023-04-27 11:40:00 +02:00
_inspector.lua docs: small fixes 2023-05-13 21:33:22 +02:00
_meta.lua test: spellcheck :help (vimdoc) files #24109 2023-06-22 03:44:51 -07:00
_system.lua feat(lua): add vim.system() 2023-06-07 13:52:23 +01:00
_watch.lua perf(lsp): reduce polling handles for workspace/didChangeWatchedFiles (#23500) 2023-06-14 12:40:11 +02:00
diagnostic.lua docs(diagnostic): return value of get() #24144 2023-06-27 08:14:17 -07:00
F.lua feat(lua): allow vim.F.if_nil to take multiple arguments (#22903) 2023-04-07 08:22:47 -06:00
filetype.lua vim-patch:9.0.1668: PEM files are not recognized (#24169) 2023-06-27 09:14:34 +02:00
fs.lua fix(fs): make normalize() work with '/' path (#24047) 2023-06-18 06:49:33 -05:00
health.lua feat(health): fold successful healthchecks #22866 2023-06-06 08:42:26 -07:00
highlight.lua feat(lua): add hl priority opts on yank (#23509) 2023-05-06 21:53:36 +02:00
inspect.lua fix(inspect): escape identifiers that are lua keywords (#19898) 2022-08-23 13:02:55 +02:00
iter.lua fix(docs): vimdoc syntax errors 2023-06-25 17:14:28 +02:00
keymap.lua docs: various clarifications (#23999) 2023-06-12 20:08:08 +08:00
loader.lua test: spellcheck :help (vimdoc) files #24109 2023-06-22 03:44:51 -07:00
lsp.lua feat(lsp): move inlay_hint() to vim.lsp (#24130) 2023-06-30 11:33:28 +02:00
re.lua refactor(build): include lpeg as a library 2023-04-27 11:40:00 +02:00
secure.lua feat(lua): rename vim.loop -> vim.uv (#22846) 2023-06-03 12:06:00 +02:00
shared.lua docs: fix vim.tbl_get type annotations #23992 2023-06-11 15:48:13 -07:00
treesitter.lua refactor!: rename "playground" => "dev" #23919 2023-06-06 08:23:20 -07:00
ui.lua fix(gx): visual selection, expand env vars 2023-07-04 23:45:35 +02:00
uri.lua refactor: remove modelines from Lua files 2023-04-13 23:29:13 +02:00
version.lua fix: tostring(vim.version()) fails if build is NIL #24097 2023-06-22 00:36:38 -07:00