aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc
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/doc
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/doc')
-rw-r--r--runtime/doc/lua.txt20
-rw-r--r--runtime/doc/news.txt9
-rw-r--r--runtime/doc/various.txt13
3 files changed, 21 insertions, 21 deletions
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index f180471bde..b09e308e80 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -2344,28 +2344,26 @@ input({opts}, {on_confirm}) *vim.ui.input()*
entered), or `nil` if the user aborted the dialog.
open({path}) *vim.ui.open()*
- Opens a path in the system's default handler. This function utilizes
- `xdg-open`, `wslview`, `explorer`, or `open` commands depending on the
- system to open the provided path.
+ Opens `path` with the system default handler (macOS `open`, Windows
+ `explorer.exe`, Linux `xdg-open`, …), or shows a message on failure.
- Notifies the user if unsuccessful
+ Expands "~/" and environment variables in filesystem paths.
- Example: >lua
+ Examples: >lua
vim.ui.open("https://neovim.io/")
-
- vim.ui.open("/path/to/file")
+ vim.ui.open("~/path/to/file")
+ vim.ui.open("$VIMRUNTIME")
<
Parameters: ~
- • {path} (string) Path to be opened
+ • {path} (string) Path or URL to open
Return: ~
- SystemCompleted|nil result Result of command, if an appropriate one
- could be found.
+ SystemCompleted|nil result Command result, or nil if not found.
See also: ~
- • |vim.system|
+ • |vim.system()|
select({items}, {opts}, {on_choice}) *vim.ui.select()*
Prompts the user to pick from a list of items, allowing arbitrary
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index ed797f94ba..24e9dc917b 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -105,10 +105,10 @@ The following new APIs and features were added.
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_inlayHint
• Bundled treesitter parser and queries (highlight, folds) for Markdown,
-Python, and Bash.
+ Python, and Bash.
• |vim.ui.open()| opens URIs using the system default handler (macOS `open`,
-Windows `explorer`, Linux `xdg-open`, etc.)
+ Windows `explorer`, Linux `xdg-open`, etc.)
==============================================================================
CHANGED FEATURES *news-changed*
@@ -146,8 +146,9 @@ The following changes to existing APIs or features add new behavior.
• |:Man| now respects 'wrapmargin'
-• The |gx| command now uses |vim.ui.open()| and not netrw. Continue using
-netrw with `vim.g.use_lua_gx = false`.
+• |gx| now uses |vim.ui.open()| and not netrw. To customize, you can redefine
+ `vim.ui.open` or remap `gx`. To continue using netrw (deprecated): >vim
+ :call netrw#BrowseX(expand(exists("g:netrw_gx")? g:netrw_gx : '<cfile>'), netrw#CheckIfRemote())<CR>
==============================================================================
REMOVED FEATURES *news-removed*
diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt
index de1c21b310..956c37fc0f 100644
--- a/runtime/doc/various.txt
+++ b/runtime/doc/various.txt
@@ -98,13 +98,14 @@ g8 Print the hex values of the bytes used in the
command won't move the cursor.
*gx*
-gx Open the current path or URL under the cursor in the
- system's default handler with |vim.ui.open|.
+gx Opens the current filepath or URL (decided by
+ |<cfile>|, 'isfname') at cursor using the system
+ default handler, by calling |vim.ui.open()|.
+
+ *v_gx*
+{Visual}gx Opens the selected text using the system default
+ handler, by calling |vim.ui.open()|.
- To use the netrw keymap, set `use_lua_gx` to false:
->lua
- vim.g.use_lua_gx = false
-<
*:p* *:pr* *:print* *E749*
:[range]p[rint] [flags]
Print [range] lines (default current line).