53 lines
1.7 KiB
Lua
53 lines
1.7 KiB
Lua
local M = {}
|
|
|
|
M.create_project = function(opts)
|
|
opts = opts or {}
|
|
vim.ui.input(
|
|
{ prompt = "Project language (e.g. python): ", completion = "filetype" },
|
|
function(ft)
|
|
ft = ft and vim.trim(ft)
|
|
if not ft or vim.trim(ft) == "" then
|
|
return
|
|
end
|
|
local ok, actions = pcall(require, "vern-nvim.actions." .. ft)
|
|
local configs = require("vern-nvim.configs." .. ft)
|
|
local args = vim.tbl_deep_extend("force", {}, configs, opts or {})
|
|
if ok and actions and type(actions.create_project) == "function" then
|
|
actions.create_project(args)
|
|
else
|
|
vim.notify("Unknown Filetype: " .. ft, vim.log.levels.WARN, {
|
|
title = "Vern Project",
|
|
})
|
|
end
|
|
end
|
|
)
|
|
end
|
|
|
|
M.create_file = function(opts)
|
|
opts = opts or {}
|
|
vim.ui.input({
|
|
prompt = "File language (e.g. python): ",
|
|
completion = "filetype",
|
|
}, function(ft)
|
|
ft = ft and vim.trim(ft)
|
|
if not ft or vim.trim(ft) == "" then
|
|
return
|
|
end
|
|
local ok, actions = pcall(require, "vern-nvim.actions." .. ft)
|
|
local configs = require("vern-nvim.configs." .. ft)
|
|
local args = vim.tbl_deep_extend("force", {}, configs, opts or {})
|
|
if ok and actions and type(actions.create_file) == "function" then
|
|
actions.create_file(args)
|
|
else
|
|
vim.notify("Unknown Filetype: " .. ft, vim.log.levels.WARN, {
|
|
title = "Vern File",
|
|
})
|
|
vim.notify("Error: " .. actions, vim.log.levels.ERROR, {
|
|
title = "Vern File",
|
|
})
|
|
end
|
|
end)
|
|
end
|
|
|
|
return M
|