Initial commit

This commit is contained in:
2024-10-02 14:54:32 +02:00
commit 14af275c5c
27 changed files with 1871 additions and 0 deletions

51
lua/cave/init.lua Normal file
View File

@@ -0,0 +1,51 @@
---@class cave
local cave = {}
cave.Path = require "cave.path"
cave.Util = require "cave.util"
cave.manager = require("cave.manager").new()
function cave.load_project_from_cwd()
local manager = cave.manager
local workspaces = require "workspaces"
local Path = cave.Path
local cwd = Path.cwd()
for project_name, project in pairs(manager:get_projects()) do
if project.dir:samefile(cwd) then workspaces.open(project_name) end
end
end
function cave.setup()
vim.api.nvim_create_user_command(
"ProjectAdd",
function(cmd_opts) cave.manager:add_project(unpack(cmd_opts.fargs)) end,
{
desc = "Add a project (dir?, name?)",
nargs = "*",
complete = "file",
}
)
vim.api.nvim_create_user_command(
"ProjectRemove",
function(cmd_opts) cave.manager:remove_project(unpack(cmd_opts.fargs)) end,
{
desc = "Remove a project (name?)",
nargs = 1,
complete = function(lead) return cave.manager:project_name_complete(lead) end,
}
)
vim.api.nvim_create_user_command(
"ProjectRename",
function(cmd_opts) cave.manager:rename_project(unpack(cmd_opts.fargs)) end,
{
desc = "Rename a project. (old_name, new_name)",
nargs = "+",
complete = function(lead) return cave.manager:project_name_complete(lead) end,
}
)
vim.schedule(cave.load_project_from_cwd)
end
return cave