diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-05-19 17:58:54 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-05-19 17:58:54 +0200 |
commit | e4c2d85c7729925128746d08883286b75fb097a8 (patch) | |
tree | f8b0295997e28da4815302b0222abc12d78b4208 /src/nvim/lua/vim.lua | |
parent | e628c011bfb58685e4a4ce7da681afda08989a7f (diff) | |
download | rneovim-e4c2d85c7729925128746d08883286b75fb097a8.tar.gz rneovim-e4c2d85c7729925128746d08883286b75fb097a8.tar.bz2 rneovim-e4c2d85c7729925128746d08883286b75fb097a8.zip |
lua/shared: share deepcopy() with test/*
deepcopy() was duplicated in test/helpers.lua
Diffstat (limited to 'src/nvim/lua/vim.lua')
-rw-r--r-- | src/nvim/lua/vim.lua | 41 |
1 files changed, 4 insertions, 37 deletions
diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua index 69038f8c89..3c1a9a86d0 100644 --- a/src/nvim/lua/vim.lua +++ b/src/nvim/lua/vim.lua @@ -1,10 +1,10 @@ -- Nvim-Lua stdlib: the `vim` module (:help lua-stdlib) -- -- Lua code lives in one of three places: --- 1. The runtime (`runtime/lua/vim/`). For "nice to have" features, e.g. --- the `inspect` and `lpeg` modules. --- 2. The `vim.shared` module: code shared between Nvim and its test-suite. --- 3. Compiled-into Nvim itself (`src/nvim/lua/`). +-- 1. runtime/lua/vim/ (the runtime): For "nice to have" features, e.g. the +-- `inspect` and `lpeg` modules. +-- 2. runtime/lua/vim/shared.lua: Code shared between Nvim and tests. +-- 3. src/nvim/lua/: Compiled-into Nvim itself. -- -- Guideline: "If in doubt, put it in the runtime". -- @@ -231,38 +231,6 @@ local function trim(s) return result end ---- Performs a deep copy of the given object, and returns that copy. ---- For a non-table object, that just means a usual copy of the object, ---- while for a table all subtables are copied recursively. ---@param orig Table The table to copy ---@returns A new table where the keys and values are deepcopies of the keys ---- and values from the original table. -local function deepcopy(orig) - error() -end - -local function _id(v) - return v -end - -local deepcopy_funcs = { - table = function(orig) - local copy = {} - for k, v in pairs(orig) do - copy[deepcopy(k)] = deepcopy(v) - end - return copy - end, - number = _id, - string = _id, - ['nil'] = _id, - boolean = _id, -} - -deepcopy = function(orig) - return deepcopy_funcs[type(orig)](orig) -end - local function __index(t, key) if key == 'inspect' then t.inspect = require('vim.inspect') @@ -282,7 +250,6 @@ local module = { trim = trim, split = split, gsplit = gsplit, - deepcopy = deepcopy, } setmetatable(module, { |