chore(actions.create_project): now has a list over manually typing for
easier creation
This commit is contained in:
1 parent
adbd2bc0e9
commit
1c13c8cbe2
28 files changed
+1151
-929
No files matched your search
@@ -3,50 +3,50 @@ local actions = require("vern-nvim.core.actions")
|
||||
|
||||
---@type VernCoreConfig
|
||||
return {
|
||||
workspace_root = "~/personal/Projects",
|
||||
env = {
|
||||
--- In documentation, make recommendation to change to username or name instead of company
|
||||
author = "company",
|
||||
workspace_root = "~/personal/Projects",
|
||||
env = {
|
||||
--- In documentation, make recommendation to change to username or name instead of company
|
||||
author = "company",
|
||||
},
|
||||
keybinds = {
|
||||
["<leader>pc"] = {
|
||||
user_command = "VernCreateProject",
|
||||
desc = "Creates a new project",
|
||||
action = actions.create_project,
|
||||
},
|
||||
keybinds = {
|
||||
["<leader>pc"] = {
|
||||
user_command = "VernCreateProject",
|
||||
desc = "Creates a new project",
|
||||
action = actions.create_project,
|
||||
},
|
||||
["<leader>pf"] = {
|
||||
user_command = "VernCreateFile",
|
||||
desc = "Creates a new project file based on current buffer filetype",
|
||||
action = actions.create_file,
|
||||
},
|
||||
["<leader>pr"] = {
|
||||
user_command = "VernRunProject",
|
||||
desc = "Builds and runs project based on current buffer filetype",
|
||||
action = actions.run,
|
||||
},
|
||||
["<leader>pf"] = {
|
||||
user_command = "VernCreateFile",
|
||||
desc = "Creates a new project file based on current buffer filetype",
|
||||
action = actions.create_file,
|
||||
},
|
||||
terminal = {
|
||||
mode = {
|
||||
type = "split", --- (float)|(split)
|
||||
win = {
|
||||
float = {
|
||||
padding = {
|
||||
left = 0,
|
||||
right = 0,
|
||||
top = 0,
|
||||
bottom = 0,
|
||||
},
|
||||
border = {
|
||||
enabled = true,
|
||||
type = vim.o.winborder, -- defaults to neovim winborder
|
||||
},
|
||||
},
|
||||
split = {
|
||||
direction = "horizontal", --- (vertical)|(horizontal)
|
||||
anchor = "bottom", --- (right)|(bottom)
|
||||
size = "20",
|
||||
},
|
||||
},
|
||||
},
|
||||
["<leader>pr"] = {
|
||||
user_command = "VernRunProject",
|
||||
desc = "Builds and runs project based on current buffer filetype",
|
||||
action = actions.run,
|
||||
},
|
||||
},
|
||||
terminal = {
|
||||
mode = {
|
||||
type = "split", --- (float)|(split)
|
||||
win = {
|
||||
float = {
|
||||
padding = {
|
||||
left = 0,
|
||||
right = 0,
|
||||
top = 0,
|
||||
bottom = 0,
|
||||
},
|
||||
border = {
|
||||
enabled = true,
|
||||
type = vim.o.winborder, -- defaults to neovim winborder
|
||||
},
|
||||
},
|
||||
split = {
|
||||
direction = "horizontal", --- (vertical)|(horizontal)
|
||||
anchor = "bottom", --- (right)|(bottom)
|
||||
size = "20",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
+200
-195
@@ -6,217 +6,222 @@ local fs = require("vern-nvim.core.fs")
|
||||
---@module "vern-nvim.core.template"
|
||||
local templates = require("vern-nvim.core.template")
|
||||
|
||||
---@module "vern-nvim.providers.web"
|
||||
local providers = require("vern-nvim.providers.web")
|
||||
|
||||
---Imitate create_file so you can skip over and use for each filetype
|
||||
|
||||
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
|
||||
vim.notify("Unknown Filetype: " .. ft, vim.log.levels.WARN, {
|
||||
title = "Vern Project",
|
||||
})
|
||||
return
|
||||
end
|
||||
local ok, langs = pcall(require, "vern-nvim.langs." .. ft)
|
||||
if not ok or type(langs) ~= "table" then return end
|
||||
local args = vim.tbl_deep_extend("force", {}, langs, opts or {})
|
||||
if not args[ft] or type(args[ft]) ~= "table" then return end
|
||||
vim.ui.input({ prompt = "Enter project name: " }, function(pname)
|
||||
pname = pname and vim.trim(pname)
|
||||
if not pname or pname == "" then return end
|
||||
local root = vim.fs.joinpath(
|
||||
vim.fn.expand(args.workspace_root),
|
||||
args[ft].root,
|
||||
pname
|
||||
)
|
||||
opts = opts or {}
|
||||
local ft = ""
|
||||
local items = {
|
||||
"cpp",
|
||||
"c",
|
||||
"rust",
|
||||
"python",
|
||||
"go",
|
||||
"lua",
|
||||
"java",
|
||||
"web - not yet implemented",
|
||||
}
|
||||
vim.ui.select(items, {
|
||||
prompt = "Select available language:",
|
||||
format_item = function(item) return item end,
|
||||
}, function(choice, _)
|
||||
if choice then ft = vim.trim(choice) end
|
||||
local ok, langs = pcall(require, "vern-nvim.langs." .. ft)
|
||||
if not ok or type(langs) ~= "table" then
|
||||
-- vim.notify("Empty or nil ft", vim.log.levels.WARN, {
|
||||
-- title = "Vern Project",
|
||||
-- })
|
||||
return
|
||||
end
|
||||
local args = vim.tbl_deep_extend("force", {}, langs, opts or {})
|
||||
if not args[ft] or type(args[ft]) ~= "table" then return end
|
||||
if ft == "web" then
|
||||
if type(langs.create_project) == "function" then
|
||||
langs.create_project()
|
||||
end
|
||||
return
|
||||
else
|
||||
vim.ui.input({ prompt = "Enter project name: " }, function(pname)
|
||||
pname = pname and vim.trim(pname)
|
||||
if not pname or pname == "" then return end
|
||||
local root = vim.fs.joinpath(
|
||||
vim.fn.expand(args.workspace_root),
|
||||
args[ft].root,
|
||||
pname
|
||||
)
|
||||
|
||||
local ctx = {
|
||||
project_name = pname,
|
||||
company_name = args.env.author,
|
||||
file_name = "",
|
||||
}
|
||||
local ctx = {
|
||||
project_name = pname,
|
||||
company_name = args.env.author,
|
||||
file_name = "",
|
||||
}
|
||||
|
||||
vim.fn.mkdir(root, "p")
|
||||
|
||||
local tpl = args[ft].templates or {}
|
||||
local dirs = args[ft].dirs
|
||||
if type(dirs) == "table" and next(dirs) then
|
||||
for _, dir in pairs(dirs) do
|
||||
local path = vim.fs.normalize(
|
||||
vim.fs.joinpath(root, fs.fmt_path(dir, nil, ctx))
|
||||
)
|
||||
vim.fn.mkdir(path, "p")
|
||||
end
|
||||
end
|
||||
|
||||
local bin
|
||||
local project = tpl.project
|
||||
if type(project) == "table" and next(project) then
|
||||
for tbl_name, tbl in pairs(project) do
|
||||
local raw_path = vim.fs.joinpath(tbl.path, tbl.name)
|
||||
local path = fs.fmt_path(raw_path, args[ft].dirs, ctx)
|
||||
if tbl_name == "primary" then
|
||||
bin = vim.fs.joinpath(root, path)
|
||||
end
|
||||
if tbl.kind then
|
||||
local abs_file_path =
|
||||
vim.fs.normalize(vim.fs.joinpath(root, path))
|
||||
local abs_dir_path = vim.fs.dirname(abs_file_path)
|
||||
if
|
||||
abs_dir_path ~= root
|
||||
and not vim.startswith(root, abs_dir_path)
|
||||
then
|
||||
vim.fn.mkdir(abs_dir_path, "p")
|
||||
end
|
||||
fs.write(
|
||||
abs_file_path,
|
||||
templates.fetch(tbl.kind_path, tbl.kind, ctx)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
local extras = tpl.extras
|
||||
if type(extras) == "table" and next(extras) then
|
||||
for _, tbl in pairs(extras) do
|
||||
if tbl.enabled ~= false and tbl.kind then
|
||||
local raw_path = vim.fs.joinpath(tbl.path, tbl.name)
|
||||
local path =
|
||||
fs.fmt_path(raw_path, args[ft].dirs, ctx)
|
||||
local abs_file_path =
|
||||
vim.fs.normalize(vim.fs.joinpath(root, path))
|
||||
local abs_dir_path = vim.fs.dirname(abs_file_path)
|
||||
if
|
||||
abs_dir_path ~= root
|
||||
and not vim.startswith(root, abs_dir_path)
|
||||
then
|
||||
vim.fn.mkdir(abs_dir_path, "p")
|
||||
end
|
||||
fs.write(
|
||||
abs_file_path,
|
||||
templates.fetch(tbl.kind_path, tbl.kind, ctx)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if type(langs.create_project) == "function" then
|
||||
langs.create_project(root)
|
||||
end
|
||||
|
||||
--- Init git
|
||||
local gitignore =
|
||||
require("vern-nvim.templates.extras.gitignore").template(ft)
|
||||
local obj = vim.system({ "git", "-C", root, "init" }):wait()
|
||||
if obj.code ~= 0 then
|
||||
vim.notify(
|
||||
"Git init failed " .. obj.stderr,
|
||||
vim.log.levels.ERROR,
|
||||
{ title = "Vern Git" }
|
||||
)
|
||||
end
|
||||
fs.write(vim.fs.joinpath(root, ".gitignore"), gitignore)
|
||||
|
||||
--- Init Readme
|
||||
local readme = require("vern-nvim.templates.extras.readme")
|
||||
fs.write(vim.fs.joinpath(root, "README.md"), readme)
|
||||
|
||||
if bin then vim.cmd.edit(vim.fn.fnameescape(bin)) end
|
||||
vim.notify(
|
||||
"Project: " .. pname .. " has been created!",
|
||||
vim.log.levels.INFO,
|
||||
{ title = "Vern Project" }
|
||||
)
|
||||
end)
|
||||
vim.fn.mkdir(root, "p")
|
||||
local dirs = args[ft].dirs
|
||||
if type(dirs) == "table" and next(dirs) then
|
||||
for _, dir in pairs(dirs) do
|
||||
local path = vim.fs.normalize(
|
||||
vim.fs.joinpath(root, fs.fmt_path(dir, nil, ctx))
|
||||
)
|
||||
vim.fn.mkdir(path, "p")
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
local function write(tpl)
|
||||
if type(tpl) == "table" and next(tpl) then
|
||||
for _, tbl in pairs(tpl) do
|
||||
local raw_path = vim.fs.joinpath(tbl.path, tbl.name)
|
||||
local path = fs.fmt_path(raw_path, args[ft].dirs, ctx)
|
||||
if tbl.enabled ~= false and tbl.kind then
|
||||
local abs_file_path =
|
||||
vim.fs.normalize(vim.fs.joinpath(root, path))
|
||||
local abs_dir_path = vim.fs.dirname(abs_file_path)
|
||||
if
|
||||
abs_dir_path ~= root
|
||||
and not vim.startswith(root, abs_dir_path)
|
||||
then
|
||||
vim.fn.mkdir(abs_dir_path, "p")
|
||||
end
|
||||
fs.write(
|
||||
abs_file_path,
|
||||
templates.fetch(tbl.kind_path, tbl.kind, ctx)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local tpl = args[ft].templates or {}
|
||||
|
||||
local bin
|
||||
local project = tpl.project
|
||||
if type(project) == "table" and next(project) then
|
||||
for tbl_name, tbl in pairs(project) do
|
||||
if tbl_name == "primary" then
|
||||
bin = vim.fs.joinpath(
|
||||
root,
|
||||
fs.fmt_path(
|
||||
vim.fs.joinpath(tbl.path, tbl.name),
|
||||
args[ft].dirs,
|
||||
ctx
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
write(project)
|
||||
write(tpl.extras)
|
||||
|
||||
if type(langs.create_project) == "function" then
|
||||
langs.create_project(root)
|
||||
end
|
||||
|
||||
--- Init git
|
||||
local gitignore =
|
||||
require("vern-nvim.templates.extras.gitignore").template(ft)
|
||||
local obj = vim.system({ "git", "-C", root, "init" }):wait()
|
||||
if obj.code ~= 0 then
|
||||
vim.notify(
|
||||
"Git init failed " .. obj.stderr,
|
||||
vim.log.levels.ERROR,
|
||||
{ title = "Vern Git" }
|
||||
)
|
||||
end
|
||||
fs.write(vim.fs.joinpath(root, ".gitignore"), gitignore)
|
||||
|
||||
--- Init Readme
|
||||
local readme = require("vern-nvim.templates.extras.readme")
|
||||
fs.write(vim.fs.joinpath(root, "README.md"), readme)
|
||||
|
||||
if bin then vim.cmd.edit(vim.fn.fnameescape(bin)) end
|
||||
vim.notify(
|
||||
"Project: " .. pname .. " has been created!",
|
||||
vim.log.levels.INFO,
|
||||
{ title = "Vern Project" }
|
||||
)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
M.create_file = function(opts)
|
||||
opts = opts or {}
|
||||
local filetype = vim.bo.filetype
|
||||
opts = opts or {}
|
||||
local filetype = vim.bo.filetype
|
||||
|
||||
local ft_ok, config = pcall(require, "vern-nvim.langs." .. filetype)
|
||||
local ft_ok, config = pcall(require, "vern-nvim.langs." .. filetype)
|
||||
if not filetype or filetype == "" or not ft_ok or type(config) ~= "table" then
|
||||
vim.notify("Unknown Filetype: " .. filetype, vim.log.levels.WARN, {
|
||||
title = "Vern File",
|
||||
})
|
||||
return
|
||||
else
|
||||
local args = vim.tbl_deep_extend("force", {}, config, opts or {})
|
||||
---@type VernCreateFile
|
||||
if
|
||||
not filetype
|
||||
or filetype == ""
|
||||
or not ft_ok
|
||||
or type(config) ~= "table"
|
||||
then
|
||||
vim.notify("Unknown Filetype: " .. filetype, vim.log.levels.WARN, {
|
||||
title = "Vern File",
|
||||
})
|
||||
return
|
||||
else
|
||||
local args = vim.tbl_deep_extend("force", {}, config, opts or {})
|
||||
local cf = args.create_file
|
||||
local function function_write(mod, fname)
|
||||
local raw_path = vim.fs.joinpath(mod.path, mod.name)
|
||||
local context = {
|
||||
project_name = fs.name(),
|
||||
company_name = args.env.author,
|
||||
file_name = fname,
|
||||
}
|
||||
local path =
|
||||
fs.fmt_path(raw_path, args[filetype].dirs or {}, context)
|
||||
local full_path = vim.fs.joinpath(fs.root(), path)
|
||||
fs.write(
|
||||
full_path,
|
||||
templates.fetch(mod.kind_path, mod.kind, context)
|
||||
)
|
||||
vim.cmd.edit(vim.fn.fnameescape(full_path))
|
||||
vim.notify(
|
||||
fname .. " has been created!",
|
||||
vim.log.levels.INFO,
|
||||
{ title = "Vern File" }
|
||||
)
|
||||
end
|
||||
|
||||
vim.ui.input({ prompt = "Enter file name: " }, function(fname)
|
||||
fname = fname and vim.trim(fname)
|
||||
if not fname or fname == "" then return end
|
||||
|
||||
local done = function(mod)
|
||||
if not mod or vim.tbl_isempty(mod) then return end
|
||||
function_write(mod, fname)
|
||||
end
|
||||
|
||||
if cf and type(cf) == "function" then
|
||||
cf(args, done)
|
||||
else
|
||||
done(args[filetype].templates.file.source)
|
||||
end
|
||||
end)
|
||||
local cf = args.create_file
|
||||
local function function_write(mod, fname)
|
||||
local raw_path = vim.fs.joinpath(mod.path, mod.name)
|
||||
local context = {
|
||||
project_name = fs.name(),
|
||||
company_name = args.env.author,
|
||||
file_name = fname,
|
||||
}
|
||||
local path = fs.fmt_path(raw_path, args[filetype].dirs or {}, context)
|
||||
local full_path = vim.fs.joinpath(fs.root(), path)
|
||||
fs.write(full_path, templates.fetch(mod.kind_path, mod.kind, context))
|
||||
vim.cmd.edit(vim.fn.fnameescape(full_path))
|
||||
vim.notify(
|
||||
fname .. " has been created!",
|
||||
vim.log.levels.INFO,
|
||||
{ title = "Vern File" }
|
||||
)
|
||||
end
|
||||
|
||||
vim.ui.input({ prompt = "Enter file name: " }, function(fname)
|
||||
fname = fname and vim.trim(fname)
|
||||
if not fname or fname == "" then return end
|
||||
|
||||
local done = function(mod)
|
||||
if not mod or vim.tbl_isempty(mod) then return end
|
||||
function_write(mod, fname)
|
||||
end
|
||||
|
||||
if cf and type(cf) == "function" then
|
||||
cf(args, done)
|
||||
else
|
||||
done(args[filetype].templates.file.source)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
M.run = function(opts)
|
||||
opts = opts or {}
|
||||
local filetype = vim.bo.filetype
|
||||
opts = opts or {}
|
||||
local filetype = vim.bo.filetype
|
||||
|
||||
local ft_ok, action = pcall(require, "vern-nvim.langs." .. filetype)
|
||||
if
|
||||
not filetype
|
||||
or filetype == ""
|
||||
or not ft_ok
|
||||
or type(action.run) ~= "function"
|
||||
then
|
||||
vim.notify("Unknown Filetype: " .. filetype, vim.log.levels.WARN, {
|
||||
title = "Vern Run",
|
||||
})
|
||||
return
|
||||
else
|
||||
local args = vim.tbl_deep_extend(
|
||||
"force",
|
||||
{},
|
||||
opts,
|
||||
require("vern-nvim.langs." .. filetype)
|
||||
)
|
||||
action.run(args)
|
||||
end
|
||||
local ft_ok, action = pcall(require, "vern-nvim.langs." .. filetype)
|
||||
if
|
||||
not filetype
|
||||
or filetype == ""
|
||||
or not ft_ok
|
||||
or type(action.run) ~= "function"
|
||||
then
|
||||
vim.notify("Unknown Filetype: " .. filetype, vim.log.levels.WARN, {
|
||||
title = "Vern Run",
|
||||
})
|
||||
return
|
||||
else
|
||||
local args = vim.tbl_deep_extend(
|
||||
"force",
|
||||
{},
|
||||
opts,
|
||||
require("vern-nvim.langs." .. filetype)
|
||||
)
|
||||
action.run(args)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -7,29 +7,22 @@ local term = require("vern-nvim.core.terminal")
|
||||
---@param build_cmd string
|
||||
---@param run_cmd string
|
||||
M.compile = function(opts, build_cmd, run_cmd)
|
||||
vim.system({ "sh", "-c", build_cmd }, { text = true }, function(obj)
|
||||
if obj.code ~= 0 then
|
||||
vim.schedule(function()
|
||||
local error_obj = (obj.stderr ~= "" and obj.stderr)
|
||||
or obj.stdout
|
||||
or ""
|
||||
local error_lines = vim.list_extend(
|
||||
{ "Error During compilation" },
|
||||
vim.split(error_obj, "\n", { trimempty = true })
|
||||
)
|
||||
local buf, _ = term.open(
|
||||
{ "echo 'compilation failed'" },
|
||||
opts.terminal,
|
||||
true
|
||||
)
|
||||
term.set_lines(buf, error_lines)
|
||||
end)
|
||||
else
|
||||
vim.schedule(
|
||||
function() term.open({ run_cmd }, opts.terminal, false) end
|
||||
)
|
||||
end
|
||||
end)
|
||||
vim.system({ "sh", "-c", build_cmd }, { text = true }, function(obj)
|
||||
if obj.code ~= 0 then
|
||||
vim.schedule(function()
|
||||
local error_obj = (obj.stderr ~= "" and obj.stderr) or obj.stdout or ""
|
||||
local error_lines = vim.list_extend(
|
||||
{ "Error During compilation" },
|
||||
vim.split(error_obj, "\n", { trimempty = true })
|
||||
)
|
||||
local buf, _ =
|
||||
term.open({ "echo 'compilation failed'" }, opts.terminal, true)
|
||||
term.set_lines(buf, error_lines)
|
||||
end)
|
||||
else
|
||||
vim.schedule(function() term.open({ run_cmd }, opts.terminal, false) end)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
return M
|
||||
+25
-25
@@ -5,45 +5,45 @@ local M = {}
|
||||
---@param ctx table<string, string> Strings to replace raw names like {project_name} with
|
||||
---@return string path Fully replaced path
|
||||
function M.fmt_path(raw_path, dir_tbl, ctx)
|
||||
--- Replace the {dirs.<key>}
|
||||
raw_path = raw_path:gsub(
|
||||
"{dirs%.([%w_]+)}",
|
||||
function(dir_key) return dir_tbl and dir_tbl[dir_key] or dir_key end
|
||||
)
|
||||
--- Replace the {dirs.<key>}
|
||||
raw_path = raw_path:gsub(
|
||||
"{dirs%.([%w_]+)}",
|
||||
function(dir_key) return dir_tbl and dir_tbl[dir_key] or dir_key end
|
||||
)
|
||||
|
||||
--- Replace the {<key>}
|
||||
local path = raw_path:gsub(
|
||||
"{([%w_]+)}",
|
||||
function(key) return ctx and ctx[key] or ("{" .. key .. "}") end
|
||||
)
|
||||
--- Replace the {<key>}
|
||||
local path = raw_path:gsub(
|
||||
"{([%w_]+)}",
|
||||
function(key) return ctx and ctx[key] or ("{" .. key .. "}") end
|
||||
)
|
||||
|
||||
return path
|
||||
return path
|
||||
end
|
||||
|
||||
---@param path string
|
||||
---@param content string
|
||||
function M.write(path, content)
|
||||
local file = assert(io.open(path, "w"), "Error creating file: " .. path)
|
||||
file:write(content)
|
||||
file:close()
|
||||
local file = assert(io.open(path, "w"), "Error creating file: " .. path)
|
||||
file:write(content)
|
||||
file:close()
|
||||
end
|
||||
|
||||
---@return string
|
||||
function M.name() return vim.fs.basename(M.proj_root()) or "" end
|
||||
function M.name() return vim.fs.basename(M.root()) or "" end
|
||||
|
||||
---@param bufnr? integer Default is 0 (current buffer)
|
||||
---@return string
|
||||
function M.root(bufnr)
|
||||
bufnr = bufnr or 0
|
||||
local root_markers = {
|
||||
".git",
|
||||
"pyproject.toml",
|
||||
"setup.py",
|
||||
"Makefile",
|
||||
"CMakeLists",
|
||||
"Cargo.toml",
|
||||
}
|
||||
return vim.fs.root(bufnr, root_markers) or vim.uv.cwd() or "."
|
||||
bufnr = bufnr or 0
|
||||
local root_markers = {
|
||||
".git",
|
||||
"pyproject.toml",
|
||||
"setup.py",
|
||||
"Makefile",
|
||||
"CMakeLists",
|
||||
"Cargo.toml",
|
||||
}
|
||||
return vim.fs.root(bufnr, root_markers) or vim.uv.cwd() or "."
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -1,9 +1,9 @@
|
||||
local M = {}
|
||||
|
||||
local registers = {
|
||||
project_name = "__PROJECT_NAME__",
|
||||
company_name = "__COMPANY_NAME__",
|
||||
file_name = "__FILE_NAME__",
|
||||
project_name = "__PROJECT_NAME__",
|
||||
company_name = "__COMPANY_NAME__",
|
||||
file_name = "__FILE_NAME__",
|
||||
}
|
||||
|
||||
---@param kind_path string Filetype of template
|
||||
@@ -11,27 +11,21 @@ local registers = {
|
||||
---@param context table<string, string> A string to replace temp values in template
|
||||
---@return string Content Formatted string
|
||||
function M.fetch(kind_path, kind, context)
|
||||
kind, context = kind or "", context or {}
|
||||
if not kind or kind == "" then
|
||||
return ""
|
||||
end
|
||||
local ok, mod = pcall(require, kind_path)
|
||||
if not ok or type(mod) ~= "table" or not mod[kind] then
|
||||
return ""
|
||||
end
|
||||
kind, context = kind or "", context or {}
|
||||
if not kind or kind == "" then return "" end
|
||||
local ok, mod = pcall(require, kind_path)
|
||||
if not ok or type(mod) ~= "table" or not mod[kind] then return "" end
|
||||
|
||||
local template = mod[kind] or ""
|
||||
context = context or {}
|
||||
local template = mod[kind] or ""
|
||||
context = context or {}
|
||||
|
||||
if ok and type(mod) == "table" then
|
||||
for key, placeholder in pairs(registers) do
|
||||
local value = context[key]
|
||||
if value then
|
||||
template = string.gsub(template, placeholder, value)
|
||||
end
|
||||
end
|
||||
if ok and type(mod) == "table" then
|
||||
for key, placeholder in pairs(registers) do
|
||||
local value = context[key]
|
||||
if value then template = string.gsub(template, placeholder, value) end
|
||||
end
|
||||
return template
|
||||
end
|
||||
return template
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -5,92 +5,92 @@ local M = {}
|
||||
---@param scratch boolean
|
||||
---@return integer, integer?
|
||||
function M.open(cmd, opts, scratch)
|
||||
opts = opts or {}
|
||||
local buf, win
|
||||
if opts.mode.type == "float" then
|
||||
local ui = vim.api.nvim_list_uis()[1]
|
||||
opts = opts or {}
|
||||
local buf, win
|
||||
if opts.mode.type == "float" then
|
||||
local ui = vim.api.nvim_list_uis()[1]
|
||||
|
||||
local dim = {
|
||||
width = math.max(
|
||||
1,
|
||||
math.floor(ui.width * 0.9)
|
||||
- opts.mode.win.float.padding.left
|
||||
- opts.mode.win.float.padding.right
|
||||
),
|
||||
height = math.max(
|
||||
1,
|
||||
math.floor(ui.height * 0.9)
|
||||
- opts.mode.win.float.padding.top
|
||||
- opts.mode.win.float.padding.bottom
|
||||
),
|
||||
}
|
||||
local dim = {
|
||||
width = math.max(
|
||||
1,
|
||||
math.floor(ui.width * 0.9)
|
||||
- opts.mode.win.float.padding.left
|
||||
- opts.mode.win.float.padding.right
|
||||
),
|
||||
height = math.max(
|
||||
1,
|
||||
math.floor(ui.height * 0.9)
|
||||
- opts.mode.win.float.padding.top
|
||||
- opts.mode.win.float.padding.bottom
|
||||
),
|
||||
}
|
||||
|
||||
local pos = {
|
||||
row = math.floor(
|
||||
(
|
||||
ui.height
|
||||
- (vim.o.laststatus == 3 and 1 or 0)
|
||||
- vim.o.cmdheight
|
||||
- dim.height
|
||||
) / 2
|
||||
),
|
||||
col = math.floor((ui.width - dim.width) / 2),
|
||||
}
|
||||
local pos = {
|
||||
row = math.floor(
|
||||
(
|
||||
ui.height
|
||||
- (vim.o.laststatus == 3 and 1 or 0)
|
||||
- vim.o.cmdheight
|
||||
- dim.height
|
||||
) / 2
|
||||
),
|
||||
col = math.floor((ui.width - dim.width) / 2),
|
||||
}
|
||||
|
||||
buf = vim.api.nvim_create_buf(false, true)
|
||||
win = vim.api.nvim_open_win(buf, true, {
|
||||
relative = "editor",
|
||||
width = dim.width,
|
||||
height = dim.height,
|
||||
row = pos.row,
|
||||
col = pos.col,
|
||||
style = "minimal",
|
||||
border = opts.mode.win.float.border.enabled
|
||||
and opts.mode.win.float.border.type
|
||||
or nil,
|
||||
})
|
||||
if scratch then return buf, win end
|
||||
buf = vim.api.nvim_create_buf(false, true)
|
||||
win = vim.api.nvim_open_win(buf, true, {
|
||||
relative = "editor",
|
||||
width = dim.width,
|
||||
height = dim.height,
|
||||
row = pos.row,
|
||||
col = pos.col,
|
||||
style = "minimal",
|
||||
border = opts.mode.win.float.border.enabled
|
||||
and opts.mode.win.float.border.type
|
||||
or nil,
|
||||
})
|
||||
if scratch then return buf, win end
|
||||
end
|
||||
if opts.mode.type == "split" then
|
||||
if opts.mode.win.split.direction == "vertical" then
|
||||
if opts.mode.win.split.anchor == "right" then
|
||||
vim.cmd("set splitright")
|
||||
end
|
||||
vim.cmd(opts.mode.win.split.size .. " vsplit")
|
||||
end
|
||||
if opts.mode.type == "split" then
|
||||
if opts.mode.win.split.direction == "vertical" then
|
||||
if opts.mode.win.split.anchor == "right" then
|
||||
vim.cmd("set splitright")
|
||||
end
|
||||
vim.cmd(opts.mode.win.split.size .. " vsplit")
|
||||
end
|
||||
if opts.mode.win.split.direction == "horizontal" then
|
||||
if opts.mode.win.split.anchor == "bottom" then
|
||||
vim.cmd("set splitbelow")
|
||||
end
|
||||
vim.cmd(opts.mode.win.split.size .. " split")
|
||||
end
|
||||
|
||||
buf = vim.api.nvim_create_buf(false, true)
|
||||
win = vim.api.nvim_get_current_win()
|
||||
|
||||
vim.api.nvim_win_set_buf(0, buf)
|
||||
if scratch then return buf, win end
|
||||
if opts.mode.win.split.direction == "horizontal" then
|
||||
if opts.mode.win.split.anchor == "bottom" then
|
||||
vim.cmd("set splitbelow")
|
||||
end
|
||||
vim.cmd(opts.mode.win.split.size .. " split")
|
||||
end
|
||||
local full_cmd = type(cmd) == "table" and table.concat(cmd, " ") or cmd
|
||||
vim.fn.jobstart(full_cmd, { term = true })
|
||||
vim.api.nvim_buf_set_keymap(
|
||||
buf,
|
||||
"n",
|
||||
"<ESC>",
|
||||
"i<C-\\><C-n>:q<CR>",
|
||||
{ noremap = true, silent = true }
|
||||
)
|
||||
return buf, win
|
||||
|
||||
buf = vim.api.nvim_create_buf(false, true)
|
||||
win = vim.api.nvim_get_current_win()
|
||||
|
||||
vim.api.nvim_win_set_buf(0, buf)
|
||||
if scratch then return buf, win end
|
||||
end
|
||||
local full_cmd = type(cmd) == "table" and table.concat(cmd, " ") or cmd
|
||||
vim.fn.jobstart(full_cmd, { term = true })
|
||||
vim.api.nvim_buf_set_keymap(
|
||||
buf,
|
||||
"n",
|
||||
"<ESC>",
|
||||
"i<C-\\><C-n>:q<CR>",
|
||||
{ noremap = true, silent = true }
|
||||
)
|
||||
return buf, win
|
||||
end
|
||||
|
||||
---@param buf integer
|
||||
---@param lines table
|
||||
function M.set_lines(buf, lines)
|
||||
if buf and vim.api.nvim_buf_is_valid(buf) then
|
||||
vim.api.nvim_set_option_value("modifiable", true, { buf = buf })
|
||||
vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
|
||||
vim.api.nvim_set_option_value("modifiable", false, { buf = buf })
|
||||
end
|
||||
if buf and vim.api.nvim_buf_is_valid(buf) then
|
||||
vim.api.nvim_set_option_value("modifiable", true, { buf = buf })
|
||||
vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
|
||||
vim.api.nvim_set_option_value("modifiable", false, { buf = buf })
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
+48
-58
@@ -6,70 +6,60 @@ local defaults = require("vern-nvim.config.defaults")
|
||||
---@type VernCoreConfig
|
||||
M.opts = vim.deepcopy(defaults)
|
||||
|
||||
---@class VernUserConfig
|
||||
---@field workspace_root? string
|
||||
---@field keybinds? table<string, VernKeybindItem>
|
||||
---@field terminal? VernTerminalConfig | table
|
||||
|
||||
---@param user_opts? VernUserConfig
|
||||
function M.setup(user_opts)
|
||||
---@type VernCoreConfig
|
||||
M.opts = vim.tbl_deep_extend("force", {}, defaults, user_opts or {})
|
||||
---@type VernCoreConfig
|
||||
M.opts = vim.tbl_deep_extend("force", {}, defaults, user_opts or {})
|
||||
|
||||
for key, def in pairs(M.opts.keybinds or {}) do
|
||||
if type(def.action) == "function" then
|
||||
vim.api.nvim_create_user_command(
|
||||
def.user_command,
|
||||
function() def.action(M.opts) end,
|
||||
{ nargs = "*", desc = def.desc }
|
||||
)
|
||||
vim.keymap.set("n", key, function() def.action(M.opts) end, {
|
||||
silent = true,
|
||||
desc = def.desc,
|
||||
})
|
||||
end
|
||||
for key, def in pairs(M.opts.keybinds or {}) do
|
||||
if type(def.action) == "function" then
|
||||
vim.api.nvim_create_user_command(
|
||||
def.user_command,
|
||||
function() def.action(M.opts) end,
|
||||
{ nargs = "*", desc = def.desc }
|
||||
)
|
||||
vim.keymap.set("n", key, function() def.action(M.opts) end, {
|
||||
silent = true,
|
||||
desc = def.desc,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
if not ft or ft == "" then return end
|
||||
local ok, mod = pcall(require, "vern-nvim.langs." .. ft)
|
||||
if not ok then return end
|
||||
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
|
||||
if not ft or ft == "" then return end
|
||||
local ok, mod = pcall(require, "vern-nvim.langs." .. ft)
|
||||
if not ok then return end
|
||||
|
||||
local opts = vim.tbl_deep_extend("force", {}, mod, M.opts or {})
|
||||
if opts[ft] and opts[ft].keybinds ~= nil then
|
||||
for key, def in pairs(opts[ft].keybinds or {}) do
|
||||
if type(def.action) == "function" then
|
||||
vim.api.nvim_buf_create_user_command(
|
||||
args.buf,
|
||||
def.user_command,
|
||||
function() def.action(opts) end,
|
||||
{ nargs = "*", desc = def.desc }
|
||||
)
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
key,
|
||||
function() def.action(opts) end,
|
||||
{
|
||||
buffer = args.buf,
|
||||
silent = true,
|
||||
desc = def.desc,
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
if ok and type(mod.attach) == "function" then
|
||||
mod.attach(args.buf, opts)
|
||||
end
|
||||
end,
|
||||
desc = "Attach languages to buffer",
|
||||
})
|
||||
local opts = vim.tbl_deep_extend("force", {}, mod, M.opts or {})
|
||||
if opts[ft] and opts[ft].keybinds ~= nil then
|
||||
for key, def in pairs(opts[ft].keybinds or {}) do
|
||||
if type(def.action) == "function" then
|
||||
vim.api.nvim_buf_create_user_command(
|
||||
args.buf,
|
||||
def.user_command,
|
||||
function() def.action(opts) end,
|
||||
{ nargs = "*", desc = def.desc }
|
||||
)
|
||||
vim.keymap.set("n", key, function() def.action(opts) end, {
|
||||
buffer = args.buf,
|
||||
silent = true,
|
||||
desc = def.desc,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
if ok and type(mod.attach) == "function" then
|
||||
mod.attach(args.buf, opts)
|
||||
end
|
||||
end,
|
||||
desc = "Attach languages to buffer",
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
+70
-70
@@ -1,5 +1,5 @@
|
||||
---@module "vern-nvim.core.fs"
|
||||
local fs = require("vern-nvim.fs")
|
||||
local fs = require("vern-nvim.core.fs")
|
||||
|
||||
---@module "vern-nvim.core.compile"
|
||||
local comp = require("vern-nvim.core.compile")
|
||||
@@ -10,92 +10,92 @@ M.attach = nil
|
||||
|
||||
---@param root string
|
||||
M.create_project = function(root)
|
||||
local build_cmd = "cd "
|
||||
.. root
|
||||
.. " && cmake -S . -B build && cmake --build build"
|
||||
local _ = vim.system({ "sh", "-c", build_cmd }):wait()
|
||||
local build_cmd = "cd "
|
||||
.. root
|
||||
.. " && cmake -S . -B build && cmake --build build"
|
||||
local _ = vim.system({ "sh", "-c", build_cmd }):wait()
|
||||
end
|
||||
|
||||
---@type VernCreateFile
|
||||
---@param opts VernCConfig
|
||||
M.create_file = function(opts, continue)
|
||||
opts = opts or {}
|
||||
local file = vim.tbl_get(opts, "c", "templates", "file")
|
||||
local items = { "source", "header" }
|
||||
vim.ui.select(items, {
|
||||
prompt = "Select type:",
|
||||
format_item = function(item) return item end,
|
||||
}, function(choice, _)
|
||||
if choice == items[1] then return continue(file.source) end
|
||||
if choice == items[2] then return continue(file.header) end
|
||||
continue(nil)
|
||||
end)
|
||||
opts = opts or {}
|
||||
local file = vim.tbl_get(opts, "c", "templates", "file")
|
||||
local items = { "source", "header" }
|
||||
vim.ui.select(items, {
|
||||
prompt = "Select type:",
|
||||
format_item = function(item) return item end,
|
||||
}, function(choice, _)
|
||||
if choice == items[1] then return continue(file.source) end
|
||||
if choice == items[2] then return continue(file.header) end
|
||||
continue(nil)
|
||||
end)
|
||||
end
|
||||
|
||||
---@param opts? VernCConfig Takes a table for the runtime
|
||||
M.run = function(opts)
|
||||
opts = opts or {}
|
||||
opts = opts or {}
|
||||
|
||||
local build_dir = vim.fn.fnameescape((fs.root() or ".") .. "/build")
|
||||
local build_cmd = string.format("cd %s && cmake --build .", build_dir)
|
||||
local run_cmd = string.format("cd %s && ./%s", build_dir, fs.name())
|
||||
local build_dir = vim.fn.fnameescape(fs.root() .. "/build")
|
||||
local build_cmd = string.format("cd %s && cmake --build .", build_dir)
|
||||
local run_cmd = string.format("cd %s && ./%s", build_dir, fs.name())
|
||||
|
||||
comp.compile(opts, build_cmd, run_cmd)
|
||||
comp.compile(opts, build_cmd, run_cmd)
|
||||
end
|
||||
|
||||
---@type VernLanguageConfig
|
||||
M.c = {
|
||||
root = "C",
|
||||
dirs = {
|
||||
src = "src",
|
||||
include = "include/{project_name}",
|
||||
root = "C",
|
||||
dirs = {
|
||||
src = "src",
|
||||
include = "include/{project_name}",
|
||||
},
|
||||
keybinds = nil,
|
||||
templates = {
|
||||
project = {
|
||||
primary = {
|
||||
path = "{dirs.src}",
|
||||
name = "main.c",
|
||||
kind = "main",
|
||||
kind_path = "vern-nvim.templates.c",
|
||||
},
|
||||
manifest = {
|
||||
path = ".",
|
||||
name = "CMakeLists.txt",
|
||||
kind = "CmakeLists",
|
||||
kind_path = "vern-nvim.templates.c",
|
||||
},
|
||||
style = {
|
||||
path = ".",
|
||||
name = ".clang-format",
|
||||
kind = "format",
|
||||
kind_path = "vern-nvim.templates.c",
|
||||
},
|
||||
},
|
||||
keybinds = nil,
|
||||
templates = {
|
||||
project = {
|
||||
primary = {
|
||||
path = "{dirs.src}",
|
||||
name = "main.c",
|
||||
kind = "main",
|
||||
kind_path = "vern-nvim.templates.c",
|
||||
},
|
||||
manifest = {
|
||||
path = ".",
|
||||
name = "CMakeLists.txt",
|
||||
kind = "CmakeLists",
|
||||
kind_path = "vern-nvim.templates.c",
|
||||
},
|
||||
style = {
|
||||
path = ".",
|
||||
name = ".clang-format",
|
||||
kind = "format",
|
||||
kind_path = "vern-nvim.templates.c",
|
||||
},
|
||||
},
|
||||
file = {
|
||||
header = {
|
||||
path = "{dirs.include}",
|
||||
name = "{file_name}.h",
|
||||
kind = "header",
|
||||
kind_path = "vern-nvim.templates.c",
|
||||
},
|
||||
source = {
|
||||
path = "{dirs.src}",
|
||||
name = "{file_name}.c",
|
||||
kind = "source",
|
||||
kind_path = "vern-nvim.templates.c",
|
||||
},
|
||||
},
|
||||
extras = {
|
||||
linter = {
|
||||
path = ".",
|
||||
name = ".clang-tidy",
|
||||
kind = "linter",
|
||||
kind_path = "vern-nvim.templates.c",
|
||||
enabled = false,
|
||||
},
|
||||
},
|
||||
file = {
|
||||
header = {
|
||||
path = "{dirs.include}",
|
||||
name = "{file_name}.h",
|
||||
kind = "header",
|
||||
kind_path = "vern-nvim.templates.c",
|
||||
},
|
||||
source = {
|
||||
path = "{dirs.src}",
|
||||
name = "{file_name}.c",
|
||||
kind = "source",
|
||||
kind_path = "vern-nvim.templates.c",
|
||||
},
|
||||
},
|
||||
extras = {
|
||||
linter = {
|
||||
path = ".",
|
||||
name = ".clang-tidy",
|
||||
kind = "linter",
|
||||
kind_path = "vern-nvim.templates.c",
|
||||
enabled = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
||||
+69
-69
@@ -10,92 +10,92 @@ M.attach = nil
|
||||
|
||||
---@param root string
|
||||
M.create_project = function(root)
|
||||
local build_cmd = "cd "
|
||||
.. root
|
||||
.. " && cmake -S . -B build && cmake --build build"
|
||||
local _ = vim.system({ "sh", "-c", build_cmd }):wait()
|
||||
local build_cmd = "cd "
|
||||
.. root
|
||||
.. " && cmake -S . -B build && cmake --build build"
|
||||
local _ = vim.system({ "sh", "-c", build_cmd }):wait()
|
||||
end
|
||||
|
||||
---@type VernCreateFile
|
||||
---@param opts VernCPPConfig
|
||||
M.create_file = function(opts, continue)
|
||||
opts = opts or {}
|
||||
local file = vim.tbl_get(opts, "cpp", "templates", "file")
|
||||
local items = { "source", "header" }
|
||||
vim.ui.select(items, {
|
||||
prompt = "Select type:",
|
||||
format_item = function(item) return item end,
|
||||
}, function(choice, _)
|
||||
if choice == items[1] then return continue(file.source) end
|
||||
if choice == items[2] then return continue(file.header) end
|
||||
continue(nil)
|
||||
end)
|
||||
opts = opts or {}
|
||||
local file = vim.tbl_get(opts, "cpp", "templates", "file")
|
||||
local items = { "source", "header" }
|
||||
vim.ui.select(items, {
|
||||
prompt = "Select type:",
|
||||
format_item = function(item) return item end,
|
||||
}, function(choice, _)
|
||||
if choice == items[1] then return continue(file.source) end
|
||||
if choice == items[2] then return continue(file.header) end
|
||||
continue(nil)
|
||||
end)
|
||||
end
|
||||
|
||||
---@param opts? VernCPPConfig Takes a table for the runtime
|
||||
M.run = function(opts)
|
||||
opts = opts or {}
|
||||
opts = opts or {}
|
||||
|
||||
local build_dir = vim.fn.fnameescape((fs.root() or ".") .. "/build")
|
||||
local build_cmd = string.format("cd %s && cmake --build .", build_dir)
|
||||
local run_cmd = string.format("cd %s && ./%s", build_dir, fs.name())
|
||||
local build_dir = vim.fn.fnameescape(fs.root() .. "/build")
|
||||
local build_cmd = string.format("cd %s && cmake --build .", build_dir)
|
||||
local run_cmd = string.format("cd %s && ./%s", build_dir, fs.name())
|
||||
|
||||
comp.compile(opts, build_cmd, run_cmd)
|
||||
comp.compile(opts, build_cmd, run_cmd)
|
||||
end
|
||||
|
||||
---@type VernLanguageConfig
|
||||
M.cpp = {
|
||||
root = "CPP",
|
||||
dirs = {
|
||||
src = "src",
|
||||
include = "include/{project_name}",
|
||||
root = "CPP",
|
||||
dirs = {
|
||||
src = "src",
|
||||
include = "include/{project_name}",
|
||||
},
|
||||
keybinds = nil,
|
||||
templates = {
|
||||
project = {
|
||||
primary = {
|
||||
path = "{dirs.src}",
|
||||
name = "main.cpp",
|
||||
kind = "main",
|
||||
kind_path = "vern-nvim.templates.cpp",
|
||||
},
|
||||
manifest = {
|
||||
path = ".",
|
||||
name = "CMakeLists.txt",
|
||||
kind = "CmakeLists",
|
||||
kind_path = "vern-nvim.templates.cpp",
|
||||
},
|
||||
style = {
|
||||
path = ".",
|
||||
name = ".clang-format",
|
||||
kind = "format",
|
||||
kind_path = "vern-nvim.templates.cpp",
|
||||
},
|
||||
},
|
||||
keybinds = nil,
|
||||
templates = {
|
||||
project = {
|
||||
primary = {
|
||||
path = "{dirs.src}",
|
||||
name = "main.cpp",
|
||||
kind = "main",
|
||||
kind_path = "vern-nvim.templates.cpp",
|
||||
},
|
||||
manifest = {
|
||||
path = ".",
|
||||
name = "CMakeLists.txt",
|
||||
kind = "CmakeLists",
|
||||
kind_path = "vern-nvim.templates.cpp",
|
||||
},
|
||||
style = {
|
||||
path = ".",
|
||||
name = ".clang-format",
|
||||
kind = "format",
|
||||
kind_path = "vern-nvim.templates.cpp",
|
||||
},
|
||||
},
|
||||
file = {
|
||||
header = {
|
||||
path = "{dirs.include}",
|
||||
name = "{file_name}.hpp",
|
||||
kind = "header",
|
||||
kind_path = "vern-nvim.templates.cpp",
|
||||
},
|
||||
source = {
|
||||
path = "{dirs.src}",
|
||||
name = "{file_name}.cpp",
|
||||
kind = "source",
|
||||
kind_path = "vern-nvim.templates.cpp",
|
||||
},
|
||||
},
|
||||
extras = {
|
||||
linter = {
|
||||
path = ".",
|
||||
name = ".clang-tidy",
|
||||
kind = "linter",
|
||||
kind_path = "vern-nvim.templates.cpp",
|
||||
enabled = false,
|
||||
},
|
||||
},
|
||||
file = {
|
||||
header = {
|
||||
path = "{dirs.include}",
|
||||
name = "{file_name}.hpp",
|
||||
kind = "header",
|
||||
kind_path = "vern-nvim.templates.cpp",
|
||||
},
|
||||
source = {
|
||||
path = "{dirs.src}",
|
||||
name = "{file_name}.cpp",
|
||||
kind = "source",
|
||||
kind_path = "vern-nvim.templates.cpp",
|
||||
},
|
||||
},
|
||||
extras = {
|
||||
linter = {
|
||||
path = ".",
|
||||
name = ".clang-tidy",
|
||||
kind = "linter",
|
||||
kind_path = "vern-nvim.templates.cpp",
|
||||
enabled = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
||||
@@ -0,0 +1,77 @@
|
||||
---@module "vern-nvim.core.fs"
|
||||
local fs = require("vern-nvim.core.fs")
|
||||
|
||||
---@module "vern-nvim.core.terminal"
|
||||
local term = require("vern-nvim.core.terminal")
|
||||
|
||||
local M = {}
|
||||
|
||||
M.attach = nil
|
||||
|
||||
M.create_project = function(root)
|
||||
local obj = vim
|
||||
.system({
|
||||
"go",
|
||||
"mod",
|
||||
"init",
|
||||
"com.DarthMooMancer." .. vim.fs.basename(root),
|
||||
})
|
||||
:wait()
|
||||
if obj.code ~= 0 then
|
||||
vim.notify(
|
||||
"Go init failed" .. obj.stderr,
|
||||
vim.log.levels.ERROR,
|
||||
{ title = "Vern Go" }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
---@type VernCreateFile
|
||||
M.create_file = nil
|
||||
|
||||
---@param opts VernPythonConfig Takes a table for the runtime
|
||||
M.run = function(opts)
|
||||
opts = opts or {}
|
||||
local root = fs.root()
|
||||
-- local context = {
|
||||
-- project_name = fs.name(),
|
||||
-- company_name = opts.env.author,
|
||||
-- file_name = "",
|
||||
-- }
|
||||
-- local bin = vim.tbl_get(opts.python.templates.project.primary)
|
||||
--
|
||||
-- local exe = vim.fs.joinpath(bin.path, bin.name)
|
||||
-- local exe_path = fs.fmt_path(exe, opts.python.dirs, context)
|
||||
-- local full_path = vim.fs.joinpath(vim.fn.expand(root), exe_path)
|
||||
|
||||
term.open({ "go run ", root .. "/main.go" }, opts.terminal or {}, false)
|
||||
end
|
||||
|
||||
---@type VernLanguageConfig
|
||||
M.go = {
|
||||
root = "Go",
|
||||
dirs = {
|
||||
src = "",
|
||||
},
|
||||
keybinds = nil,
|
||||
templates = {
|
||||
project = {
|
||||
primary = {
|
||||
path = "{dirs.src}",
|
||||
name = "main.go",
|
||||
kind = "main",
|
||||
kind_path = "vern-nvim.templates.go",
|
||||
},
|
||||
},
|
||||
file = {
|
||||
source = {
|
||||
path = "{dirs.src}",
|
||||
name = "{file_name}.go",
|
||||
kind = "module",
|
||||
kind_path = "vern-nvim.templates.go",
|
||||
},
|
||||
},
|
||||
extras = nil,
|
||||
},
|
||||
}
|
||||
return M
|
||||
@@ -15,67 +15,67 @@ M.create_file = nil
|
||||
|
||||
---@param opts VernJavaConfig Takes a table for the runtime
|
||||
M.run = function(opts)
|
||||
opts = opts or {}
|
||||
local root = fs.root()
|
||||
local context = {
|
||||
project_name = fs.name()(),
|
||||
company_name = opts.env.author,
|
||||
file_name = "",
|
||||
}
|
||||
opts = opts or {}
|
||||
local root = fs.root()
|
||||
local context = {
|
||||
project_name = fs.name(),
|
||||
company_name = opts.env.author,
|
||||
file_name = "",
|
||||
}
|
||||
|
||||
local src_root = vim.fs.joinpath(
|
||||
root,
|
||||
fs.fmt_path(opts.java.dirs.src, opts.java.dirs, context)
|
||||
)
|
||||
local build_dir = root .. "/bin"
|
||||
local build_cmd = string.format(
|
||||
"javac -d %s -sourcepath %s $(find %s -name '*java')",
|
||||
build_dir,
|
||||
src_root,
|
||||
src_root
|
||||
)
|
||||
local run_cmd = string.format(
|
||||
"java -cp %s com.%s.%s.Main",
|
||||
build_dir,
|
||||
context.company_name,
|
||||
context.project_name
|
||||
)
|
||||
local src_root = vim.fs.joinpath(
|
||||
root,
|
||||
fs.fmt_path(opts.java.dirs.src, opts.java.dirs, context)
|
||||
)
|
||||
local build_dir = root .. "/bin"
|
||||
local build_cmd = string.format(
|
||||
"javac -d %s -sourcepath %s $(find %s -name '*java')",
|
||||
build_dir,
|
||||
src_root,
|
||||
src_root
|
||||
)
|
||||
local run_cmd = string.format(
|
||||
"java -cp %s com.%s.%s.Main",
|
||||
build_dir,
|
||||
context.company_name,
|
||||
context.project_name
|
||||
)
|
||||
|
||||
comp.compile(opts, build_cmd, run_cmd)
|
||||
comp.compile(opts, build_cmd, run_cmd)
|
||||
end
|
||||
|
||||
---@type VernLanguageConfig
|
||||
M.java = {
|
||||
root = "Java",
|
||||
dirs = {
|
||||
src = "src/com/{company_name}/{project_name}",
|
||||
bin = "bin",
|
||||
root = "Java",
|
||||
dirs = {
|
||||
src = "src/com/{company_name}/{project_name}",
|
||||
bin = "bin",
|
||||
},
|
||||
keybinds = nil,
|
||||
templates = {
|
||||
project = {
|
||||
primary = {
|
||||
path = "{dirs.src}",
|
||||
name = "Main.java",
|
||||
kind = "main",
|
||||
kind_path = "vern-nvim.templates.java",
|
||||
},
|
||||
style = {
|
||||
path = ".",
|
||||
name = ".clang-format",
|
||||
kind = "format",
|
||||
kind_path = "vern-nvim.templates.java",
|
||||
},
|
||||
},
|
||||
keybinds = nil,
|
||||
templates = {
|
||||
project = {
|
||||
primary = {
|
||||
path = "{dirs.src}",
|
||||
name = "Main.java",
|
||||
kind = "main",
|
||||
kind_path = "vern-nvim.templates.java",
|
||||
},
|
||||
style = {
|
||||
path = ".",
|
||||
name = ".clang-format",
|
||||
kind = "format",
|
||||
kind_path = "vern-nvim.templates.java",
|
||||
},
|
||||
},
|
||||
file = {
|
||||
source = {
|
||||
path = "{dirs.src}",
|
||||
name = "{file_name}.java",
|
||||
kind = "source",
|
||||
kind_path = "vern-nvim.templates.java",
|
||||
},
|
||||
},
|
||||
extras = nil,
|
||||
file = {
|
||||
source = {
|
||||
path = "{dirs.src}",
|
||||
name = "{file_name}.java",
|
||||
kind = "source",
|
||||
kind_path = "vern-nvim.templates.java",
|
||||
},
|
||||
},
|
||||
extras = nil,
|
||||
},
|
||||
}
|
||||
return M
|
||||
+33
-33
@@ -1,5 +1,5 @@
|
||||
---@module "vern-nvim.core.fs"
|
||||
local fs = require("vern-nvim.fs")
|
||||
local fs = require("vern-nvim.core.fs")
|
||||
|
||||
---@module "vern-nvim.core.terminal"
|
||||
local term = require("vern-nvim.core.terminal")
|
||||
@@ -15,45 +15,45 @@ M.create_file = nil
|
||||
|
||||
---@param opts VernLuaConfig Takes a table for the runtime
|
||||
M.run = function(opts)
|
||||
opts = opts or {}
|
||||
opts = opts or {}
|
||||
|
||||
term.open({
|
||||
"lua " .. vim.fs.joinpath(fs.root(), "lua", fs.name(), "/init.lua"),
|
||||
}, opts.terminal or {}, false)
|
||||
term.open({
|
||||
"lua " .. vim.fs.joinpath(fs.root(), "lua", fs.name(), "/init.lua"),
|
||||
}, opts.terminal or {}, false)
|
||||
end
|
||||
|
||||
---@type VernLanguageConfig
|
||||
M.lua = {
|
||||
root = "Lua",
|
||||
dirs = {
|
||||
src = "lua/{project_name}",
|
||||
root = "Lua",
|
||||
dirs = {
|
||||
src = "lua/{project_name}",
|
||||
},
|
||||
keybinds = nil,
|
||||
templates = {
|
||||
project = {
|
||||
primary = {
|
||||
path = "{dirs.src}",
|
||||
name = "init.lua",
|
||||
kind = "main",
|
||||
kind_path = "vern-nvim.templates.lua",
|
||||
},
|
||||
style = {
|
||||
path = ".",
|
||||
name = "stylua.toml",
|
||||
kind = "format",
|
||||
kind_path = "vern-nvim.templates.lua",
|
||||
},
|
||||
},
|
||||
keybinds = nil,
|
||||
templates = {
|
||||
project = {
|
||||
primary = {
|
||||
path = "{dirs.src}",
|
||||
name = "init.lua",
|
||||
kind = "init",
|
||||
kind_path = "vern-nvim.templates.lua",
|
||||
},
|
||||
style = {
|
||||
path = ".",
|
||||
name = "stylua.toml",
|
||||
kind = "format",
|
||||
kind_path = "vern-nvim.templates.lua",
|
||||
},
|
||||
},
|
||||
file = {
|
||||
source = {
|
||||
path = "{dirs.src}",
|
||||
name = "{file_name}.lua",
|
||||
kind = "source",
|
||||
kind_path = "vern-nvim.templates.lua",
|
||||
},
|
||||
},
|
||||
extras = nil,
|
||||
file = {
|
||||
source = {
|
||||
path = "{dirs.src}",
|
||||
name = "{file_name}.lua",
|
||||
kind = "source",
|
||||
kind_path = "vern-nvim.templates.lua",
|
||||
},
|
||||
},
|
||||
extras = nil,
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
||||
+102
-103
@@ -1,5 +1,5 @@
|
||||
---@module "vern-nvim.core.fs"
|
||||
local fs = require("vern-nvim.fs")
|
||||
local fs = require("vern-nvim.core.fs")
|
||||
|
||||
---@module "vern-nvim.core.terminal"
|
||||
local term = require("vern-nvim.core.terminal")
|
||||
@@ -7,30 +7,30 @@ local term = require("vern-nvim.core.terminal")
|
||||
local M = {}
|
||||
|
||||
M.attach = function()
|
||||
local root = fs.root()
|
||||
if not root then return end
|
||||
local venv_dir = nil
|
||||
if vim.uv.fs_stat(root .. "/venv/bin/python") then
|
||||
venv_dir = root .. "/venv"
|
||||
elseif vim.uv.fs_stat(root .. "/.venv/bin/python") then
|
||||
venv_dir = root .. "/.venv"
|
||||
end
|
||||
if venv_dir then
|
||||
vim.env.VIRTUAL_ENV = venv_dir
|
||||
vim.env.PATH = venv_dir .. "/bin:" .. vim.env.PATH
|
||||
end
|
||||
local root = fs.root()
|
||||
if not root then return end
|
||||
local venv_dir = nil
|
||||
if vim.uv.fs_stat(root .. "/venv/bin/python") then
|
||||
venv_dir = root .. "/venv"
|
||||
elseif vim.uv.fs_stat(root .. "/.venv/bin/python") then
|
||||
venv_dir = root .. "/.venv"
|
||||
end
|
||||
if venv_dir then
|
||||
vim.env.VIRTUAL_ENV = venv_dir
|
||||
vim.env.PATH = venv_dir .. "/bin:" .. vim.env.PATH
|
||||
end
|
||||
end
|
||||
|
||||
---@param root string
|
||||
M.create_project = function(root)
|
||||
local obj = vim.system({ "python3", "-m", "venv", root .. "/venv" }):wait()
|
||||
if obj.code ~= 0 then
|
||||
vim.notify(
|
||||
"Virtual environment failed to initialize " .. obj.stderr,
|
||||
vim.log.levels.ERROR,
|
||||
{ title = "Vern Python" }
|
||||
)
|
||||
end
|
||||
local obj = vim.system({ "python3", "-m", "venv", root .. "/venv" }):wait()
|
||||
if obj.code ~= 0 then
|
||||
vim.notify(
|
||||
"Virtual environment failed to initialize " .. obj.stderr,
|
||||
vim.log.levels.ERROR,
|
||||
{ title = "Vern Python" }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
---@type VernCreateFile
|
||||
@@ -38,102 +38,101 @@ M.create_file = nil
|
||||
|
||||
---@param opts VernPythonConfig Takes a table for the runtime
|
||||
M.run = function(opts)
|
||||
opts = opts or {}
|
||||
local root = fs.root() or "."
|
||||
local context = {
|
||||
project_name = fs.name(),
|
||||
company_name = opts.env.author,
|
||||
file_name = "",
|
||||
}
|
||||
local bin = opts.python.templates.project.primary
|
||||
opts = opts or {}
|
||||
local root = fs.root()
|
||||
local context = {
|
||||
project_name = fs.name(),
|
||||
company_name = opts.env.author,
|
||||
file_name = "",
|
||||
}
|
||||
local bin = vim.tbl_get(opts.python.templates.project.primary)
|
||||
|
||||
local exe = vim.fs.joinpath(bin.path, bin.name)
|
||||
or "src/{project_name}/main.py"
|
||||
local exe_path = fs.fmt_path(exe, opts.python.dirs, context)
|
||||
local full_path = vim.fs.joinpath(vim.fn.expand(root), exe_path)
|
||||
local exe = vim.fs.joinpath(bin.path, bin.name)
|
||||
local exe_path = fs.fmt_path(exe, opts.python.dirs, context)
|
||||
local full_path = vim.fs.joinpath(vim.fn.expand(root), exe_path)
|
||||
|
||||
term.open({ "python3 " .. full_path }, opts.terminal or {}, false)
|
||||
term.open({ "python3 " .. full_path }, opts.terminal or {}, false)
|
||||
end
|
||||
|
||||
M.pip_install = function()
|
||||
vim.ui.input({ prompt = "Enter pip module: " }, function(mod)
|
||||
mod = mod and vim.trim(mod)
|
||||
if not mod or mod == "" then
|
||||
vim.notify(
|
||||
"Pip Cancelled",
|
||||
vim.log.levels.WARN,
|
||||
{ title = "Vern Python" }
|
||||
)
|
||||
return
|
||||
end
|
||||
vim.notify(
|
||||
"Installing " .. mod,
|
||||
vim.ui.input({ prompt = "Enter pip module: " }, function(mod)
|
||||
mod = mod and vim.trim(mod)
|
||||
if not mod or mod == "" then
|
||||
vim.notify(
|
||||
"Pip Cancelled",
|
||||
vim.log.levels.WARN,
|
||||
{ title = "Vern Python" }
|
||||
)
|
||||
return
|
||||
end
|
||||
vim.notify(
|
||||
"Installing " .. mod,
|
||||
vim.log.levels.INFO,
|
||||
{ title = "Vern Python" }
|
||||
)
|
||||
vim.system({ "pip", "install", mod }, { text = true }, function(obj)
|
||||
vim.schedule(function()
|
||||
if obj.code ~= 0 then
|
||||
vim.notify(
|
||||
"Pip failed: " .. obj.stderr,
|
||||
vim.log.levels.WARN,
|
||||
{ title = "Vern Python" }
|
||||
)
|
||||
else
|
||||
vim.notify(
|
||||
"Pip installed " .. mod,
|
||||
vim.log.levels.INFO,
|
||||
{ title = "Vern Python" }
|
||||
)
|
||||
vim.system({ "pip", "install", mod }, { text = true }, function(obj)
|
||||
vim.schedule(function()
|
||||
if obj.code ~= 0 then
|
||||
vim.notify(
|
||||
"Pip failed: " .. obj.stderr,
|
||||
vim.log.levels.WARN,
|
||||
{ title = "Vern Python" }
|
||||
)
|
||||
else
|
||||
vim.notify(
|
||||
"Pip installed " .. mod,
|
||||
vim.log.levels.INFO,
|
||||
{ title = "Vern Python" }
|
||||
)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
---@type VernLanguageConfig
|
||||
M.python = {
|
||||
root = "Python",
|
||||
dirs = {
|
||||
src = "src/{project_name}",
|
||||
root = "Python",
|
||||
dirs = {
|
||||
src = "src/{project_name}",
|
||||
},
|
||||
keybinds = {
|
||||
["<leader>pi"] = {
|
||||
user_command = "VernPythonPip",
|
||||
desc = "Install python packages for environment",
|
||||
action = M.pip_install,
|
||||
},
|
||||
keybinds = {
|
||||
["<leader>pi"] = {
|
||||
user_command = "VernPythonPip",
|
||||
desc = "Install python packages for environment",
|
||||
action = M.pip_install,
|
||||
},
|
||||
},
|
||||
templates = {
|
||||
project = {
|
||||
primary = {
|
||||
path = "{dirs.src}",
|
||||
name = "main.py",
|
||||
kind = "main",
|
||||
kind_path = "vern-nvim.templates.python",
|
||||
},
|
||||
manifest = {
|
||||
path = ".",
|
||||
name = "pyproject.toml",
|
||||
kind = "pyproject",
|
||||
kind_path = "vern-nvim.templates.python",
|
||||
},
|
||||
pkg_init = {
|
||||
path = "{dirs.src}",
|
||||
name = "__init__.py",
|
||||
kind = "__init__",
|
||||
kind_path = "vern-nvim.templates.python",
|
||||
},
|
||||
},
|
||||
templates = {
|
||||
project = {
|
||||
primary = {
|
||||
path = "{dirs.src}",
|
||||
name = "main.py",
|
||||
kind = "main",
|
||||
kind_path = "vern-nvim.templates.python",
|
||||
},
|
||||
manifest = {
|
||||
path = ".",
|
||||
name = "pyproject.toml",
|
||||
kind = "pyproject",
|
||||
kind_path = "vern-nvim.templates.python",
|
||||
},
|
||||
pkg_init = {
|
||||
path = "{dirs.src}",
|
||||
name = "__init__.py",
|
||||
kind = "__init__",
|
||||
kind_path = "vern-nvim.templates.python",
|
||||
},
|
||||
},
|
||||
file = {
|
||||
source = {
|
||||
path = "{dirs.src}",
|
||||
name = "{file_name}.py",
|
||||
kind = "module",
|
||||
kind_path = "vern-nvim.templates.python",
|
||||
},
|
||||
},
|
||||
extras = nil,
|
||||
file = {
|
||||
source = {
|
||||
path = "{dirs.src}",
|
||||
name = "{file_name}.py",
|
||||
kind = "module",
|
||||
kind_path = "vern-nvim.templates.python",
|
||||
},
|
||||
},
|
||||
extras = nil,
|
||||
},
|
||||
}
|
||||
return M
|
||||
@@ -1,5 +1,5 @@
|
||||
---@module "vern-nvim.core.fs"
|
||||
local fs = require("vern-nvim.fs")
|
||||
local fs = require("vern-nvim.core.fs")
|
||||
|
||||
---@module "vern-nvim.core.terminal"
|
||||
local term = require("vern-nvim.core.terminal")
|
||||
@@ -9,17 +9,19 @@ local M = {}
|
||||
M.attach = nil
|
||||
|
||||
M.create_project = function(root)
|
||||
local obj = vim.system({
|
||||
"cargo",
|
||||
"init",
|
||||
vim.fn.expand(root),
|
||||
"--name",
|
||||
vim.fs.basename(root),
|
||||
}):wait()
|
||||
local obj = vim
|
||||
.system({
|
||||
"cargo",
|
||||
"init",
|
||||
vim.fn.expand(root),
|
||||
"--name",
|
||||
vim.fs.basename(root),
|
||||
})
|
||||
:wait()
|
||||
|
||||
if obj.code ~= 0 then
|
||||
vim.notify("Cargo init failed:" .. obj.stderr, vim.log.levels.ERROR)
|
||||
end
|
||||
if obj.code ~= 0 then
|
||||
vim.notify("Cargo init failed:" .. obj.stderr, vim.log.levels.ERROR)
|
||||
end
|
||||
end
|
||||
|
||||
---@type VernCreateFile
|
||||
@@ -27,33 +29,33 @@ M.create_file = nil
|
||||
|
||||
---@param opts VernRustConfig Takes a table for the runtime
|
||||
M.run = function(opts)
|
||||
opts = opts or {}
|
||||
term.open(
|
||||
{ "cd " .. fs.root() .. " && cargo run" },
|
||||
opts.terminal or {},
|
||||
false
|
||||
)
|
||||
opts = opts or {}
|
||||
term.open(
|
||||
{ "cd " .. fs.root() .. " && cargo run" },
|
||||
opts.terminal or {},
|
||||
false
|
||||
)
|
||||
end
|
||||
|
||||
---@type VernLanguageConfig
|
||||
M.rust = {
|
||||
root = "Rust",
|
||||
dirs = nil,
|
||||
keybinds = nil,
|
||||
templates = {
|
||||
project = {
|
||||
primary = { path = "src", name = "main.rs" },
|
||||
},
|
||||
file = {
|
||||
source = {
|
||||
path = "src",
|
||||
name = "{file_name}.rs",
|
||||
kind = "source",
|
||||
kind_path = "vern-nvim.templates.rust",
|
||||
},
|
||||
},
|
||||
extras = nil,
|
||||
root = "Rust",
|
||||
dirs = nil,
|
||||
keybinds = nil,
|
||||
templates = {
|
||||
project = {
|
||||
primary = { path = "src", name = "main.rs" },
|
||||
},
|
||||
file = {
|
||||
source = {
|
||||
path = "src",
|
||||
name = "{file_name}.rs",
|
||||
kind = "source",
|
||||
kind_path = "vern-nvim.templates.rust",
|
||||
},
|
||||
},
|
||||
extras = nil,
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
||||
@@ -0,0 +1,59 @@
|
||||
---@module "vern-nvim.core.fs"
|
||||
local fs = require("vern-nvim.core.fs")
|
||||
|
||||
---@module "vern-nvim.core.terminal"
|
||||
local term = require("vern-nvim.core.terminal")
|
||||
|
||||
---@module "vern-nvim.providers.web"
|
||||
local providers = require("vern-nvim.providers.web")
|
||||
local M = {}
|
||||
|
||||
M.attach = nil
|
||||
|
||||
M.create_project = function(opts, continue)
|
||||
opts = opts or {}
|
||||
local provider = vim.tbl_get(opts, "web", "providers")
|
||||
if vim.trim(provider) == "bun" then
|
||||
local items = { "Vanilla", "Tailwind", "Shadcn" }
|
||||
vim.ui.select(items, {
|
||||
prompt = "Select scaffold from Bun:",
|
||||
format_item = function(item) return item end,
|
||||
}, function(choice, _)
|
||||
if choice then return continue(choice) end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
---@type VernCreateFile
|
||||
M.create_file = nil
|
||||
|
||||
---@param opts VernWebConfig Takes a table for the runtime
|
||||
M.run = function(opts)
|
||||
opts = opts or {}
|
||||
|
||||
-- term.open({
|
||||
-- "lua " .. vim.fs.joinpath(fs.root(), "lua", fs.name(), "/init.lua"),
|
||||
-- }, opts.terminal or {}, false)
|
||||
end
|
||||
|
||||
---@type VernLanguageConfig
|
||||
M.web = {
|
||||
root = "Web",
|
||||
dirs = nil,
|
||||
providers = "bun", --- "bun"|"deno"|"vanilla"
|
||||
keybinds = nil,
|
||||
templates = {
|
||||
project = nil,
|
||||
file = {
|
||||
source = {
|
||||
path = "{dirs.src}",
|
||||
name = "{file_name}.lua",
|
||||
kind = "source",
|
||||
kind_path = "vern-nvim.templates.lua",
|
||||
},
|
||||
},
|
||||
extras = nil,
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
||||
@@ -0,0 +1,10 @@
|
||||
--- Providers for bun
|
||||
---
|
||||
|
||||
--[[ React
|
||||
|
||||
--react
|
||||
--react=tailwind
|
||||
--react=shadcn
|
||||
|
||||
--]]
|
||||
Whitespace-only changes.
@@ -1,115 +1,115 @@
|
||||
return {
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: MAIN (Entrypoint)
|
||||
File: main.c
|
||||
Target: src/main.c
|
||||
--[[ =====================================================================
|
||||
template: main (entrypoint)
|
||||
file: main.c
|
||||
target: src/main.c
|
||||
===================================================================== --]]
|
||||
main = vim.trim([=[
|
||||
main = vim.trim([=[
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
char* str = "Hello World";
|
||||
char* str = "hello world";
|
||||
printf("%s\n", str);
|
||||
return 0;
|
||||
}
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: CLANG-FORMAT (Code formatter)
|
||||
File: .clang-format
|
||||
Target: .clang-format
|
||||
--[[ =====================================================================
|
||||
template: clang-format (code formatter)
|
||||
file: .clang-format
|
||||
target: .clang-format
|
||||
===================================================================== --]]
|
||||
format = vim.trim([=[
|
||||
format = vim.trim([=[
|
||||
---
|
||||
BasedOnStyle: Google
|
||||
Standard: Latest
|
||||
UseTab: Always
|
||||
TabWidth: 8
|
||||
IndentWidth: 8
|
||||
BreakBeforeBraces: Allman
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
SeparateDefinitionBlocks: Always
|
||||
Cpp11BracedListStyle: false
|
||||
BreakAfterReturnType: TopLevel
|
||||
ReflowComments: Always
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
IndentAccessModifiers: false # Indent access specifiers by one level
|
||||
AccessModifierOffset: -4 # Optional: adjust offset relative to the class indentation level
|
||||
IndentGotoLabels: InnerIndent
|
||||
DerivePointerAlignment: false
|
||||
PointerAlignment: Left
|
||||
IndentPPDirectives: AfterHash
|
||||
SortIncludes: CaseSensitive
|
||||
IncludeBlocks: Preserve
|
||||
basedonstyle: google
|
||||
standard: latest
|
||||
usetab: always
|
||||
tabwidth: 8
|
||||
indentwidth: 8
|
||||
breakbeforebraces: allman
|
||||
spacebeforecpp11bracedlist: true
|
||||
separatedefinitionblocks: always
|
||||
cpp11bracedliststyle: false
|
||||
breakafterreturntype: toplevel
|
||||
reflowcomments: always
|
||||
allowshortfunctionsonasingleline: all
|
||||
allowshortifstatementsonasingleline: allifsandelse
|
||||
allowshortloopsonasingleline: true
|
||||
indentaccessmodifiers: false # indent access specifiers by one level
|
||||
accessmodifieroffset: -4 # optional: adjust offset relative to the class indentation level
|
||||
indentgotolabels: innerindent
|
||||
derivepointeralignment: false
|
||||
pointeralignment: left
|
||||
indentppdirectives: afterhash
|
||||
sortincludes: casesensitive
|
||||
includeblocks: preserve
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: CMAKELISTS (Spec / Build Manifest)
|
||||
File: CMakeLists.txt
|
||||
Target: CMakeLists.txt
|
||||
--[[ =====================================================================
|
||||
template: cmakelists (spec / build manifest)
|
||||
file: cmakelists.txt
|
||||
target: cmakelists.txt
|
||||
===================================================================== --]]
|
||||
CmakeLists = vim.trim([=[
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(__PROJECT_NAME__ LANGUAGES C)
|
||||
set(CMAKE_C_STANDARD 23)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
cmakelists = vim.trim([=[
|
||||
cmake_minimum_required(version 3.16)
|
||||
project(__project_name__ languages c)
|
||||
set(cmake_c_standard 23)
|
||||
set(cmake_c_standard_required on)
|
||||
set(cmake_export_compile_commands on)
|
||||
|
||||
set(LIB_SOURCES
|
||||
# Add your other types here as you implement them:
|
||||
set(lib_sources
|
||||
# add your other types here as you implement them:
|
||||
# src/example1.c
|
||||
# src/example2.c
|
||||
)
|
||||
|
||||
if(LIB_SOURCES)
|
||||
add_library(__PROJECT_NAME__ STATIC ${LIB_SOURCES})
|
||||
target_include_directories(__PROJECT_NAME__
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
if(lib_sources)
|
||||
add_library(__project_name__ static ${lib_sources})
|
||||
target_include_directories(__project_name__
|
||||
public
|
||||
${cmake_current_source_dir}/include
|
||||
)
|
||||
endif()
|
||||
|
||||
add_executable(__PROJECT_NAME___bin src/main.c)
|
||||
set_target_properties(__PROJECT_NAME___bin PROPERTIES OUTPUT_NAME "__PROJECT_NAME__")
|
||||
add_executable(__project_name___bin src/main.c)
|
||||
set_target_properties(__project_name___bin properties output_name "__project_name__")
|
||||
|
||||
if(TARGET __PROJECT_NAME__)
|
||||
target_link_libraries(__PROJECT_NAME___bin PRIVATE __PROJECT_NAME__)
|
||||
if(target __project_name__)
|
||||
target_link_libraries(__project_name___bin private __project_name__)
|
||||
endif()
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: HEADER (Standalone File)
|
||||
File: {name}.h
|
||||
Target: include/{project_name}/{name}.h
|
||||
--[[ =====================================================================
|
||||
template: header (standalone file)
|
||||
file: {name}.h
|
||||
target: include/{project_name}/{name}.h
|
||||
===================================================================== --]]
|
||||
header = vim.trim([=[
|
||||
#ifndef __FILE_NAME___H
|
||||
#define __FILE_NAME___H
|
||||
header = vim.trim([=[
|
||||
#ifndef __file_name___h
|
||||
#define __file_name___h
|
||||
|
||||
// Code
|
||||
// code
|
||||
|
||||
#endif /* __FILE_NAME___H */
|
||||
#endif /* __file_name___h */
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: SOURCE (Standalone File)
|
||||
File: {name}.c
|
||||
Target: src/{name}.c
|
||||
--[[ =====================================================================
|
||||
template: source (standalone file)
|
||||
file: {name}.c
|
||||
target: src/{name}.c
|
||||
===================================================================== --]]
|
||||
source = vim.trim([=[
|
||||
source = vim.trim([=[
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: CLANG_TIDY (LINTER)
|
||||
File: .clang-tidy
|
||||
Target: .clang-tidy
|
||||
--[[ =====================================================================
|
||||
template: clang_tidy (linter)
|
||||
file: .clang-tidy
|
||||
target: .clang-tidy
|
||||
===================================================================== --]]
|
||||
linter = vim.trim([=[
|
||||
Checks: >
|
||||
linter = vim.trim([=[
|
||||
checks: >
|
||||
-*,
|
||||
clang-analyzer-*,
|
||||
bugprone-*,
|
||||
@@ -126,12 +126,12 @@ Checks: >
|
||||
|
||||
-bugprone-narrowing-conversions,
|
||||
-readability-identifier-length
|
||||
CheckOptions:
|
||||
readability-identifier-naming.VariableCase: lower_case
|
||||
readability-identifier-naming.FunctionCase: lower_case
|
||||
readability-identifier-naming.StructCase: lower_case
|
||||
readability-identifier-naming.EnumCase: CamelCase
|
||||
readability-identifier-naming.EnumConstantCase: UPPER_CASE
|
||||
readability-identifier-naming.MacroDefinitionCase: UPPER_CASE
|
||||
checkoptions:
|
||||
readability-identifier-naming.variablecase: lower_case
|
||||
readability-identifier-naming.functioncase: lower_case
|
||||
readability-identifier-naming.structcase: lower_case
|
||||
readability-identifier-naming.enumcase: camelcase
|
||||
readability-identifier-naming.enumconstantcase: upper_case
|
||||
readability-identifier-naming.macrodefinitioncase: upper_case
|
||||
]=]) .. "\n",
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
return {
|
||||
--[[ =====================================================================
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: MAIN (Entrypoint)
|
||||
File: main.cpp
|
||||
Target: src/main.cpp
|
||||
===================================================================== --]]
|
||||
main = vim.trim([=[
|
||||
main = vim.trim([=[
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
@@ -16,12 +16,12 @@ main()
|
||||
}
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: CLANG-FORMAT (Code formatter)
|
||||
File: .clang-format
|
||||
Target: .clang-format
|
||||
===================================================================== --]]
|
||||
format = vim.trim([=[
|
||||
format = vim.trim([=[
|
||||
---
|
||||
BasedOnStyle: Google
|
||||
Standard: Latest
|
||||
@@ -47,12 +47,12 @@ SortIncludes: CaseSensitive
|
||||
IncludeBlocks: Preserve
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: CMAKELISTS (Spec / Build Manifest)
|
||||
File: CMakeLists.txt
|
||||
Target: CMakeLists.txt
|
||||
===================================================================== --]]
|
||||
CmakeLists = vim.trim([=[
|
||||
CmakeLists = vim.trim([=[
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(__PROJECT_NAME__ LANGUAGES CXX)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
@@ -81,12 +81,12 @@ if(TARGET __PROJECT_NAME__)
|
||||
endif()
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: HEADER (Standalone File)
|
||||
File: {name}.hpp
|
||||
Target: include/{project_name}/{name}.hpp
|
||||
===================================================================== --]]
|
||||
header = vim.trim([=[
|
||||
header = vim.trim([=[
|
||||
#ifndef __FILE_NAME___HPP
|
||||
#define __FILE_NAME___HPP
|
||||
|
||||
@@ -95,20 +95,20 @@ endif()
|
||||
#endif /* __FILE_NAME___HPP */
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: SOURCE (Standalone File)
|
||||
File: {name}.cpp
|
||||
Target: src/{name}.cpp
|
||||
===================================================================== --]]
|
||||
source = vim.trim([=[
|
||||
source = vim.trim([=[
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: CLANG_TIDY (LINTER)
|
||||
File: .clang-tidy
|
||||
Target: .clang-tidy
|
||||
===================================================================== --]]
|
||||
linter = vim.trim([=[
|
||||
linter = vim.trim([=[
|
||||
Checks: >
|
||||
-*,
|
||||
clang-analyzer-*,
|
||||
|
||||
@@ -2,7 +2,7 @@ local M = {}
|
||||
|
||||
---@param lang string
|
||||
M.template = function(lang)
|
||||
local base = [=[
|
||||
local base = [=[
|
||||
.DS_Store
|
||||
|
||||
.vscode/
|
||||
@@ -12,8 +12,8 @@ M.template = function(lang)
|
||||
.env.*
|
||||
|
||||
]=]
|
||||
local lang_block = {
|
||||
python = vim.trim([=[
|
||||
local lang_block = {
|
||||
python = vim.trim([=[
|
||||
__pycache__/
|
||||
build/
|
||||
dist/
|
||||
@@ -23,26 +23,26 @@ venv/
|
||||
.pytest_cache/
|
||||
]=]),
|
||||
|
||||
c = vim.trim([=[
|
||||
c = vim.trim([=[
|
||||
build/
|
||||
.cache/
|
||||
]=]),
|
||||
|
||||
cpp = vim.trim([=[
|
||||
cpp = vim.trim([=[
|
||||
build/
|
||||
.cache/
|
||||
]=]),
|
||||
|
||||
lua = vim.trim([=[
|
||||
lua = vim.trim([=[
|
||||
luac.out
|
||||
]=]),
|
||||
|
||||
java = vim.trim([=[
|
||||
java = vim.trim([=[
|
||||
bin/
|
||||
*.class
|
||||
*.jar
|
||||
]=]),
|
||||
rust = vim.trim([=[
|
||||
rust = vim.trim([=[
|
||||
debug
|
||||
target
|
||||
**/*.rs.bk
|
||||
@@ -51,10 +51,10 @@ target
|
||||
rustc-ice-*.txt
|
||||
#.idea/
|
||||
]=]),
|
||||
}
|
||||
}
|
||||
|
||||
local extra = (lang and lang_block[lang]) or ""
|
||||
return base .. extra
|
||||
local extra = (lang and lang_block[lang]) or ""
|
||||
return base .. extra
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -0,0 +1,25 @@
|
||||
return {
|
||||
--[[ =====================================================================
|
||||
template: main (entrypoint)
|
||||
file: main.go
|
||||
target: main.go
|
||||
===================================================================== --]]
|
||||
main = vim.trim([=[
|
||||
package main
|
||||
|
||||
import ("fmt")
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hello World")
|
||||
}
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
template: source (standalone file)
|
||||
file: {name}.go
|
||||
target: {name}.go
|
||||
===================================================================== --]]
|
||||
--- Add boilder plate
|
||||
source = vim.trim([=[
|
||||
]=]) .. "\n",
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
return {
|
||||
--[[ =====================================================================
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: MAIN (Entrypoint)
|
||||
File: Main.java
|
||||
Target: src/com/company/app/Main.java
|
||||
===================================================================== --]]
|
||||
main = vim.trim([=[
|
||||
main = vim.trim([=[
|
||||
package com.__COMPANY_NAME__.__PROJECT_NAME__;
|
||||
|
||||
public class Main {
|
||||
@@ -15,12 +15,12 @@ public class Main {
|
||||
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: CLANG-FORMAT (Code formatter)
|
||||
File: .clang-format
|
||||
Target: .clang-format
|
||||
===================================================================== --]]
|
||||
format = vim.trim([=[
|
||||
format = vim.trim([=[
|
||||
---
|
||||
Language: Java
|
||||
BasedOnStyle: Google
|
||||
@@ -39,12 +39,12 @@ SortIncludes: CaseSensitive
|
||||
IncludeBlocks: Preserve
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: SOURCE (Standalone File)
|
||||
File: {name}.java
|
||||
Target: src/com/company/app/{name}.java
|
||||
===================================================================== --]]
|
||||
source = vim.trim([=[
|
||||
source = vim.trim([=[
|
||||
package com.__COMPANY_NAME__.__PROJECT_NAME__;
|
||||
|
||||
public class __FILE_NAME__ {
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
return {
|
||||
--[[ =====================================================================
|
||||
template: main (entrypoint)
|
||||
file: init.lua
|
||||
target: lua/init.lua
|
||||
===================================================================== --]]
|
||||
main = vim.trim([=[
|
||||
local M = {}
|
||||
|
||||
---@param opts? table
|
||||
function M.setup(opts)
|
||||
M.opts = opts or {}
|
||||
end
|
||||
|
||||
return M
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
template: stylua (code formatter)
|
||||
file: stylua.toml
|
||||
target: stylua.toml
|
||||
===================================================================== --]]
|
||||
format = vim.trim([=[
|
||||
# stylua.toml
|
||||
|
||||
# How many characters per line before wrapping
|
||||
column_width = 80
|
||||
|
||||
# Indentation style: "Tabs" or "Spaces"
|
||||
line_endings = "Unix"
|
||||
indent_type = "Spaces"
|
||||
indent_width = 4
|
||||
|
||||
# Quote styling: "AutoPreferDouble", "AutoPreferSingle", "ForceDouble", "ForceSingle"
|
||||
quote_style = "AutoPreferDouble"
|
||||
|
||||
# Call parentheses: "Always", "NoSingleString", "None", "Input"
|
||||
# "None" removes parens when a single string/table literal is passed: fn "arg" / fn { ... }
|
||||
# "Always" keeps them strictly standard: fn("arg") / fn({ ... })
|
||||
call_parentheses = "Always"
|
||||
|
||||
# Sorting and formatting behavior
|
||||
# collapse_simple_statement = "Never"
|
||||
collapse_simple_statement = "Always"
|
||||
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
template: source (standalone file)
|
||||
file: {name}.lua
|
||||
target: lua/{name}.lua
|
||||
===================================================================== --]]
|
||||
source = vim.trim([=[
|
||||
local M = {}
|
||||
|
||||
return M
|
||||
]=]) .. "\n",
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
return {
|
||||
--[[ =====================================================================
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: MAIN (Entrypoint)
|
||||
File: main.py
|
||||
Target: src/{project_name}/main.py
|
||||
===================================================================== --]]
|
||||
main = vim.trim([=[
|
||||
main = vim.trim([=[
|
||||
def main() -> None:
|
||||
print("Hello from __PROJECT_NAME__!")
|
||||
|
||||
@@ -13,23 +13,23 @@ if __name__ == "__main__":
|
||||
main()
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: INIT (Package Anchor)
|
||||
File: __init__.py
|
||||
Target: src/{project_name}/__init__.py
|
||||
===================================================================== --]]
|
||||
__init__ = vim.trim([=[
|
||||
__init__ = vim.trim([=[
|
||||
# __PROJECT_NAME__ init
|
||||
|
||||
__all__: list[str] = []
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: PYPROJECT (Spec / Build Manifest)
|
||||
File: pyproject.toml
|
||||
Target: pyproject.toml
|
||||
===================================================================== --]]
|
||||
pyproject = vim.trim([=[
|
||||
pyproject = vim.trim([=[
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
@@ -46,12 +46,12 @@ dependencies = []
|
||||
__PROJECT_NAME__ = "__PROJECT_NAME__.main:main"
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: MODULE (Standalone File)
|
||||
File: {name}.py
|
||||
Target: src/{project_name}/{name}.py
|
||||
===================================================================== --]]
|
||||
module = vim.trim([=[
|
||||
module = vim.trim([=[
|
||||
"""
|
||||
Module: __FILE_NAME__
|
||||
"""
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
return {
|
||||
--[[ =====================================================================
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: SOURCE (Standalone File)
|
||||
File: {name}.rs
|
||||
Target: src/{name}.rs
|
||||
===================================================================== --]]
|
||||
source = vim.trim([=[
|
||||
source = vim.trim([=[
|
||||
]=]) .. "\n",
|
||||
}
|
||||
+12
-5
@@ -2,13 +2,17 @@
|
||||
---@alias SplitDirection "vertical" | "horizontal"
|
||||
---@alias SplitAnchorType "right" | "bottom"
|
||||
|
||||
---@class VernCreateFile
|
||||
---@field func? fun(opts: any, continue: fun(mod: VernFileLayout|nil)): any?
|
||||
---@alias VernCreateFile fun(opts: any, continue: fun(mod: VernFileLayout|nil))
|
||||
|
||||
---@class VernUserConfig
|
||||
---@field workspace_root? string
|
||||
---@field keybinds? table<string, VernKeybindItem>
|
||||
---@field terminal? VernTerminalConfig | table
|
||||
|
||||
---@class VernKeybindItem
|
||||
---@field user_command string
|
||||
---@field desc string
|
||||
---@field action function
|
||||
---@field action fun(opts: VernCoreConfig)
|
||||
|
||||
---@class VernFloatWindowConfig
|
||||
---@field padding { left: integer, right: integer, top: integer, bottom: integer }
|
||||
@@ -46,7 +50,7 @@
|
||||
---@field kind_path? string
|
||||
|
||||
---@class VernExtrasLayout : VernFileLayout
|
||||
---@field enabled boolean
|
||||
---@field enabled? boolean
|
||||
|
||||
---@class VernLanguageTemplates
|
||||
---@field project table<string, VernFileLayout>|nil
|
||||
@@ -70,9 +74,12 @@
|
||||
|
||||
---@class VernLuaConfig : VernCoreConfig
|
||||
---@field lua? VernLanguageConfig
|
||||
---
|
||||
|
||||
---@class VernJavaConfig : VernCoreConfig
|
||||
---@field java? VernLanguageConfig
|
||||
|
||||
---@class VernRustConfig : VernCoreConfig
|
||||
---@field rust? VernLanguageConfig
|
||||
|
||||
---@class VernWebConfig : VernCoreConfig
|
||||
---@field web? VernLanguageConfig
|
||||
+1
-1
@@ -6,7 +6,7 @@ column_width = 80
|
||||
# Indentation style: "Tabs" or "Spaces"
|
||||
line_endings = "Unix"
|
||||
indent_type = "Spaces"
|
||||
indent_width = 4
|
||||
indent_width = 2
|
||||
|
||||
# Quote styling: "AutoPreferDouble", "AutoPreferSingle", "ForceDouble", "ForceSingle"
|
||||
quote_style = "AutoPreferDouble"
|
||||
|
||||
Reference in new issue
Block a user