diff options
Diffstat (limited to 'runtime/lua/vim/_editor.lua')
-rw-r--r-- | runtime/lua/vim/_editor.lua | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index 975f3fea4a..e29d8f1c30 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -1142,6 +1142,21 @@ do end end +--- @param inspect_strings boolean use vim.inspect() for strings +function vim._print(inspect_strings, ...) + local msg = {} + for i = 1, select('#', ...) do + local o = select(i, ...) + if not inspect_strings and type(o) == 'string' then + table.insert(msg, o) + else + table.insert(msg, vim.inspect(o, { newline = '\n', indent = ' ' })) + end + end + print(table.concat(msg, '\n')) + return ... +end + --- "Pretty prints" the given arguments and returns them unmodified. --- --- Example: @@ -1155,17 +1170,7 @@ end --- @param ... any --- @return any # given arguments. function vim.print(...) - local msg = {} - for i = 1, select('#', ...) do - local o = select(i, ...) - if type(o) == 'string' then - table.insert(msg, o) - else - table.insert(msg, vim.inspect(o, { newline = '\n', indent = ' ' })) - end - end - print(table.concat(msg, '\n')) - return ... + return vim._print(false, ...) end --- Translates keycodes. |