chore(actions.create_project): now has a list over manually typing for
easier creation
This commit is contained in:
1 parent
adbd2bc0e9
commit
1c13c8cbe2
21 files changed
+409
-187
No files matched your search
@@ -6,24 +6,44 @@ 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",
|
||||
})
|
||||
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 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
|
||||
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
|
||||
@@ -40,8 +60,6 @@ M.create_project = function(opts)
|
||||
}
|
||||
|
||||
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
|
||||
@@ -52,56 +70,52 @@ M.create_project = function(opts)
|
||||
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
|
||||
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)
|
||||
bin = vim.fs.joinpath(
|
||||
root,
|
||||
fs.fmt_path(
|
||||
vim.fs.joinpath(tbl.path, tbl.name),
|
||||
args[ft].dirs,
|
||||
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
|
||||
|
||||
write(project)
|
||||
write(tpl.extras)
|
||||
|
||||
if type(langs.create_project) == "function" then
|
||||
langs.create_project(root)
|
||||
end
|
||||
@@ -131,7 +145,7 @@ M.create_project = function(opts)
|
||||
)
|
||||
end)
|
||||
end
|
||||
)
|
||||
end)
|
||||
end
|
||||
|
||||
M.create_file = function(opts)
|
||||
@@ -139,19 +153,14 @@ M.create_file = function(opts)
|
||||
local filetype = vim.bo.filetype
|
||||
|
||||
local ft_ok, config = pcall(require, "vern-nvim.langs." .. filetype)
|
||||
---@type VernCreateFile
|
||||
if
|
||||
not filetype
|
||||
or filetype == ""
|
||||
or not ft_ok
|
||||
or type(config) ~= "table"
|
||||
then
|
||||
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
|
||||
local cf = args.create_file
|
||||
local function function_write(mod, fname)
|
||||
local raw_path = vim.fs.joinpath(mod.path, mod.name)
|
||||
@@ -160,13 +169,9 @@ M.create_file = function(opts)
|
||||
company_name = args.env.author,
|
||||
file_name = fname,
|
||||
}
|
||||
local path =
|
||||
fs.fmt_path(raw_path, args[filetype].dirs or {}, context)
|
||||
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)
|
||||
)
|
||||
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!",
|
||||
|
||||
@@ -10,24 +10,17 @@ 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_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
|
||||
)
|
||||
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
|
||||
)
|
||||
vim.schedule(function() term.open({ run_cmd }, opts.terminal, false) end)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -29,7 +29,7 @@ function M.write(path, content)
|
||||
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
|
||||
|
||||
@@ -12,13 +12,9 @@ local registers = {
|
||||
---@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
|
||||
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
|
||||
if not ok or type(mod) ~= "table" or not mod[kind] then return "" end
|
||||
|
||||
local template = mod[kind] or ""
|
||||
context = context or {}
|
||||
@@ -26,9 +22,7 @@ function M.fetch(kind_path, kind, context)
|
||||
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
|
||||
if value then template = string.gsub(template, placeholder, value) end
|
||||
end
|
||||
end
|
||||
return template
|
||||
|
||||
+2
-12
@@ -6,11 +6,6 @@ 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
|
||||
@@ -51,16 +46,11 @@ function M.setup(user_opts)
|
||||
function() def.action(opts) end,
|
||||
{ nargs = "*", desc = def.desc }
|
||||
)
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
key,
|
||||
function() def.action(opts) end,
|
||||
{
|
||||
vim.keymap.set("n", key, function() def.action(opts) end, {
|
||||
buffer = args.buf,
|
||||
silent = true,
|
||||
desc = def.desc,
|
||||
}
|
||||
)
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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")
|
||||
@@ -36,7 +36,7 @@ end
|
||||
M.run = function(opts)
|
||||
opts = opts or {}
|
||||
|
||||
local build_dir = vim.fn.fnameescape((fs.root() or ".") .. "/build")
|
||||
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())
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ end
|
||||
M.run = function(opts)
|
||||
opts = opts or {}
|
||||
|
||||
local build_dir = vim.fn.fnameescape((fs.root() or ".") .. "/build")
|
||||
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())
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -18,7 +18,7 @@ M.run = function(opts)
|
||||
opts = opts or {}
|
||||
local root = fs.root()
|
||||
local context = {
|
||||
project_name = fs.name()(),
|
||||
project_name = fs.name(),
|
||||
company_name = opts.env.author,
|
||||
file_name = "",
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
@@ -34,7 +34,7 @@ M.lua = {
|
||||
primary = {
|
||||
path = "{dirs.src}",
|
||||
name = "init.lua",
|
||||
kind = "init",
|
||||
kind = "main",
|
||||
kind_path = "vern-nvim.templates.lua",
|
||||
},
|
||||
style = {
|
||||
|
||||
@@ -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")
|
||||
@@ -39,16 +39,15 @@ 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 root = fs.root()
|
||||
local context = {
|
||||
project_name = fs.name(),
|
||||
company_name = opts.env.author,
|
||||
file_name = "",
|
||||
}
|
||||
local bin = opts.python.templates.project.primary
|
||||
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)
|
||||
|
||||
|
||||
@@ -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,13 +9,15 @@ local M = {}
|
||||
M.attach = nil
|
||||
|
||||
M.create_project = function(root)
|
||||
local obj = vim.system({
|
||||
local obj = vim
|
||||
.system({
|
||||
"cargo",
|
||||
"init",
|
||||
vim.fn.expand(root),
|
||||
"--name",
|
||||
vim.fs.basename(root),
|
||||
}):wait()
|
||||
})
|
||||
:wait()
|
||||
|
||||
if obj.code ~= 0 then
|
||||
vim.notify("Cargo init failed:" .. obj.stderr, vim.log.levels.ERROR)
|
||||
|
||||
@@ -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,8 +1,8 @@
|
||||
return {
|
||||
--[[ =====================================================================
|
||||
TEMPLATE: MAIN (Entrypoint)
|
||||
File: main.c
|
||||
Target: src/main.c
|
||||
template: main (entrypoint)
|
||||
file: main.c
|
||||
target: src/main.c
|
||||
===================================================================== --]]
|
||||
main = vim.trim([=[
|
||||
#include <stdio.h>
|
||||
@@ -10,106 +10,106 @@ return {
|
||||
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([=[
|
||||
---
|
||||
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
|
||||
#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([=[
|
||||
]=]) .. "\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: >
|
||||
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",
|
||||
}
|
||||
@@ -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",
|
||||
}
|
||||
@@ -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",
|
||||
}
|
||||
+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