aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/handlers.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2023-07-02 16:51:30 +0200
committerJustin M. Keyes <justinkz@gmail.com>2023-07-04 23:45:35 +0200
commit67b2ed1004ae551c9fe1bbd29a86b5a301570800 (patch)
tree17291218462aa3b25ce5e0393b25f93b9aa927a6 /runtime/lua/vim/lsp/handlers.lua
parentaf6e6ccf3dee815850639ec5613dda3442caa7d6 (diff)
downloadrneovim-67b2ed1004ae551c9fe1bbd29a86b5a301570800.tar.gz
rneovim-67b2ed1004ae551c9fe1bbd29a86b5a301570800.tar.bz2
rneovim-67b2ed1004ae551c9fe1bbd29a86b5a301570800.zip
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
Diffstat (limited to 'runtime/lua/vim/lsp/handlers.lua')
-rw-r--r--runtime/lua/vim/lsp/handlers.lua6
1 files changed, 3 insertions, 3 deletions
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua
index 9b102c0f84..79d3f7aab0 100644
--- a/runtime/lua/vim/lsp/handlers.lua
+++ b/runtime/lua/vim/lsp/handlers.lua
@@ -576,12 +576,12 @@ M['window/showDocument'] = function(_, result, ctx, _)
local ret = vim.ui.open(uri)
- if ret.code ~= 0 or ret == nil then
+ if ret == nil or ret.code ~= 0 then
return {
success = false,
error = {
code = protocol.ErrorCodes.UnknownErrorCode,
- message = ret and ret.stderr or 'No handler could be found',
+ message = ret and ret.stderr or 'No handler found',
},
}
end
@@ -593,7 +593,7 @@ M['window/showDocument'] = function(_, result, ctx, _)
local client = vim.lsp.get_client_by_id(client_id)
local client_name = client and client.name or string.format('id=%d', client_id)
if not client then
- err_message({ 'LSP[', client_name, '] client has shut down after sending ', ctx.method })
+ err_message('LSP[', client_name, '] client has shut down after sending ', ctx.method)
return vim.NIL
end