aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/vim.lua
diff options
context:
space:
mode:
authorShadman <13149513+shadmansaleh@users.noreply.github.com>2022-01-07 00:42:31 +0600
committerGitHub <noreply@github.com>2022-01-06 11:42:31 -0700
commit287d3566de11f82aa86448998fd4703b1db328bd (patch)
tree9fd586e31fc9058f499a4247c1c0efe72a64f55d /src/nvim/lua/vim.lua
parentd78e46679d2ff31916091f9368367ccc1539c299 (diff)
downloadrneovim-287d3566de11f82aa86448998fd4703b1db328bd.tar.gz
rneovim-287d3566de11f82aa86448998fd4703b1db328bd.tar.bz2
rneovim-287d3566de11f82aa86448998fd4703b1db328bd.zip
fix(lua): print multiple return values with =expr (#16933)
Diffstat (limited to 'src/nvim/lua/vim.lua')
-rw-r--r--src/nvim/lua/vim.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua
index e5a5ae799b..731e7d8d36 100644
--- a/src/nvim/lua/vim.lua
+++ b/src/nvim/lua/vim.lua
@@ -689,4 +689,23 @@ vim._expand_pat_get_parts = function(lua_string)
return parts, search_index
end
+---Prints given arguments in human-readable format.
+---Example:
+---<pre>
+--- -- Print highlight group Normal and store it's contents in a variable.
+--- local hl_normal = vim.pretty_print(vim.api.nvim_get_hl_by_name("Normal", true))
+---</pre>
+---@see |vim.inspect()|
+---@return given arguments.
+function vim.pretty_print(...)
+ local objects = {}
+ for i = 1, select('#', ...) do
+ local v = select(i, ...)
+ table.insert(objects, vim.inspect(v))
+ end
+
+ print(table.concat(objects, ' '))
+ return ...
+end
+
return module