RENAME: Changed vern.nvim to vern-nvim and moved vern to vern-nvim
This commit is contained in:
@@ -22,7 +22,7 @@ NOTE: The plugin may not work well with lazy or any other package manager other
|
|||||||
* Integrated terminal for flexible command execution
|
* Integrated terminal for flexible command execution
|
||||||
* Minimal configuration with extensibility in mind
|
* Minimal configuration with extensibility in mind
|
||||||
|
|
||||||
> 📚 [View the full documentation](https://git.moomancer.xyz/DarthMooMancer/vern.nvim/wiki/Home$0) for setup, configuration, and usage details.
|
> 📚 [View the full documentation](https://git.moomancer.xyz/DarthMooMancer/vern-nvim.nvim/wiki/Home$0) for setup, configuration, and usage details.
|
||||||
|
|
||||||
## Supported Languages
|
## Supported Languages
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local utils = require("vern.utils")
|
local utils = require("vern-nvim.utils")
|
||||||
local templates = require("vern.templates")
|
local templates = require("vern-nvim.templates")
|
||||||
local action_utils = require("vern.actions.utils")
|
local action_utils = require("vern-nvim.actions.utils")
|
||||||
|
|
||||||
local join = vim.fs.joinpath
|
local join = vim.fs.joinpath
|
||||||
|
|
||||||
@@ -14,14 +14,14 @@ function M.create_project(opts)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local configs = require("vern.configs.c")
|
local configs = require("vern-nvim.configs.c")
|
||||||
|
|
||||||
---@type VernCConfig
|
---@type VernCConfig
|
||||||
local cfg = vim.tbl_deep_extend("force", {}, configs, configs, opts or {})
|
local cfg = vim.tbl_deep_extend("force", {}, configs, configs, opts or {})
|
||||||
local root = join(vim.fn.expand(cfg.workspace_root), cfg.c.root, pname)
|
local root = join(vim.fn.expand(cfg.workspace_root), cfg.c.root, pname)
|
||||||
local bin = action_utils.create(cfg.c, pname, root)
|
local bin = action_utils.create(cfg.c, pname, root)
|
||||||
|
|
||||||
local build_cmd = "cd " .. root .. " && cmake -S . -B build"
|
local build_cmd = "cd " .. root .. " && cmake -S . -B build && cmake --build build"
|
||||||
local _ = vim.system({ "sh", "-c", build_cmd }):wait()
|
local _ = vim.system({ "sh", "-c", build_cmd }):wait()
|
||||||
|
|
||||||
utils.init_git(root, "c")
|
utils.init_git(root, "c")
|
||||||
@@ -36,7 +36,7 @@ function M.create_file(opts)
|
|||||||
if not ft or ft == "" then
|
if not ft or ft == "" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local configs = require("vern.configs.c")
|
local configs = require("vern-nvim.configs.c")
|
||||||
---@type VernCConfig
|
---@type VernCConfig
|
||||||
local cfg = vim.tbl_deep_extend("force", {}, configs, opts or {})
|
local cfg = vim.tbl_deep_extend("force", {}, configs, opts or {})
|
||||||
vim.ui.input({ prompt = "Enter file name: " }, function(fname)
|
vim.ui.input({ prompt = "Enter file name: " }, function(fname)
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local utils = require("vern.utils")
|
local utils = require("vern-nvim.utils")
|
||||||
local templates = require("vern.templates")
|
local templates = require("vern-nvim.templates")
|
||||||
local action_utils = require("vern.actions.utils")
|
local action_utils = require("vern-nvim.actions.utils")
|
||||||
|
|
||||||
local join = vim.fs.joinpath
|
local join = vim.fs.joinpath
|
||||||
|
|
||||||
@@ -14,14 +14,14 @@ function M.create_project(opts)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local configs = require("vern.configs.cpp")
|
local configs = require("vern-nvim.configs.cpp")
|
||||||
|
|
||||||
---@type VernCPPConfig
|
---@type VernCPPConfig
|
||||||
local cfg = vim.tbl_deep_extend("force", {}, configs, configs, opts or {})
|
local cfg = vim.tbl_deep_extend("force", {}, configs, configs, opts or {})
|
||||||
local root = join(vim.fn.expand(cfg.workspace_root), cfg.cpp.root, pname)
|
local root = join(vim.fn.expand(cfg.workspace_root), cfg.cpp.root, pname)
|
||||||
local bin = action_utils.create(cfg.cpp, pname, root)
|
local bin = action_utils.create(cfg.cpp, pname, root)
|
||||||
|
|
||||||
local build_cmd = "cd " .. root .. " && cmake -S . -B build"
|
local build_cmd = "cd " .. root .. " && cmake -S . -B build && cmake --build build"
|
||||||
local _ = vim.system({ "sh", "-c", build_cmd }):wait()
|
local _ = vim.system({ "sh", "-c", build_cmd }):wait()
|
||||||
|
|
||||||
utils.init_git(root, "cpp")
|
utils.init_git(root, "cpp")
|
||||||
@@ -37,7 +37,7 @@ function M.create_file(opts)
|
|||||||
if not ft or ft == "" then
|
if not ft or ft == "" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local configs = require("vern.configs.cpp")
|
local configs = require("vern-nvim.configs.cpp")
|
||||||
---@type VernCPPConfig
|
---@type VernCPPConfig
|
||||||
local cfg = vim.tbl_deep_extend("force", {}, configs, opts or {})
|
local cfg = vim.tbl_deep_extend("force", {}, configs, opts or {})
|
||||||
vim.ui.input({ prompt = "Enter file name: " }, function(fname)
|
vim.ui.input({ prompt = "Enter file name: " }, function(fname)
|
||||||
@@ -9,8 +9,8 @@ M.create_project = function(opts)
|
|||||||
if not ft or vim.trim(ft) == "" then
|
if not ft or vim.trim(ft) == "" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local ok, actions = pcall(require, "vern.actions." .. ft)
|
local ok, actions = pcall(require, "vern-nvim.actions." .. ft)
|
||||||
local configs = require("vern.configs." .. ft)
|
local configs = require("vern-nvim.configs." .. ft)
|
||||||
local args = vim.tbl_deep_extend("force", {}, configs, opts or {})
|
local args = vim.tbl_deep_extend("force", {}, configs, opts or {})
|
||||||
if ok and actions and type(actions.create_project) == "function" then
|
if ok and actions and type(actions.create_project) == "function" then
|
||||||
actions.create_project(args)
|
actions.create_project(args)
|
||||||
@@ -33,8 +33,8 @@ M.create_file = function(opts)
|
|||||||
if not ft or vim.trim(ft) == "" then
|
if not ft or vim.trim(ft) == "" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local ok, actions = pcall(require, "vern.actions." .. ft)
|
local ok, actions = pcall(require, "vern-nvim.actions." .. ft)
|
||||||
local configs = require("vern.configs." .. ft)
|
local configs = require("vern-nvim.configs." .. ft)
|
||||||
local args = vim.tbl_deep_extend("force", {}, configs, opts or {})
|
local args = vim.tbl_deep_extend("force", {}, configs, opts or {})
|
||||||
if ok and actions and type(actions.create_file) == "function" then
|
if ok and actions and type(actions.create_file) == "function" then
|
||||||
actions.create_file(args)
|
actions.create_file(args)
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
local utils = require("vern-nvim.utils")
|
||||||
|
local templates = require("vern-nvim.templates")
|
||||||
|
local action_utils = require("vern-nvim.actions.utils")
|
||||||
|
|
||||||
|
local join = vim.fs.joinpath
|
||||||
|
|
||||||
|
---@param opts VernLuaConfig
|
||||||
|
function M.create_project(opts)
|
||||||
|
vim.ui.input({ prompt = "Enter project name: " }, function(pname)
|
||||||
|
pname = pname and vim.trim(pname)
|
||||||
|
if not pname or pname == "" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local configs = require("vern-nvim.configs.lua")
|
||||||
|
|
||||||
|
---@type VernLuaConfig
|
||||||
|
local cfg = vim.tbl_deep_extend("force", {}, configs, configs, opts or {})
|
||||||
|
local root = join(vim.fn.expand(cfg.workspace_root), cfg.lua.root, pname)
|
||||||
|
local bin = action_utils.create(cfg.lua, pname, root)
|
||||||
|
|
||||||
|
utils.init_git(root, "lua")
|
||||||
|
|
||||||
|
vim.cmd.edit(vim.fn.fnameescape(bin))
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param opts VernLuaConfig
|
||||||
|
function M.create_file(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
vim.ui.input({ prompt = "Enter file name: " }, function(fname)
|
||||||
|
fname = fname and vim.trim(fname)
|
||||||
|
if not fname or fname == "" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local configs = require("vern-nvim.configs.lua")
|
||||||
|
---@type VernLuaConfig
|
||||||
|
local cfg = vim.tbl_deep_extend("force", {}, configs, opts or {})
|
||||||
|
local mod = cfg.lua.templates.file.source or {}
|
||||||
|
|
||||||
|
local raw_path = join(mod.path, mod.name)
|
||||||
|
local context = { project_name = utils.proj_name(), name = fname }
|
||||||
|
local path = utils.resolve_path(raw_path, cfg.lua.dirs or {}, context)
|
||||||
|
|
||||||
|
utils.dump(path, templates.fetch(mod.kind_path, mod.kind, fname))
|
||||||
|
vim.notify("File: " .. fname .. " has been created!")
|
||||||
|
vim.cmd.edit(vim.fn.expand(path))
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param opts VernCPPConfig Takes a table for the runtime
|
||||||
|
function M.run(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
local root = utils.proj_root() or "."
|
||||||
|
local pname = vim.fs.basename(root)
|
||||||
|
|
||||||
|
local full_path = join(root, pname, "lua", pname)
|
||||||
|
print(full_path .. "/init.lua")
|
||||||
|
|
||||||
|
utils.term({ "lua " .. full_path .. "/init.lua" }, opts.terminal or {}, false)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local utils = require("vern.utils")
|
local utils = require("vern-nvim.utils")
|
||||||
local templates = require("vern.templates")
|
local templates = require("vern-nvim.templates")
|
||||||
local action_utils = require("vern.actions.utils")
|
local action_utils = require("vern-nvim.actions.utils")
|
||||||
|
|
||||||
local join = vim.fs.joinpath
|
local join = vim.fs.joinpath
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ function M.create_project(opts)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local configs = require("vern.configs.python")
|
local configs = require("vern-nvim.configs.python")
|
||||||
|
|
||||||
---@type VernPythonConfig
|
---@type VernPythonConfig
|
||||||
local cfg = vim.tbl_deep_extend("force", {}, configs, opts or {})
|
local cfg = vim.tbl_deep_extend("force", {}, configs, opts or {})
|
||||||
@@ -39,10 +39,10 @@ function M.create_file(opts)
|
|||||||
if not fname or fname == "" then
|
if not fname or fname == "" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local configs = require("vern.configs.python")
|
local configs = require("vern-nvim.configs.python")
|
||||||
---@type VernPythonConfig
|
---@type VernPythonConfig
|
||||||
local cfg = vim.tbl_deep_extend("force", {}, configs, opts or {})
|
local cfg = vim.tbl_deep_extend("force", {}, configs, opts or {})
|
||||||
local mod = cfg.python.templates.file.mod or {}
|
local mod = cfg.python.templates.file.source or {}
|
||||||
|
|
||||||
local raw_path = join(mod.path, mod.name)
|
local raw_path = join(mod.path, mod.name)
|
||||||
local context = { project_name = utils.proj_name(), name = fname }
|
local context = { project_name = utils.proj_name(), name = fname }
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local utils = require("vern.utils")
|
local utils = require("vern-nvim.utils")
|
||||||
local templates = require("vern.templates")
|
local templates = require("vern-nvim.templates")
|
||||||
|
|
||||||
local join = vim.fs.joinpath
|
local join = vim.fs.joinpath
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
local actions = require("vern.actions.c")
|
local actions = require("vern-nvim.actions.c")
|
||||||
local config = require("vern.configs.c")
|
local config = require("vern-nvim.configs.c")
|
||||||
|
|
||||||
---@param bufnr integer Buffer to activate on : defaults to 0
|
---@param bufnr integer Buffer to activate on : defaults to 0
|
||||||
---@param user_opts? VernCConfig
|
---@param user_opts? VernCConfig
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
local actions = require("vern.actions.cpp")
|
local actions = require("vern-nvim.actions.cpp")
|
||||||
local config = require("vern.configs.cpp")
|
local config = require("vern-nvim.configs.cpp")
|
||||||
|
|
||||||
---@param bufnr integer Buffer to activate on : defaults to 0
|
---@param bufnr integer Buffer to activate on : defaults to 0
|
||||||
---@param user_opts? VernCPPConfig
|
---@param user_opts? VernCPPConfig
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
local actions = require("vern-nvim.actions.lua")
|
||||||
|
local config = require("vern-nvim.configs.lua")
|
||||||
|
|
||||||
|
---@param bufnr integer Buffer to activate on : defaults to 0
|
||||||
|
---@param user_opts? VernLuaConfig
|
||||||
|
return function(bufnr, user_opts)
|
||||||
|
---@type VernLuaConfig
|
||||||
|
local opts = vim.tbl_deep_extend("force", {}, config, user_opts or {})
|
||||||
|
vim.api.nvim_buf_create_user_command(bufnr, "LuaRun", function()
|
||||||
|
if type(actions.run) == "function" then
|
||||||
|
actions.run(opts)
|
||||||
|
end
|
||||||
|
end, { desc = "Run lua project" })
|
||||||
|
|
||||||
|
for key, def in pairs(opts.lua.keybinds or {}) do
|
||||||
|
if type(def.action) == "function" then
|
||||||
|
vim.keymap.set("n", key, function()
|
||||||
|
def.action(opts)
|
||||||
|
end, {
|
||||||
|
buffer = bufnr,
|
||||||
|
silent = true,
|
||||||
|
desc = def.desc,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
local actions = require("vern.actions.python")
|
local actions = require("vern-nvim.actions.python")
|
||||||
local config = require("vern.configs.python")
|
local config = require("vern-nvim.configs.python")
|
||||||
|
|
||||||
---@param bufnr integer Buffer to activate on : defaults to 0
|
---@param bufnr integer Buffer to activate on : defaults to 0
|
||||||
---@param user_opts? VernPythonConfig
|
---@param user_opts? VernPythonConfig
|
||||||
@@ -30,7 +30,7 @@ return function(bufnr, user_opts)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local root = require("vern.utils").proj_root()
|
local root = require("vern-nvim.utils").proj_root()
|
||||||
if not root then
|
if not root then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -10,11 +10,11 @@ M.c = {
|
|||||||
keybinds = {
|
keybinds = {
|
||||||
["<leader>pr"] = {
|
["<leader>pr"] = {
|
||||||
desc = "Executes c code",
|
desc = "Executes c code",
|
||||||
action = require("vern.actions.c").run,
|
action = require("vern-nvim.actions.c").run,
|
||||||
},
|
},
|
||||||
["<leader>pf"] = {
|
["<leader>pf"] = {
|
||||||
desc = "Creates source/header files",
|
desc = "Creates source/header files",
|
||||||
action = require("vern.actions.c").create_file,
|
action = require("vern-nvim.actions.c").create_file,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
templates = {
|
templates = {
|
||||||
@@ -23,19 +23,19 @@ M.c = {
|
|||||||
path = "{dirs.src}",
|
path = "{dirs.src}",
|
||||||
name = "main.c",
|
name = "main.c",
|
||||||
kind = "main",
|
kind = "main",
|
||||||
kind_path = "vern.templates.c",
|
kind_path = "vern-nvim.templates.c",
|
||||||
},
|
},
|
||||||
manifest = {
|
manifest = {
|
||||||
path = ".",
|
path = ".",
|
||||||
name = "CMakeLists.txt",
|
name = "CMakeLists.txt",
|
||||||
kind = "CmakeLists",
|
kind = "CmakeLists",
|
||||||
kind_path = "vern.templates.c",
|
kind_path = "vern-nvim.templates.c",
|
||||||
},
|
},
|
||||||
style = {
|
style = {
|
||||||
path = ".",
|
path = ".",
|
||||||
name = ".clang-format",
|
name = ".clang-format",
|
||||||
kind = "format",
|
kind = "format",
|
||||||
kind_path = "vern.templates.c",
|
kind_path = "vern-nvim.templates.c",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
file = {
|
file = {
|
||||||
@@ -43,13 +43,13 @@ M.c = {
|
|||||||
path = "{dirs.include}",
|
path = "{dirs.include}",
|
||||||
name = "{name}.h",
|
name = "{name}.h",
|
||||||
kind = "header",
|
kind = "header",
|
||||||
kind_path = "vern.templates.c",
|
kind_path = "vern-nvim.templates.c",
|
||||||
},
|
},
|
||||||
source = {
|
source = {
|
||||||
path = "{dirs.src}",
|
path = "{dirs.src}",
|
||||||
name = "{name}.c",
|
name = "{name}.c",
|
||||||
kind = "source",
|
kind = "source",
|
||||||
kind_path = "vern.templates.c",
|
kind_path = "vern-nvim.templates.c",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
extras = {
|
extras = {
|
||||||
@@ -57,7 +57,7 @@ M.c = {
|
|||||||
path = ".",
|
path = ".",
|
||||||
name = ".clang-tidy",
|
name = ".clang-tidy",
|
||||||
kind = "linter",
|
kind = "linter",
|
||||||
kind_path = "vern.templates.c",
|
kind_path = "vern-nvim.templates.c",
|
||||||
enabled = false,
|
enabled = false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -10,11 +10,11 @@ M.cpp = {
|
|||||||
keybinds = {
|
keybinds = {
|
||||||
["<leader>pr"] = {
|
["<leader>pr"] = {
|
||||||
desc = "Executes cpp code",
|
desc = "Executes cpp code",
|
||||||
action = require("vern.actions.cpp").run,
|
action = require("vern-nvim.actions.cpp").run,
|
||||||
},
|
},
|
||||||
["<leader>pf"] = {
|
["<leader>pf"] = {
|
||||||
desc = "Creates source/header files",
|
desc = "Creates source/header files",
|
||||||
action = require("vern.actions.cpp").create_file,
|
action = require("vern-nvim.actions.cpp").create_file,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
templates = {
|
templates = {
|
||||||
@@ -23,19 +23,19 @@ M.cpp = {
|
|||||||
path = "{dirs.src}",
|
path = "{dirs.src}",
|
||||||
name = "main.cpp",
|
name = "main.cpp",
|
||||||
kind = "main",
|
kind = "main",
|
||||||
kind_path = "vern.templates.cpp",
|
kind_path = "vern-nvim.templates.cpp",
|
||||||
},
|
},
|
||||||
manifest = {
|
manifest = {
|
||||||
path = ".",
|
path = ".",
|
||||||
name = "CMakeLists.txt",
|
name = "CMakeLists.txt",
|
||||||
kind = "CmakeLists",
|
kind = "CmakeLists",
|
||||||
kind_path = "vern.templates.cpp",
|
kind_path = "vern-nvim.templates.cpp",
|
||||||
},
|
},
|
||||||
style = {
|
style = {
|
||||||
path = ".",
|
path = ".",
|
||||||
name = ".clang-format",
|
name = ".clang-format",
|
||||||
kind = "format",
|
kind = "format",
|
||||||
kind_path = "vern.templates.cpp",
|
kind_path = "vern-nvim.templates.cpp",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
file = {
|
file = {
|
||||||
@@ -43,13 +43,13 @@ M.cpp = {
|
|||||||
path = "{dirs.include}",
|
path = "{dirs.include}",
|
||||||
name = "{name}.hpp",
|
name = "{name}.hpp",
|
||||||
kind = "header",
|
kind = "header",
|
||||||
kind_path = "vern.templates.cpp",
|
kind_path = "vern-nvim.templates.cpp",
|
||||||
},
|
},
|
||||||
source = {
|
source = {
|
||||||
path = "{dirs.src}",
|
path = "{dirs.src}",
|
||||||
name = "{name}.c",
|
name = "{name}.c",
|
||||||
kind = "source",
|
kind = "source",
|
||||||
kind_path = "vern.templates.cpp",
|
kind_path = "vern-nvim.templates.cpp",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
extras = {
|
extras = {
|
||||||
@@ -57,7 +57,7 @@ M.cpp = {
|
|||||||
path = ".",
|
path = ".",
|
||||||
name = ".clang-tidy",
|
name = ".clang-tidy",
|
||||||
kind = "linter",
|
kind = "linter",
|
||||||
kind_path = "vern.templates.c",
|
kind_path = "vern-nvim.templates.c",
|
||||||
enabled = false,
|
enabled = false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
local actions = require("vern.actions")
|
local actions = require("vern-nvim.actions")
|
||||||
|
|
||||||
---@type VernCoreConfig
|
---@type VernCoreConfig
|
||||||
return {
|
return {
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
---@type VernLanguageConfig
|
||||||
|
M.lua = {
|
||||||
|
root = "Lua",
|
||||||
|
dirs = {
|
||||||
|
src = "lua/{project_name}",
|
||||||
|
},
|
||||||
|
keybinds = {
|
||||||
|
["<leader>pr"] = {
|
||||||
|
desc = "Executes lua code",
|
||||||
|
action = require("vern-nvim.actions.lua").run,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
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 = "{name}.lua",
|
||||||
|
kind = "source",
|
||||||
|
kind_path = "vern-nvim.templates.lua",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
extras = {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -9,11 +9,11 @@ M.python = {
|
|||||||
keybinds = {
|
keybinds = {
|
||||||
["<leader>pr"] = {
|
["<leader>pr"] = {
|
||||||
desc = "Executes python code",
|
desc = "Executes python code",
|
||||||
action = require("vern.actions.python").run,
|
action = require("vern-nvim.actions.python").run,
|
||||||
},
|
},
|
||||||
["<leader>pi"] = {
|
["<leader>pi"] = {
|
||||||
desc = "Asks for what python package to install",
|
desc = "Asks for what python package to install",
|
||||||
action = require("vern.actions.python").pip_install,
|
action = require("vern-nvim.actions.python").pip_install,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
templates = {
|
templates = {
|
||||||
@@ -22,27 +22,27 @@ M.python = {
|
|||||||
path = "{dirs.src}",
|
path = "{dirs.src}",
|
||||||
name = "main.py",
|
name = "main.py",
|
||||||
kind = "main",
|
kind = "main",
|
||||||
kind_path = "vern.templates.python",
|
kind_path = "vern-nvim.templates.python",
|
||||||
},
|
},
|
||||||
manifest = {
|
manifest = {
|
||||||
path = ".",
|
path = ".",
|
||||||
name = "pyproject.toml",
|
name = "pyproject.toml",
|
||||||
kind = "pyproject",
|
kind = "pyproject",
|
||||||
kind_path = "vern.templates.python",
|
kind_path = "vern-nvim.templates.python",
|
||||||
},
|
},
|
||||||
pkg_init = {
|
pkg_init = {
|
||||||
path = "{dirs.src}",
|
path = "{dirs.src}",
|
||||||
name = "__init__.py",
|
name = "__init__.py",
|
||||||
kind = "__init__",
|
kind = "__init__",
|
||||||
kind_path = "vern.templates.python",
|
kind_path = "vern-nvim.templates.python",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
file = {
|
file = {
|
||||||
mod = {
|
source = {
|
||||||
path = "{dirs.src}",
|
path = "{dirs.src}",
|
||||||
name = "{name}.py",
|
name = "{name}.py",
|
||||||
kind = "module",
|
kind = "module",
|
||||||
kind_path = "vern.templates.python",
|
kind_path = "vern-nvim.templates.python",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
extras = {},
|
extras = {},
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local configs = require("vern.configs")
|
local configs = require("vern-nvim.configs")
|
||||||
local actions = require("vern.actions")
|
local actions = require("vern-nvim.actions")
|
||||||
|
|
||||||
---@type VernCoreConfig
|
---@type VernCoreConfig
|
||||||
M.opts = vim.deepcopy(configs)
|
M.opts = vim.deepcopy(configs)
|
||||||
@@ -45,7 +45,7 @@ function M.setup(user_opts)
|
|||||||
pattern = "*",
|
pattern = "*",
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
local ft = vim.bo[args.buf].filetype
|
local ft = vim.bo[args.buf].filetype
|
||||||
local ok, attach = pcall(require, "vern.attach." .. ft)
|
local ok, attach = pcall(require, "vern-nvim.attach." .. ft)
|
||||||
if ok and type(attach) == "function" then
|
if ok and type(attach) == "function" then
|
||||||
attach(args.buf, M.opts)
|
attach(args.buf, M.opts)
|
||||||
end
|
end
|
||||||
@@ -2,31 +2,6 @@ local utils = require("Polydev.utils")
|
|||||||
local configs = require("Polydev.configs")
|
local configs = require("Polydev.configs")
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local loaded_languages = {}
|
|
||||||
|
|
||||||
---@param lang string
|
|
||||||
---@param opts? table
|
|
||||||
---@return boolean
|
|
||||||
function M.load_language_module(lang, opts)
|
|
||||||
if loaded_languages[lang] then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
local ok, mod = pcall(require, "Polydev.languages")
|
|
||||||
if not ok or type(mod.languages) ~= "table" then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local lang_mod = mod.languages[lang]
|
|
||||||
if type(lang_mod) ~= "table" or type(lang_mod.setup) ~= "function" then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
lang_mod:setup(opts and opts[lang] or {})
|
|
||||||
loaded_languages[lang] = lang_mod
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
M.languages = {
|
M.languages = {
|
||||||
javascript = {
|
javascript = {
|
||||||
setup = function(self, user_opts)
|
setup = function(self, user_opts)
|
||||||
@@ -99,85 +74,6 @@ M.languages = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
c = {
|
|
||||||
setup = function(self, user_opts)
|
|
||||||
local opts = vim.tbl_deep_extend("force", {}, configs.get("c"), user_opts or {})
|
|
||||||
vim.api.nvim_create_user_command("CRun", function()
|
|
||||||
self:run()
|
|
||||||
end, {})
|
|
||||||
for key, _ in pairs(opts.keybinds) do
|
|
||||||
vim.keymap.set("n", key, ":CRun<CR>", { silent = true })
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
run = function()
|
|
||||||
local root = utils.get_project_root()
|
|
||||||
local build_dir = root .. "/build"
|
|
||||||
|
|
||||||
local cmd = "cd '" .. build_dir .. "' && cmake --build ."
|
|
||||||
local output = vim.fn.system(cmd)
|
|
||||||
local success = vim.v.shell_error == 0
|
|
||||||
|
|
||||||
if not success then
|
|
||||||
local term_buf = utils.terminal({ cmd })
|
|
||||||
vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf })
|
|
||||||
vim.api.nvim_buf_set_lines(
|
|
||||||
term_buf,
|
|
||||||
0,
|
|
||||||
-1,
|
|
||||||
false,
|
|
||||||
vim.list_extend(
|
|
||||||
{ "Error during compilation:" },
|
|
||||||
vim.split(output, "\n", { trimempty = true })
|
|
||||||
)
|
|
||||||
)
|
|
||||||
vim.api.nvim_set_option_value("modifiable", false, { buf = term_buf })
|
|
||||||
end
|
|
||||||
if success then
|
|
||||||
local run_cmd = "cd '" .. build_dir .. "' && ./" .. utils.get_project_name()
|
|
||||||
utils.terminal({ run_cmd })
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
cpp = {
|
|
||||||
setup = function(self, user_opts)
|
|
||||||
local opts = vim.tbl_deep_extend("force", {}, configs.get("cpp"), user_opts or {})
|
|
||||||
vim.api.nvim_create_user_command("CppRun", function()
|
|
||||||
self:run()
|
|
||||||
end, {})
|
|
||||||
for key, _ in pairs(opts.keybinds) do
|
|
||||||
vim.keymap.set("n", key, ":CppRun<CR>", { silent = true })
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
run = function()
|
|
||||||
local root = utils.get_project_root()
|
|
||||||
local build_dir = root .. "/build"
|
|
||||||
|
|
||||||
local cmd = "cd '" .. build_dir .. "' && cmake --build ."
|
|
||||||
local output = vim.fn.system(cmd)
|
|
||||||
local success = vim.v.shell_error == 0
|
|
||||||
|
|
||||||
if not success then
|
|
||||||
local term_buf = utils.terminal({ cmd })
|
|
||||||
|
|
||||||
vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf })
|
|
||||||
vim.api.nvim_buf_set_lines(
|
|
||||||
term_buf,
|
|
||||||
0,
|
|
||||||
-1,
|
|
||||||
false,
|
|
||||||
vim.list_extend(
|
|
||||||
{ "Error during compilation:" },
|
|
||||||
vim.split(output, "\n", { trimempty = true })
|
|
||||||
)
|
|
||||||
)
|
|
||||||
vim.api.nvim_set_option_value("modifiable", false, { buf = term_buf })
|
|
||||||
end
|
|
||||||
if success then
|
|
||||||
local run_cmd = "cd '" .. build_dir .. "' && ./" .. utils.get_project_name()
|
|
||||||
utils.terminal({ run_cmd })
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
html = {
|
html = {
|
||||||
setup = function(user_opts)
|
setup = function(user_opts)
|
||||||
vim.tbl_deep_extend("force", {}, configs.get("html"), user_opts or {})
|
vim.tbl_deep_extend("force", {}, configs.get("html"), user_opts or {})
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
local utils = require("Polydev.utils")
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.projects = {
|
||||||
|
javascript = {
|
||||||
|
run = function(project_name, project_root)
|
||||||
|
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||||
|
vim.fn.mkdir(full_project_root, "p")
|
||||||
|
utils.write_file(
|
||||||
|
{ full_project_root, "main.js" },
|
||||||
|
[[
|
||||||
|
console.log("Hello World!");
|
||||||
|
]]
|
||||||
|
)
|
||||||
|
local gitignore = { "" }
|
||||||
|
utils.init_git(full_project_root, gitignore)
|
||||||
|
vim.cmd("edit " .. full_project_root .. "/main.js")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
lua = {
|
||||||
|
run = function(project_name, project_root)
|
||||||
|
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||||
|
vim.fn.mkdir(full_project_root .. "/lua/" .. project_name, "p")
|
||||||
|
utils.write_file(
|
||||||
|
{ full_project_root, "lua", project_name, "init.lua" },
|
||||||
|
[[
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
return M
|
||||||
|
]]
|
||||||
|
)
|
||||||
|
local gitignore = { "" }
|
||||||
|
utils.init_git(full_project_root, gitignore)
|
||||||
|
vim.cmd("edit " .. full_project_root .. "/lua/" .. project_name .. "/init.lua")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
java = {
|
||||||
|
run = function(project_name, project_root)
|
||||||
|
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||||
|
for _, path in ipairs({ "/src", "/build" }) do
|
||||||
|
vim.fn.mkdir(full_project_root .. path, "p")
|
||||||
|
end
|
||||||
|
local content = [[
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println("Hello, World!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]
|
||||||
|
local gitignore = {
|
||||||
|
"build/",
|
||||||
|
}
|
||||||
|
utils.init_git(full_project_root, gitignore)
|
||||||
|
utils.write_file({ full_project_root, "src", "Main.java" }, content)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
python = {
|
||||||
|
run = function(project_name, project_root)
|
||||||
|
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||||
|
vim.fn.mkdir(full_project_root .. "/include", "p")
|
||||||
|
utils.write_file(
|
||||||
|
{ full_project_root, "main.py" },
|
||||||
|
[[
|
||||||
|
def main():
|
||||||
|
print("Hello, World!")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
]]
|
||||||
|
)
|
||||||
|
utils.write_file({ full_project_root, "include/__init__.py" }, "")
|
||||||
|
utils.write_file({ full_project_root, "requirements.txt" }, "")
|
||||||
|
utils.write_file(
|
||||||
|
{ full_project_root, "setup.py" },
|
||||||
|
string.format(
|
||||||
|
[[
|
||||||
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="%s",
|
||||||
|
version="0.1.0",
|
||||||
|
packages=find_packages(),
|
||||||
|
install_requires=[],
|
||||||
|
python_requires=">=3.6",
|
||||||
|
)
|
||||||
|
]],
|
||||||
|
project_name
|
||||||
|
)
|
||||||
|
)
|
||||||
|
local gitignore = {
|
||||||
|
"venv/",
|
||||||
|
}
|
||||||
|
utils.init_git(full_project_root, gitignore)
|
||||||
|
vim.cmd("edit " .. full_project_root .. "/main.py")
|
||||||
|
local venv_path = full_project_root .. "/venv"
|
||||||
|
vim.fn.system("python3 -m venv " .. venv_path)
|
||||||
|
vim.g.python3_host_prog = venv_path .. "/bin/python"
|
||||||
|
vim.fn.setenv("VIRTUAL_ENV", venv_path)
|
||||||
|
vim.fn.setenv("PATH", venv_path .. "/bin:" .. vim.fn.getenv("PATH"))
|
||||||
|
print("Virtual environment activated for " .. project_name)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
rust = {
|
||||||
|
run = function(project_name, project_root)
|
||||||
|
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||||
|
vim.fn.system("cargo new " .. full_project_root)
|
||||||
|
vim.cmd("edit " .. full_project_root .. "/src/main.rs")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
html = {
|
||||||
|
run = function(project_name, project_root)
|
||||||
|
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||||
|
if vim.fn.isdirectory(full_project_root) == 0 then
|
||||||
|
vim.fn.mkdir(full_project_root, "p") -- Create directory with parent directories
|
||||||
|
end
|
||||||
|
local main_html_content = [[
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Page Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>My First Heading</h1>
|
||||||
|
<p>My first paragraph.</p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
]]
|
||||||
|
utils.write_file({ full_project_root, "index.html" }, main_html_content)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
M.files = {
|
||||||
|
lua = {
|
||||||
|
run = function(file_name)
|
||||||
|
utils.write_file({
|
||||||
|
utils.get_project_root(),
|
||||||
|
"lua",
|
||||||
|
utils.get_project_name(),
|
||||||
|
file_name .. ".lua",
|
||||||
|
}, "")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
java = {
|
||||||
|
run = function(file_name)
|
||||||
|
utils.write_file(
|
||||||
|
{ utils.get_project_root(), "src", file_name .. ".java" },
|
||||||
|
string.format(
|
||||||
|
[[
|
||||||
|
public class %s {
|
||||||
|
// New File
|
||||||
|
}
|
||||||
|
]],
|
||||||
|
file_name
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
python = {
|
||||||
|
run = function(file_name)
|
||||||
|
utils.write_file({ utils.get_project_root(), "include", file_name .. ".py" }, "")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
rust = {
|
||||||
|
run = function(file_name)
|
||||||
|
utils.write_file({ utils.get_project_root(), "src", file_name .. ".rs" }, "")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
html = {
|
||||||
|
run = function(file_name)
|
||||||
|
utils.write_file(
|
||||||
|
{ ".", file_name .. ".html" },
|
||||||
|
string.format([[
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Page Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>My First Heading</h1>
|
||||||
|
<p>My first paragraph.</p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
]])
|
||||||
|
)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
||||||
+14
@@ -22,6 +22,20 @@ env/
|
|||||||
venv/
|
venv/
|
||||||
.pytest_cache/
|
.pytest_cache/
|
||||||
]=]),
|
]=]),
|
||||||
|
|
||||||
|
c = vim.trim([=[
|
||||||
|
build/
|
||||||
|
.cache/
|
||||||
|
]=]),
|
||||||
|
|
||||||
|
cpp = vim.trim([=[
|
||||||
|
build/
|
||||||
|
.cache/
|
||||||
|
]=]),
|
||||||
|
|
||||||
|
lua = vim.trim([=[
|
||||||
|
luac.out
|
||||||
|
]=]),
|
||||||
}
|
}
|
||||||
|
|
||||||
local extra = (lang and lang_block[lang]) or ""
|
local extra = (lang and lang_block[lang]) or ""
|
||||||
@@ -56,6 +56,9 @@
|
|||||||
|
|
||||||
---@class VernCConfig : VernCoreConfig
|
---@class VernCConfig : VernCoreConfig
|
||||||
---@field c? VernLanguageConfig
|
---@field c? VernLanguageConfig
|
||||||
---
|
|
||||||
---@class VernCPPConfig : VernCoreConfig
|
---@class VernCPPConfig : VernCoreConfig
|
||||||
---@field cpp? VernLanguageConfig
|
---@field cpp? VernLanguageConfig
|
||||||
|
|
||||||
|
---@class VernLuaConfig : VernCoreConfig
|
||||||
|
---@field lua? VernLanguageConfig
|
||||||
@@ -60,14 +60,14 @@ function M.init_git(path, ft)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local gitignore = require("vern.templates.extras.gitignore").template(ft)
|
local gitignore = require("vern-nvim.templates.extras.gitignore").template(ft)
|
||||||
vim.fn.system({ "git", "-C", path, "init" })
|
vim.fn.system({ "git", "-C", path, "init" })
|
||||||
M.dump(vim.fs.joinpath(path, ".gitignore"), gitignore)
|
M.dump(vim.fs.joinpath(path, ".gitignore"), gitignore)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param path string
|
---@param path string
|
||||||
function M.init_readme(path)
|
function M.init_readme(path)
|
||||||
local readme = require("vern.templates.extras.readme")
|
local readme = require("vern-nvim.templates.extras.readme")
|
||||||
M.dump(vim.fs.joinpath(path, "README.md"), readme)
|
M.dump(vim.fs.joinpath(path, "README.md"), readme)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1,487 +0,0 @@
|
|||||||
local utils = require("Polydev.utils")
|
|
||||||
|
|
||||||
local M = {}
|
|
||||||
|
|
||||||
local function extras(guard, file_type, file_name)
|
|
||||||
if not file_name then
|
|
||||||
return print("Header file creation canceled")
|
|
||||||
end
|
|
||||||
local guard_macro = file_name:upper():gsub("[^A-Z0-9]", "_") .. guard
|
|
||||||
local content = string.format(
|
|
||||||
[[
|
|
||||||
#ifndef %s
|
|
||||||
#define %s
|
|
||||||
|
|
||||||
// Add code here
|
|
||||||
|
|
||||||
#endif
|
|
||||||
]],
|
|
||||||
guard_macro,
|
|
||||||
guard_macro
|
|
||||||
)
|
|
||||||
utils.write_file(
|
|
||||||
{ utils.get_project_root(), "include", file_name .. file_type },
|
|
||||||
content
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
M.projects = {
|
|
||||||
javascript = {
|
|
||||||
run = function(project_name, project_root)
|
|
||||||
local full_project_root = vim.fn.expand(project_root)
|
|
||||||
.. "/"
|
|
||||||
.. project_name
|
|
||||||
vim.fn.mkdir(full_project_root, "p")
|
|
||||||
utils.write_file(
|
|
||||||
{ full_project_root, "main.js" },
|
|
||||||
[[
|
|
||||||
console.log("Hello World!");
|
|
||||||
]]
|
|
||||||
)
|
|
||||||
local gitignore = { "" }
|
|
||||||
utils.init_git(full_project_root, gitignore)
|
|
||||||
vim.cmd("edit " .. full_project_root .. "/main.js")
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
lua = {
|
|
||||||
run = function(project_name, project_root)
|
|
||||||
local full_project_root = vim.fn.expand(project_root)
|
|
||||||
.. "/"
|
|
||||||
.. project_name
|
|
||||||
vim.fn.mkdir(full_project_root .. "/lua/" .. project_name, "p")
|
|
||||||
utils.write_file(
|
|
||||||
{ full_project_root, "lua", project_name, "init.lua" },
|
|
||||||
[[
|
|
||||||
local M = {}
|
|
||||||
|
|
||||||
return M
|
|
||||||
]]
|
|
||||||
)
|
|
||||||
local gitignore = { "" }
|
|
||||||
utils.init_git(full_project_root, gitignore)
|
|
||||||
vim.cmd(
|
|
||||||
"edit "
|
|
||||||
.. full_project_root
|
|
||||||
.. "/lua/"
|
|
||||||
.. project_name
|
|
||||||
.. "/init.lua"
|
|
||||||
)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
java = {
|
|
||||||
run = function(project_name, project_root)
|
|
||||||
local full_project_root = vim.fn.expand(project_root)
|
|
||||||
.. "/"
|
|
||||||
.. project_name
|
|
||||||
for _, path in ipairs({ "/src", "/build" }) do
|
|
||||||
vim.fn.mkdir(full_project_root .. path, "p")
|
|
||||||
end
|
|
||||||
local content = [[
|
|
||||||
public class Main {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
System.out.println("Hello, World!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]]
|
|
||||||
local gitignore = {
|
|
||||||
"build/",
|
|
||||||
}
|
|
||||||
utils.init_git(full_project_root, gitignore)
|
|
||||||
utils.write_file({ full_project_root, "src", "Main.java" }, content)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
python = {
|
|
||||||
run = function(project_name, project_root)
|
|
||||||
local full_project_root = vim.fn.expand(project_root)
|
|
||||||
.. "/"
|
|
||||||
.. project_name
|
|
||||||
vim.fn.mkdir(full_project_root .. "/include", "p")
|
|
||||||
utils.write_file(
|
|
||||||
{ full_project_root, "main.py" },
|
|
||||||
[[
|
|
||||||
def main():
|
|
||||||
print("Hello, World!")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
]]
|
|
||||||
)
|
|
||||||
utils.write_file({ full_project_root, "include/__init__.py" }, "")
|
|
||||||
utils.write_file({ full_project_root, "requirements.txt" }, "")
|
|
||||||
utils.write_file(
|
|
||||||
{ full_project_root, "setup.py" },
|
|
||||||
string.format(
|
|
||||||
[[
|
|
||||||
from setuptools import setup, find_packages
|
|
||||||
|
|
||||||
setup(
|
|
||||||
name="%s",
|
|
||||||
version="0.1.0",
|
|
||||||
packages=find_packages(),
|
|
||||||
install_requires=[],
|
|
||||||
python_requires=">=3.6",
|
|
||||||
)
|
|
||||||
]],
|
|
||||||
project_name
|
|
||||||
)
|
|
||||||
)
|
|
||||||
local gitignore = {
|
|
||||||
"venv/",
|
|
||||||
}
|
|
||||||
utils.init_git(full_project_root, gitignore)
|
|
||||||
vim.cmd("edit " .. full_project_root .. "/main.py")
|
|
||||||
local venv_path = full_project_root .. "/venv"
|
|
||||||
vim.fn.system("python3 -m venv " .. venv_path)
|
|
||||||
vim.g.python3_host_prog = venv_path .. "/bin/python"
|
|
||||||
vim.fn.setenv("VIRTUAL_ENV", venv_path)
|
|
||||||
vim.fn.setenv("PATH", venv_path .. "/bin:" .. vim.fn.getenv("PATH"))
|
|
||||||
print("Virtual environment activated for " .. project_name)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
c = {
|
|
||||||
run = function(project_name, project_root)
|
|
||||||
local full_project_root = vim.fn.expand(project_root)
|
|
||||||
.. "/"
|
|
||||||
.. project_name
|
|
||||||
for _, path in ipairs({ "/src", "/build", "/include" }) do
|
|
||||||
vim.fn.mkdir(full_project_root .. path, "p")
|
|
||||||
end
|
|
||||||
utils.write_file(
|
|
||||||
{ full_project_root, ".clang-format" },
|
|
||||||
[[
|
|
||||||
---
|
|
||||||
BasedOnStyle: Google
|
|
||||||
Standard: Latest
|
|
||||||
UseTab: Always
|
|
||||||
TabWidth: 8
|
|
||||||
IndentWidth: 8
|
|
||||||
BreakBeforeBraces: Allman
|
|
||||||
SpaceBeforeCpp11BracedList: true
|
|
||||||
SeparateDefinitionBlocks: Always
|
|
||||||
Cpp11BracedListStyle: false
|
|
||||||
BreakAfterReturnType: TopLevel
|
|
||||||
AlignTrailingComments:
|
|
||||||
Kind: Always
|
|
||||||
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
|
|
||||||
]]
|
|
||||||
)
|
|
||||||
utils.write_file(
|
|
||||||
{ full_project_root, "src/main.c" },
|
|
||||||
[[
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
printf("%s", "Hello World");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
]]
|
|
||||||
)
|
|
||||||
|
|
||||||
utils.write_file(
|
|
||||||
{ full_project_root, ".clang-tidy" },
|
|
||||||
string.format([[
|
|
||||||
---
|
|
||||||
Checks: >
|
|
||||||
-*,
|
|
||||||
bugprone-*,
|
|
||||||
concurrency-*,
|
|
||||||
misc-*,
|
|
||||||
modernize-*,
|
|
||||||
performance-*,
|
|
||||||
readability-*,
|
|
||||||
portability-*,
|
|
||||||
-readability-braces-around-statements,
|
|
||||||
-readability-implicit-bool-conversion
|
|
||||||
|
|
||||||
WarningsAsErrors: ""
|
|
||||||
|
|
||||||
CheckOptions:
|
|
||||||
- key: readability-identifier-naming.VariableCase
|
|
||||||
value: lower_case
|
|
||||||
- key: readability-identifier-naming.FunctionCase
|
|
||||||
value: lower_case
|
|
||||||
---
|
|
||||||
]])
|
|
||||||
)
|
|
||||||
utils.write_file(
|
|
||||||
{ full_project_root, "CMakeLists.txt" },
|
|
||||||
string.format(
|
|
||||||
[[
|
|
||||||
cmake_minimum_required(VERSION 3.16)
|
|
||||||
set(CMAKE_C_STANDARD 23)
|
|
||||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
||||||
include_directories(include)
|
|
||||||
project(%s LANGUAGES C)
|
|
||||||
|
|
||||||
set(SOURCES
|
|
||||||
src/main.c
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(%s ${SOURCES})
|
|
||||||
]],
|
|
||||||
project_name,
|
|
||||||
project_name,
|
|
||||||
project_name
|
|
||||||
)
|
|
||||||
)
|
|
||||||
local gitignore = { "build/", ".cache/" }
|
|
||||||
utils.init_git(full_project_root, gitignore)
|
|
||||||
vim.fn.system(
|
|
||||||
string.format(
|
|
||||||
"cd %s/build && cmake -S .. -B . && cmake --build . && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..",
|
|
||||||
full_project_root
|
|
||||||
)
|
|
||||||
)
|
|
||||||
vim.cmd("edit " .. full_project_root .. "/src/main.c")
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
cpp = {
|
|
||||||
run = function(project_name, project_root)
|
|
||||||
local full_project_root = vim.fn.expand(project_root)
|
|
||||||
.. "/"
|
|
||||||
.. project_name
|
|
||||||
for _, path in ipairs({ "/src", "/build", "/include" }) do
|
|
||||||
vim.fn.mkdir(full_project_root .. path, "p")
|
|
||||||
end
|
|
||||||
utils.write_file(
|
|
||||||
{ full_project_root, ".clang-format" },
|
|
||||||
[[
|
|
||||||
---
|
|
||||||
BasedOnStyle: Google
|
|
||||||
Standard: Latest
|
|
||||||
UseTab: Always
|
|
||||||
TabWidth: 8
|
|
||||||
IndentWidth: 8
|
|
||||||
BreakBeforeBraces: Allman
|
|
||||||
SpaceBeforeCpp11BracedList: true
|
|
||||||
SeparateDefinitionBlocks: Always
|
|
||||||
Cpp11BracedListStyle: false
|
|
||||||
BreakAfterReturnType: TopLevel
|
|
||||||
AlignTrailingComments:
|
|
||||||
Kind: Always
|
|
||||||
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
|
|
||||||
]]
|
|
||||||
)
|
|
||||||
|
|
||||||
utils.write_file(
|
|
||||||
{ full_project_root, "src/main.cpp" },
|
|
||||||
[[
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
std::cout << "Hello World\n";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
]]
|
|
||||||
)
|
|
||||||
|
|
||||||
utils.write_file(
|
|
||||||
{ full_project_root, ".clang-tidy" },
|
|
||||||
string.format([[
|
|
||||||
---
|
|
||||||
Checks: >
|
|
||||||
-*,
|
|
||||||
bugprone-*,
|
|
||||||
concurrency-*,
|
|
||||||
misc-*,
|
|
||||||
modernize-*,
|
|
||||||
performance-*,
|
|
||||||
readability-*,
|
|
||||||
portability-*,
|
|
||||||
-readability-braces-around-statements,
|
|
||||||
-readability-implicit-bool-conversion
|
|
||||||
|
|
||||||
WarningsAsErrors: ""
|
|
||||||
|
|
||||||
CheckOptions:
|
|
||||||
- key: readability-identifier-naming.VariableCase
|
|
||||||
value: lower_case
|
|
||||||
- key: readability-identifier-naming.FunctionCase
|
|
||||||
value: lower_case
|
|
||||||
---
|
|
||||||
]])
|
|
||||||
)
|
|
||||||
|
|
||||||
utils.write_file(
|
|
||||||
{ full_project_root, "CMakeLists.txt" },
|
|
||||||
string.format(
|
|
||||||
[[
|
|
||||||
cmake_minimum_required(VERSION 3.16)
|
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
||||||
project(%s LANGUAGES CXX)
|
|
||||||
|
|
||||||
|
|
||||||
set(SOURCES
|
|
||||||
src/main.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(%s ${SOURCES})
|
|
||||||
]],
|
|
||||||
project_name,
|
|
||||||
project_name
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
local gitignore = { "build/", ".cache/" }
|
|
||||||
utils.init_git(full_project_root, gitignore)
|
|
||||||
vim.fn.system(
|
|
||||||
string.format(
|
|
||||||
"cd %s/build && cmake -S .. -B . && cmake --build . && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..",
|
|
||||||
full_project_root
|
|
||||||
)
|
|
||||||
)
|
|
||||||
vim.cmd("edit " .. full_project_root .. "/src/main.cpp")
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
rust = {
|
|
||||||
run = function(project_name, project_root)
|
|
||||||
local full_project_root = vim.fn.expand(project_root)
|
|
||||||
.. "/"
|
|
||||||
.. project_name
|
|
||||||
vim.fn.system("cargo new " .. full_project_root)
|
|
||||||
vim.cmd("edit " .. full_project_root .. "/src/main.rs")
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
html = {
|
|
||||||
run = function(project_name, project_root)
|
|
||||||
local full_project_root = vim.fn.expand(project_root)
|
|
||||||
.. "/"
|
|
||||||
.. project_name
|
|
||||||
if vim.fn.isdirectory(full_project_root) == 0 then
|
|
||||||
vim.fn.mkdir(full_project_root, "p") -- Create directory with parent directories
|
|
||||||
end
|
|
||||||
local main_html_content = [[
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Page Title</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<h1>My First Heading</h1>
|
|
||||||
<p>My first paragraph.</p>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
]]
|
|
||||||
utils.write_file(
|
|
||||||
{ full_project_root, "index.html" },
|
|
||||||
main_html_content
|
|
||||||
)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
M.files = {
|
|
||||||
lua = {
|
|
||||||
run = function(file_name)
|
|
||||||
utils.write_file(
|
|
||||||
{
|
|
||||||
utils.get_project_root(),
|
|
||||||
"lua",
|
|
||||||
utils.get_project_name(),
|
|
||||||
file_name .. ".lua",
|
|
||||||
},
|
|
||||||
""
|
|
||||||
)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
java = {
|
|
||||||
run = function(file_name)
|
|
||||||
utils.write_file(
|
|
||||||
{ utils.get_project_root(), "src", file_name .. ".java" },
|
|
||||||
string.format(
|
|
||||||
[[
|
|
||||||
public class %s {
|
|
||||||
// New File
|
|
||||||
}
|
|
||||||
]],
|
|
||||||
file_name
|
|
||||||
)
|
|
||||||
)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
python = {
|
|
||||||
run = function(file_name)
|
|
||||||
utils.write_file(
|
|
||||||
{ utils.get_project_root(), "include", file_name .. ".py" },
|
|
||||||
""
|
|
||||||
)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
c = {
|
|
||||||
run = function(file_name)
|
|
||||||
utils.write_file(
|
|
||||||
{ utils.get_project_root(), "src", file_name .. ".c" },
|
|
||||||
""
|
|
||||||
)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
cpp = {
|
|
||||||
run = function(file_name)
|
|
||||||
utils.write_file(
|
|
||||||
{ utils.get_project_root(), "src", file_name .. ".cpp" },
|
|
||||||
""
|
|
||||||
)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
rust = {
|
|
||||||
run = function(file_name)
|
|
||||||
utils.write_file(
|
|
||||||
{ utils.get_project_root(), "src", file_name .. ".rs" },
|
|
||||||
""
|
|
||||||
)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
html = {
|
|
||||||
run = function(file_name)
|
|
||||||
utils.write_file(
|
|
||||||
{ ".", file_name .. ".html" },
|
|
||||||
string.format([[
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Page Title</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<h1>My First Heading</h1>
|
|
||||||
<p>My first paragraph.</p>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
]])
|
|
||||||
)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
M.extras = {
|
|
||||||
run = function(lang, file_name)
|
|
||||||
if lang == "c" then
|
|
||||||
extras("_H", ".h", file_name)
|
|
||||||
print("Successful creation of " .. file_name .. ".h")
|
|
||||||
elseif lang == "cpp" then
|
|
||||||
extras("_HPP", ".hpp", file_name)
|
|
||||||
print("Successful creation of " .. file_name .. ".hpp")
|
|
||||||
else
|
|
||||||
print("Extras language is not found: enter cpp or c")
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
return M
|
|
||||||
Reference in New Issue
Block a user