diff options
Diffstat (limited to 'lua/pets')
| -rw-r--r-- | lua/pets/utils.lua | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/lua/pets/utils.lua b/lua/pets/utils.lua index 68ea6b1..62b4913 100644 --- a/lua/pets/utils.lua +++ b/lua/pets/utils.lua @@ -1,23 +1,12 @@ local M = {} M.available_pets = {} --- list all files in a directory --- source: https://stackoverflow.com/a/11130774 -function M.listdir(directory) - local i, t, popen = 0, {}, io.popen - local pfile - pfile = popen('/bin/ls -a "' .. directory .. '"') - if pfile == nil then - error("Error getting assets for specified pet") - end - for filename in pfile:lines() do - if filename ~= "." and filename ~= ".." and not vim.endswith(filename, "sh") then - i = i + 1 - t[i] = filename - end - end - pfile:close() - return t +function M.listdir(path) + local sol = {} + for val in vim.fs.dir(path) do + table.insert(sol, val) + end + return sol end local wd = debug.getinfo(1).source:sub(2):match("(.*nvim/)") .. "media/" |