From 2000eb6f6d4dc4a1c1a15ae6810630f29346a7f1 Mon Sep 17 00:00:00 2001 From: Konstantinos Despoinidis Date: Sun, 24 Dec 2023 18:46:16 +0200 Subject: [PATCH] cleaning --- lua/project-starter/builders.lua | 13 ++++++------- lua/project-starter/commands.lua | 25 +++++++++++++++++++++++++ lua/project-starter/init.lua | 2 +- 3 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 lua/project-starter/commands.lua diff --git a/lua/project-starter/builders.lua b/lua/project-starter/builders.lua index 72e1b83..ccfd5f2 100644 --- a/lua/project-starter/builders.lua +++ b/lua/project-starter/builders.lua @@ -2,6 +2,7 @@ local vim = vim local paths = require("project-starter.paths") local utils = require("project-starter.utils") +local run_command = require("project-starter.commands") return { @@ -11,7 +12,7 @@ return { if not utils.handle_invalid_path(path) then return nil end - vim.cmd(":silent !cd ".. path .. " && " .. "git clone https://github.com/KDesp73/CPP-Project-Template " .. name) + run_command.cpp(path, name) utils.change_nvim_directory(path .. name) return path .. name @@ -24,9 +25,7 @@ return { if not utils.handle_invalid_path(path) then return nil end - local command = "mvn archetype:generate -DgroupId=" .. groupId .. " -DartifactId=" .. artifactId .. " -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false" - - vim.cmd(":silent !cd " .. path .. " && " .. command) + run_command.java(path, groupId, artifactId) utils.change_nvim_directory(path .. artifactId) @@ -39,7 +38,7 @@ return { if not utils.handle_invalid_path(path) then return nil end - vim.cmd(":silent !cd ".. path .. " && " .. "git clone https://github.com/KDesp73/swing-gui-starter " .. name) + run_command.swing(path, name) utils.change_nvim_directory(path .. name) @@ -53,7 +52,7 @@ return { if not utils.handle_invalid_path(path) then return nil end - vim.cmd(":silent !cd " .. path .. " && " .. "git clone https://github.com/KDesp73/plugin-template.nvim " .. name) + run_command.nvim_plugin(path, name) utils.change_nvim_directory(path .. name) @@ -66,7 +65,7 @@ return { if not utils.handle_invalid_path(path) then return nil end - vim.cmd(":silent !cd " .. path .. " && " .. "git clone https://github.com/KDesp73/python-starter.git " .. name) + run_command.python(path, name) utils.change_nvim_directory(path .. name) diff --git a/lua/project-starter/commands.lua b/lua/project-starter/commands.lua new file mode 100644 index 0000000..7aba044 --- /dev/null +++ b/lua/project-starter/commands.lua @@ -0,0 +1,25 @@ +local vim = vim + +return { + cpp = function(path, name) + vim.cmd(":silent !cd ".. path .. " && " .. "git clone https://github.com/KDesp73/CPP-Project-Template " .. name) + end, + + java = function(path, groupId, artifactId) + local command = "mvn archetype:generate -DgroupId=" .. groupId .. " -DartifactId=" .. artifactId .. " -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false" + + vim.cmd(":silent !cd " .. path .. " && " .. command) + end, + + swing = function(path, name) + vim.cmd(":silent !cd ".. path .. " && " .. "git clone https://github.com/KDesp73/swing-gui-starter " .. name) + end, + + nvim_plugin = function (path, name) + vim.cmd(":silent !cd " .. path .. " && " .. "git clone https://github.com/KDesp73/plugin-template.nvim " .. name) + end, + + python = function (path, name) + vim.cmd(":silent !cd " .. path .. " && " .. "git clone https://github.com/KDesp73/python-starter.git " .. name) + end, +} diff --git a/lua/project-starter/init.lua b/lua/project-starter/init.lua index 73411f9..de8c8ee 100644 --- a/lua/project-starter/init.lua +++ b/lua/project-starter/init.lua @@ -63,5 +63,5 @@ vim.api.nvim_create_user_command( { desc = "Create a template project", nargs = '?' } ) - + return M