Skip to content

Commit

Permalink
added c project starter
Browse files Browse the repository at this point in the history
  • Loading branch information
KDesp73 committed Feb 2, 2024
1 parent 0126282 commit f7a1896
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
13 changes: 7 additions & 6 deletions doc/project-starter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@

*CurrentSupport*
The plugin currently supports:
1. C++
2. Java
3. Java Swing
4. Neovim Plugin
5. Python
6. Ruby
1. C
2. C++
3. Java
4. Java Swing
5. Neovim Plugin
6. Python
7. Ruby

vim:tw=78:ts=8:ft=help:norl:
12 changes: 12 additions & 0 deletions lua/project-starter/builders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ local run_command = require("project-starter.commands")


return {
["c"] = function (name)
name = name or vim.fn.input("Name: ")
local path = paths["c"] or vim.fn.input("Path: ")

if not utils.handle_invalid_path(path) then return nil end

run_command.c(path, name)

utils.change_nvim_directory(path .. name)
return path .. name
end,

["cpp"] = function(name)
name = name or vim.fn.input("Name: ")
local path = paths["cpp"] or vim.fn.input("Path: ")
Expand Down
5 changes: 5 additions & 0 deletions lua/project-starter/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ local vim = vim

local M = {}

M.c = function(path, name)
vim.cmd(":silent !cd ".. path .. " && " .. "git clone --depth=1 https://github.com/KDesp73/c-starter " .. name)
vim.cmd(":silent !cd " .. path .. name .. " && rm -r .git")
end

M.cpp = function(path, name)
vim.cmd(":silent !cd ".. path .. " && " .. "git clone --depth=1 https://github.com/KDesp73/CPP-Project-Template " .. name)
vim.cmd(":silent !cd " .. path .. name .. " && rm -r .git")
Expand Down
3 changes: 3 additions & 0 deletions lua/project-starter/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ M.setup = function (opts)
opts = opts or {}

if opts.default_paths then
if opts.default_paths.c then
paths.c = opts.default_paths.c
end
if opts.default_paths.cpp then
paths.cpp = opts.default_paths.cpp
end
Expand Down
1 change: 1 addition & 0 deletions lua/project-starter/paths.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
return {
c = nil,
cpp = nil,
java = nil,
nvimplugins = nil,
Expand Down
2 changes: 2 additions & 0 deletions todo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TODO: autocomplete languages
DONE: allow -, _

0 comments on commit f7a1896

Please sign in to comment.