2022-04-23 03:56:57 +00:00
|
|
|
-- Prelude initializes everything else for our shell
|
|
|
|
local _ = require 'succulent' -- Function additions
|
2022-10-11 21:41:13 +00:00
|
|
|
local bait = require 'bait'
|
2022-06-20 21:07:15 +00:00
|
|
|
local fs = require 'fs'
|
2022-04-23 03:56:57 +00:00
|
|
|
|
|
|
|
package.path = package.path .. ';' .. hilbish.dataDir .. '/?/init.lua'
|
2022-05-08 20:01:06 +00:00
|
|
|
.. ';' .. hilbish.dataDir .. '/?/?.lua' .. ";" .. hilbish.dataDir .. '/?.lua'
|
2022-04-23 03:56:57 +00:00
|
|
|
|
2023-11-12 00:39:31 +00:00
|
|
|
hilbish.module.paths = '?.so;?/?.so;'
|
|
|
|
.. hilbish.userDir.data .. 'hilbish/libs/?/?.so'
|
|
|
|
.. ";" .. hilbish.userDir.data .. 'hilbish/libs/?.so'
|
|
|
|
|
|
|
|
table.insert(package.searchers, function(module)
|
|
|
|
local path = package.searchpath(module, hilbish.module.paths)
|
|
|
|
if not path then return nil end
|
|
|
|
|
|
|
|
-- it didnt work normally, idk
|
|
|
|
return function() return hilbish.module.load(path) end, path
|
|
|
|
end)
|
|
|
|
|
2022-04-23 03:56:57 +00:00
|
|
|
require 'nature.commands'
|
2022-04-24 13:00:06 +00:00
|
|
|
require 'nature.completions'
|
2022-05-01 01:22:37 +00:00
|
|
|
require 'nature.opts'
|
2022-05-14 00:52:48 +00:00
|
|
|
require 'nature.vim'
|
2022-05-28 23:06:18 +00:00
|
|
|
require 'nature.runner'
|
2023-07-10 23:03:30 +00:00
|
|
|
require 'nature.hummingbird'
|
2024-05-03 02:07:09 +00:00
|
|
|
require 'nature.env'
|
2022-04-23 03:56:57 +00:00
|
|
|
|
|
|
|
local shlvl = tonumber(os.getenv 'SHLVL')
|
|
|
|
if shlvl ~= nil then
|
|
|
|
os.setenv('SHLVL', tostring(shlvl + 1))
|
|
|
|
else
|
|
|
|
os.setenv('SHLVL', '0')
|
|
|
|
end
|
|
|
|
|
2022-06-20 21:07:15 +00:00
|
|
|
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)
|
|
|
|
if entry then
|
|
|
|
dofile(entry)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
package.path = package.path .. ';' .. startSearchPath
|
|
|
|
end
|
2022-10-11 21:41:13 +00:00
|
|
|
|
|
|
|
bait.catch('error', function(event, handler, err)
|
2023-01-07 11:39:36 +00:00
|
|
|
print(string.format('Encountered an error in %s handler\n%s', event, err:sub(8)))
|
2022-10-11 21:41:13 +00:00
|
|
|
end)
|
2022-12-13 16:57:27 +00:00
|
|
|
|
|
|
|
bait.catch('command.not-found', function(cmd)
|
|
|
|
print(string.format('hilbish: %s not found', cmd))
|
|
|
|
end)
|
|
|
|
|
|
|
|
bait.catch('command.not-executable', function(cmd)
|
|
|
|
print(string.format('hilbish: %s: not executable', cmd))
|
|
|
|
end)
|