REFACTOR: Merged templates into a per language file, deleted init.lua as
it was just a middle man and wasnt needed (in fact it is better without it) FT: Changes to python
This commit is contained in:
+37
-4
@@ -1,9 +1,38 @@
|
||||
local M = {}
|
||||
|
||||
M.user_opts = {}
|
||||
local global_opts = require("vern.configs.default")
|
||||
local actions = require("vern.actions")
|
||||
M.opts = {}
|
||||
|
||||
function M.setup(opts)
|
||||
M.user_opts = opts or {}
|
||||
function M.setup(user_opts)
|
||||
M.opts = vim.tbl_deep_extend("force", {}, global_opts, user_opts or {})
|
||||
|
||||
--- Bind global keybinds
|
||||
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
|
||||
|
||||
--- Load project cmdline commands
|
||||
vim.api.nvim_create_user_command("VernCreateProject", function(args)
|
||||
if actions.create_project then
|
||||
actions.create_project(M.opts, args)
|
||||
end
|
||||
end, { nargs = "*", desc = "Create a new project" })
|
||||
|
||||
vim.api.nvim_create_user_command("VernCreateFile", function(args)
|
||||
if type(actions.create_file) == "function" then
|
||||
actions.create_file(M.opts, args)
|
||||
end
|
||||
end, { nargs = "*", desc = "Creates a new file for project" })
|
||||
|
||||
--- Create group and attach based on ft
|
||||
local group =
|
||||
vim.api.nvim_create_augroup("VernAutocommands", { clear = true })
|
||||
|
||||
@@ -11,7 +40,11 @@ function M.setup(opts)
|
||||
group = group,
|
||||
pattern = "*",
|
||||
callback = function(args)
|
||||
require("vern.attach").buf(args.buf, M.user_opts)
|
||||
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.user_opts)
|
||||
end
|
||||
end,
|
||||
desc = "Attach languages to buffer",
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user