Files
vern-nvim/lua/vern/init.lua
T
DarthMooMancer 685a711644 REFACTOR: Annotations for autocompletion, reworked how projects are made
and handled, wrote the c file replacing the copied python code.
2026-10-22 04:29:52 -04:00

53 lines
1.6 KiB
Lua

local M = {}
local configs = require("vern.configs")
local actions = require("vern.actions")
---@type VernCoreConfig
M.opts = vim.deepcopy(configs)
---@param user_opts? VernCoreConfig | table
function M.setup(user_opts)
---@type VernCoreConfig
M.opts = vim.tbl_deep_extend("force", {}, configs, user_opts or {})
for key, def in pairs(M.opts.keybinds or {}) do
if type(def.action) == "function" then
vim.keymap.set("n", key, function()
def.action(M.opts)
end, {
silent = true,
desc = def.desc,
})
end
end
vim.api.nvim_create_user_command("VernCreateProject", function()
if actions.create_project then
actions.create_project(M.opts)
end
end, { nargs = "*", desc = "Create a new project" })
vim.api.nvim_create_user_command("VernCreateFile", function()
if type(actions.create_file) == "function" then
actions.create_file(M.opts)
end
end, { nargs = "*", desc = "Creates a new file for project" })
local group = vim.api.nvim_create_augroup("VernAutocommands", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
group = group,
pattern = "*",
callback = function(args)
local ft = vim.bo[args.buf].filetype
local ok, attach = pcall(require, "vern.attach." .. ft)
if ok and type(attach) == "function" then
attach(args.buf, M.opts)
end
end,
desc = "Attach languages to buffer",
})
end
return M