1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 12:50:04 +08:00
This commit is contained in:
Wang Shidong 2020-12-20 20:22:11 +08:00 committed by GitHub
parent 88f9554122
commit 169ad9748a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 74 additions and 19 deletions

View File

@ -45,13 +45,37 @@ function! SpaceVim#api#data#dict#get() abort
\ )
endfunction
function! s:entrys(dict) abort
let entrys = []
for key in keys(a:dict)
call add(entrys, {key : a:dict[key]})
endfor
return entrys
endfunction
if has('lua') || has('nvim')
function! s:entrys(dict) abort
lua require("spacevim.api.data.dict").entrys(
\ require("spacevim").eval("a:dict")
\ )
endfunction
function! s:pick(dict, keys) abort
lua require("spacevim.api.data.dict").pick(
\ require("spacevim").eval("a:dict"),
\ require("spacevim").eval("a:keys")
\ )
endfunction
else
function! s:entrys(dict) abort
let entrys = []
for key in keys(a:dict)
call add(entrys, {key : a:dict[key]})
endfor
return entrys
endfunction
function! s:pick(dict, keys) abort
let new_dict = {}
for key in a:keys
if has_key(a:dict, key)
let new_dict[key] = a:dict[key]
endif
endfor
return new_dict
endfunction
endif
function! s:make(keys, values, ...) abort
let dict = {}
@ -77,15 +101,6 @@ function! s:make_index(list, ...) abort
return s:make(a:list, [], value)
endfunction
function! s:pick(dict, keys) abort
let new_dict = {}
for key in a:keys
if has_key(a:dict, key)
let new_dict[key] = a:dict[key]
endif
endfor
return new_dict
endfunction
function! s:omit(dict, keys) abort
let new_dict = copy(a:dict)

View File

@ -1,4 +1,4 @@
local spacevim = {}
local M = {}
local options = require('spacevim.opt')
@ -6,11 +6,19 @@ local layers = require('spacevim.layer')
function spacevim.bootstrap()
function M.bootstrap()
options.init()
layers.init()
end
return spacevim
function M.eval(l)
if vim['api'] ~= nil then
return vim.eval(l)
else
return vim.api.nvim_eval(l)
end
end
return M

View File

@ -0,0 +1,19 @@
local M = {}
function M.entrys(d)
end
function M.pick(d, keys)
local new_d = {}
for key, value in pairs(d) do
end
return new_d
end
return M

9
lua/spacevim/neovim.lua Normal file
View File

@ -0,0 +1,9 @@
local M = {}
function M.eval(l)
return vim.api.nvim_eval(l)
end
return M

0
lua/spacevim/vim.lua Normal file
View File

4
test/lua/spacevim.vader Normal file
View File

@ -0,0 +1,4 @@
Execute ( lua module spacevim ):
let g:test_lua = 'abc'
AssertEqual luaeval('require("spacevim").eval("g:test_lua")'), 'abc'