feat: auto start lua modules (closes #167)

website
TorchedSammy 2022-06-20 17:07:15 -04:00
parent 453ba9f8ad
commit 362bb14d7e
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
2 changed files with 20 additions and 0 deletions

View File

@ -55,6 +55,8 @@ having and using multiple runners.
- .. and 2 properties
- `fs.pathSep` is the separator for filesystem paths and directories
- `fs.pathListSep` is the separator for $PATH env entries
- Lua modules located in `hilbish.userDir.data .. '/hilbish/start'` (like `~/.local/share/hilbish/start/foo/init.lua`)
will be ran on startup
### Changed
- **Breaking Change:** Upgraded to Lua 5.4.

View File

@ -1,5 +1,6 @@
-- Prelude initializes everything else for our shell
local _ = require 'succulent' -- Function additions
local fs = require 'fs'
package.path = package.path .. ';' .. hilbish.dataDir .. '/?/init.lua'
.. ';' .. hilbish.dataDir .. '/?/?.lua' .. ";" .. hilbish.dataDir .. '/?.lua'
@ -45,3 +46,20 @@ do
})
end
do
local startSearchPath = hilbish.userDir.data .. '/hilbish/start/?/init.lua;'
.. hilbish.userDir.data .. '/hilbish/start/?.lua'
local ok, modules = pcall(fs.readdir, hilbish.userDir.data .. '/hilbish/start/')
if ok then
for _, module in ipairs(modules) do
local entry = package.searchpath(module, startSearchPath)
print(entry)
if entry then
dofile(entry)
end
end
end
package.path = package.path .. ';' .. startSearchPath
end