This commit is contained in:
DarthMooMancer
2025-09-04 21:07:31 -04:00
4 changed files with 191 additions and 174 deletions
+3 -5
View File
@@ -1,6 +1,6 @@
<h1 align="center">Polydev</h1> <h1 align="center">Polydev</h1>
<p align="center"><em>A multi-language project managing plugin for file creation, building, and running code—all within neovim. Whether you're coding in Java, Python, Lua, Rust, or more, Polydev provides seamless integration to boost your productivity inside Neovim.</em></p> <p align="center"><em>A multi-language project managing plugin for file creation, building, and running code—all within neovim. Whether you're coding in C/C++ Java, Python, Lua, Rust, and more, Polydev provides seamless integration to boost your productivity inside Neovim.</em></p>
<p align="center"> <p align="center">
<img src="https://img.shields.io/badge/Lua-1e90ff?style=for-the-badge&logo=lua&logoColor=white" /> <img src="https://img.shields.io/badge/Lua-1e90ff?style=for-the-badge&logo=lua&logoColor=white" />
@@ -10,9 +10,8 @@
<img src="https://img.shields.io/badge/Docs-Available-blue?style=for-the-badge&logo=readthedocs&logoColor=white" /> <img src="https://img.shields.io/badge/Docs-Available-blue?style=for-the-badge&logo=readthedocs&logoColor=white" />
</p> </p>
<p align="center">
<img src="https://github.com/user-attachments/assets/c8e84056-5080-4ec3-ba15-30be61faaf68" alt="Polydev Preview" width="720"/> https://github.com/user-attachments/assets/39d406e7-19cc-4040-823f-0a5c30dec714
</p>
## Features ## Features
@@ -26,7 +25,6 @@
> 📚 [View the full documentation](https://darthmoomancer.github.io/Polydev/) for setup, configuration, and usage details. > 📚 [View the full documentation](https://darthmoomancer.github.io/Polydev/) for setup, configuration, and usage details.
## Supported Languages ## Supported Languages
Polydev currently supports the following languages: Polydev currently supports the following languages:
+4 -1
View File
@@ -89,6 +89,10 @@ M.languages = {
run = function () run = function ()
local root = utils.get_project_root() local root = utils.get_project_root()
local build_dir = root .. "/build" local build_dir = root .. "/build"
if utils.exists(build_dir) == nil then
vim.fn.mkdir(build_dir, "p")
vim.fn.system(string.format("cd %s/build && cmake -S .. -B . && cmake --build . && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. && ln -sf compile_commands.json ../compile_commands.json", root))
end
local cmd = "cd '" .. build_dir .. "' && cmake --build ." local cmd = "cd '" .. build_dir .. "' && cmake --build ."
local output = vim.fn.system(cmd) local output = vim.fn.system(cmd)
@@ -102,7 +106,6 @@ M.languages = {
vim.list_extend({ "Error during compilation:" }, vim.split(output, "\n", { trimempty = true })) vim.list_extend({ "Error during compilation:" }, vim.split(output, "\n", { trimempty = true }))
) )
vim.api.nvim_set_option_value("modifiable", false, { buf = term_buf }) vim.api.nvim_set_option_value("modifiable", false, { buf = term_buf })
end end
if success then if success then
local run_cmd = "cd '" .. build_dir .. "' && ./" .. utils.get_project_name() local run_cmd = "cd '" .. build_dir .. "' && ./" .. utils.get_project_name()
+30 -18
View File
@@ -99,19 +99,25 @@ int main() {
} }
]]) ]])
utils.write_file({ full_project_root, "CMakeLists.txt" }, string.format([[ utils.write_file({ full_project_root, "CMakeLists.txt" }, string.format([[
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.16)
project(%s) project(%s)
include_directories(include)
set(SOURCES src/main.c)
add_executable(%s ${SOURCES})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_C_STANDARD 23) set(CMAKE_C_STANDARD 23)
set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD_REQUIRED ON)
include_directories(include)
# find_package(SDL3 CONFIG REQUIRED) # An example of how to import libraries from vcpkg set(SOURCES
# target_link_libraries(Game PRIVATE SDL3::SDL3) src/main.c
]], project_name, project_name)) )
local gitignore = { "build/" }
add_executable(%s ${SOURCES})
# find_package(Curses REQUIRED)
# include_directories(${CURSES_INCLUDE_DIR})
# target_link_libraries(%s ${CURSES_LIBRARIES})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
]], project_name, project_name, project_name))
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")
@@ -132,20 +138,26 @@ int main() {
} }
]]) ]])
utils.write_file({ full_project_root, "CMakeLists.txt" }, string.format([[ utils.write_file({ full_project_root, "CMakeLists.txt" }, string.format([[
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.16)
project(%s) project(%s)
include_directories(include)
set(SOURCES src/main.cpp)
add_executable(%s ${SOURCES})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_C_STANDARD 23) set(CMAKE_C_STANDARD 23)
set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD_REQUIRED ON)
include_directories(include)
# find_package(SDL3 CONFIG REQUIRED) # An example of how to import libraries from vcpkg set(SOURCES
# target_link_libraries(Game PRIVATE SDL3::SDL3) src/main.cpp
]], project_name, project_name)) )
local gitignore = { "build/" } add_executable(%s ${SOURCES})
# find_package(Curses REQUIRED)
# include_directories(${CURSES_INCLUDE_DIR})
# target_link_libraries(%s ${CURSES_LIBRARIES})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
]], project_name, project_name, project_name))
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")
+4
View File
@@ -5,6 +5,10 @@ function M.setup(opts)
M.opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("terminal"), opts or {}) M.opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("terminal"), opts or {})
end end
function M.exists(path)
return (io.open(path,"r") ~= nil)
end
---@return string ---@return string
function M.get_project_root() function M.get_project_root()
local plugin_dir = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":h:h:h") local plugin_dir = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":h:h:h")