A new top-level ide/: install.sh places a hash-checked Neovim release, five third-party plugins each at one pinned commit, the LLeMbas plugin from nvim/, a generated colourscheme and a launcher, for one user and under its own NVIM_APPNAME. Built in a staging directory, started there once, then swapped in. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
72 lines
3.1 KiB
Lua
72 lines
3.1 KiB
Lua
-- LLeMbas IDE: a complete Neovim, with LLeMbas built in. Everything here works from what the
|
|
-- installer placed: nothing is fetched, installed or updated when the editor starts.
|
|
local M = {}
|
|
|
|
M.name = "LLeMbas IDE"
|
|
M.problems = {} -- what could not be set up, in words; the dashboard and :LLeMbasIdeDoctor show it
|
|
M.prefix = nil
|
|
M.version = "dev"
|
|
|
|
--- Run one part of the setup; a part that fails is named, and the editor still starts.
|
|
function M.try(what, fn)
|
|
local ok, err = xpcall(fn, debug.traceback)
|
|
if not ok then table.insert(M.problems, what .. ": " .. tostring(err):gsub("\n.*", "")) end
|
|
return ok
|
|
end
|
|
|
|
local function read_first_line(path)
|
|
local f = io.open(path, "r")
|
|
if not f then return nil end
|
|
local line = f:read("*l")
|
|
f:close()
|
|
return line and vim.trim(line) or nil
|
|
end
|
|
|
|
--- Whether a plugin the installer places is there: a module that `require` can find.
|
|
function M.has(module)
|
|
return #vim.api.nvim_get_runtime_file("lua/" .. module:gsub("%.", "/") .. ".lua", false) > 0
|
|
or #vim.api.nvim_get_runtime_file("lua/" .. module:gsub("%.", "/") .. "/init.lua", false) > 0
|
|
end
|
|
|
|
function M.start(opts)
|
|
if M.started then return end
|
|
M.started = true
|
|
M.prefix = opts and opts.prefix or vim.fn.stdpath("data")
|
|
local here = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h")
|
|
M.version = read_first_line(M.prefix .. "/lib/VERSION")
|
|
or read_first_line(vim.fn.fnamemodify(here, ":h:h:h:h") .. "/VERSION") -- a checkout
|
|
or "dev"
|
|
|
|
-- The LLeMbas plugin sits beside its VERSION file, as it does in its repository.
|
|
local plugin = M.prefix .. "/lib/llembas/nvim"
|
|
if vim.fn.isdirectory(plugin) == 0 then plugin = vim.fn.fnamemodify(here, ":h:h:h:h") .. "/nvim" end
|
|
if vim.fn.isdirectory(plugin) == 1 then vim.opt.runtimepath:prepend(plugin) end
|
|
|
|
M.try("options", function() require("llembas_ide.options").setup() end)
|
|
M.try("theme", function() vim.cmd.colorscheme("llembas") end)
|
|
M.try("plugins", function() require("llembas_ide.plugins").setup() end)
|
|
M.try("treesitter", function() require("llembas_ide.treesitter").setup() end)
|
|
M.try("completion", function() require("llembas_ide.completion").setup() end)
|
|
M.try("lsp", function() require("llembas_ide.lsp").setup() end)
|
|
M.try("llembas", function() require("llembas_ide.llembas").setup() end)
|
|
M.try("bars", function() require("llembas_ide.bars").setup() end)
|
|
M.try("sessions", function() require("llembas_ide.sessions").setup() end)
|
|
M.try("keys", function() require("llembas_ide.keys").setup() end)
|
|
M.try("commands", function() require("llembas_ide.commands").setup() end)
|
|
M.try("dashboard", function() require("llembas_ide.dashboard").setup() end)
|
|
|
|
-- The person's own file, last: it may change anything above.
|
|
local user = vim.fn.stdpath("config") .. "/lua/user/init.lua"
|
|
if vim.fn.filereadable(user) == 1 then
|
|
M.try("your lua/user/init.lua", function() dofile(user) end)
|
|
end
|
|
|
|
if #M.problems > 0 then
|
|
vim.schedule(function()
|
|
vim.notify("LLeMbas IDE: " .. #M.problems .. " part(s) did not start. :LLeMbasIdeProblems lists them.", vim.log.levels.WARN)
|
|
end)
|
|
end
|
|
end
|
|
|
|
return M
|