1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-14 23:49:19 +08:00

feat(lua): fix layer list

This commit is contained in:
wsdjeg 2022-06-19 12:03:48 +08:00
parent c028efe0ea
commit d757310857

View File

@ -34,8 +34,28 @@ local function find_layers()
local pattern = '/autoload/SpaceVim/layers/'
local rst = {}
for _, layer in pairs(layers) do
local name = layer:gsub('.+SpaceVim[\\/]layers[\\/]', ''):gsub('.vim$', ''):gsub('[\\/]', '#')
table.insert(rst, name)
local name = layer:gsub('.+SpaceVim[\\/]layers[\\/]', ''):gsub('.vim$', ''):gsub('[\\/]', '/')
if M.isLoaded(name) then
local status = 'loaded'
else
local status = 'not loaded'
end
if name == 'lsp' then
local url = 'language-server-protocol'
else
local url = name
end
if sp.fn.filereadable(sp.fn.expand('~/.SpaceVim/docs/layers/' .. url .. '.md')) then
local website = 'https://spacevim.org/layers/' .. url .. '/'
else
local website = 'no exists'
end
local name = sp.fn.substitute(name, '/', '#','g')
if status == 'loaded' then
table.insert(rst, '+ ' .. name .. ':' .. sp.fn.repeat(' ', 25 - sp.fn.len(name)) .. status .. sp.fn.repeat(' ', 10) .. website)
else
table.insert(rst, '- ' .. name .. ':' .. sp.fn.repeat(' ', 25 - sp.fn.len(name)) .. status .. sp.fn.repeat(' ', 10) .. website)
end
end
return rst
end