LANG: added javascript init
This commit is contained in:
+33
-14
@@ -17,6 +17,17 @@ local function extras(guard, file_type, file_name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
M.projects = {
|
M.projects = {
|
||||||
|
javascript = {
|
||||||
|
run = function(project_name, project_root)
|
||||||
|
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||||
|
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 = {
|
lua = {
|
||||||
run = function(project_name, project_root)
|
run = function(project_name, project_root)
|
||||||
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||||
@@ -89,7 +100,10 @@ setup(
|
|||||||
c = {
|
c = {
|
||||||
run = function(project_name, project_root)
|
run = function(project_name, project_root)
|
||||||
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
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
|
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" }, [[
|
utils.write_file({ full_project_root, ".clang-format" }, [[
|
||||||
---
|
---
|
||||||
BasedOnStyle: Google
|
BasedOnStyle: Google
|
||||||
@@ -159,12 +173,14 @@ add_executable(%s ${SOURCES})
|
|||||||
]], project_name, project_name, project_name))
|
]], project_name, project_name, project_name))
|
||||||
local gitignore = { "build/", ".cache/" }
|
local gitignore = { "build/", ".cache/" }
|
||||||
utils.init_git(full_project_root, gitignore)
|
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.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")
|
vim.cmd("edit " .. full_project_root .. "/src/main.c")
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
cpp = {
|
cpp = {
|
||||||
run = function (project_name, project_root)
|
run = function(project_name, project_root)
|
||||||
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||||
for _, path in ipairs({ "/src", "/build", "/include" }) do
|
for _, path in ipairs({ "/src", "/build", "/include" }) do
|
||||||
vim.fn.mkdir(full_project_root .. path, "p")
|
vim.fn.mkdir(full_project_root .. path, "p")
|
||||||
@@ -242,12 +258,14 @@ add_executable(%s ${SOURCES})
|
|||||||
|
|
||||||
local gitignore = { "build/", ".cache/" }
|
local gitignore = { "build/", ".cache/" }
|
||||||
utils.init_git(full_project_root, gitignore)
|
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.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")
|
vim.cmd("edit " .. full_project_root .. "/src/main.cpp")
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
rust = {
|
rust = {
|
||||||
run = function (project_name, project_root)
|
run = function(project_name, project_root)
|
||||||
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||||
vim.fn.system("cargo new " .. full_project_root)
|
vim.fn.system("cargo new " .. full_project_root)
|
||||||
vim.cmd("edit " .. full_project_root .. "/src/main.rs")
|
vim.cmd("edit " .. full_project_root .. "/src/main.rs")
|
||||||
@@ -280,12 +298,13 @@ add_executable(%s ${SOURCES})
|
|||||||
|
|
||||||
M.files = {
|
M.files = {
|
||||||
lua = {
|
lua = {
|
||||||
run = function (file_name)
|
run = function(file_name)
|
||||||
utils.write_file({ utils.get_project_root(), "lua", utils.get_project_name(), file_name .. ".lua"}, "")
|
utils.write_file(
|
||||||
|
{ utils.get_project_root(), "lua", utils.get_project_name(), file_name .. ".lua" }, "")
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
java = {
|
java = {
|
||||||
run = function (file_name)
|
run = function(file_name)
|
||||||
utils.write_file({ utils.get_project_root(), "src", file_name .. ".java" }, string.format([[
|
utils.write_file({ utils.get_project_root(), "src", file_name .. ".java" }, string.format([[
|
||||||
public class %s {
|
public class %s {
|
||||||
// New File
|
// New File
|
||||||
@@ -294,28 +313,28 @@ public class %s {
|
|||||||
end
|
end
|
||||||
},
|
},
|
||||||
python = {
|
python = {
|
||||||
run = function (file_name)
|
run = function(file_name)
|
||||||
utils.write_file({ utils.get_project_root(), "include", file_name .. ".py" }, "")
|
utils.write_file({ utils.get_project_root(), "include", file_name .. ".py" }, "")
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
c = {
|
c = {
|
||||||
run = function (file_name)
|
run = function(file_name)
|
||||||
utils.write_file({ utils.get_project_root(), "src", file_name .. ".c" }, "")
|
utils.write_file({ utils.get_project_root(), "src", file_name .. ".c" }, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
},
|
},
|
||||||
cpp = {
|
cpp = {
|
||||||
run = function (file_name)
|
run = function(file_name)
|
||||||
utils.write_file({ utils.get_project_root(), "src", file_name .. ".cpp" }, "")
|
utils.write_file({ utils.get_project_root(), "src", file_name .. ".cpp" }, "")
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
rust = {
|
rust = {
|
||||||
run = function (file_name)
|
run = function(file_name)
|
||||||
utils.write_file({ utils.get_project_root(), "src", file_name .. ".rs" }, "")
|
utils.write_file({ utils.get_project_root(), "src", file_name .. ".rs" }, "")
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
html = {
|
html = {
|
||||||
run = function (file_name)
|
run = function(file_name)
|
||||||
utils.write_file({ ".", file_name .. ".html" }, string.format([[
|
utils.write_file({ ".", file_name .. ".html" }, string.format([[
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
@@ -335,7 +354,7 @@ public class %s {
|
|||||||
}
|
}
|
||||||
|
|
||||||
M.extras = {
|
M.extras = {
|
||||||
run = function (lang, file_name)
|
run = function(lang, file_name)
|
||||||
if lang == "c" then
|
if lang == "c" then
|
||||||
extras("_H", ".h", file_name)
|
extras("_H", ".h", file_name)
|
||||||
print("Successful creation of " .. file_name .. ".h")
|
print("Successful creation of " .. file_name .. ".h")
|
||||||
|
|||||||
Reference in New Issue
Block a user