4 Commits
Author SHA1 Message Date
DarthMooMancer 70ff086e0c Merge branch 'main' of https://github.com/DarthMooMancer/Polydev 2025-05-16 00:35:48 -04:00
DarthMooMancer b348710bd5 fix(docs, configs): removed build_attribues from docs and configs; removed unnecessary requirements from installation and index 2025-05-16 00:35:39 -04:00
DarthMooMancer dc0cf79188 Update README.md 2025-05-16 00:27:14 -04:00
DarthMooMancer 0ac0267888 Major Update: v1.2.0
rework: languages are in one files called languages making it easier to manage all languages and removes headache
feat: added ui in a725faaac8
2025-05-15 14:38:07 -04:00
16 changed files with 193 additions and 226 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
<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" />
<img src="https://img.shields.io/badge/Neovim-0.10%2B-32c48d?style=for-the-badge&logo=neovim&logoColor=white" /> <img src="https://img.shields.io/badge/Neovim-0.10%2B-32c48d?style=for-the-badge&logo=neovim&logoColor=white" />
<img src="https://img.shields.io/github/stars/DarthMooMancer/Polydev?style=for-the-badge&logo=github" /> <img src="https://img.shields.io/github/stars/DarthMooMancer/Polydev?style=for-the-badge&logo=github" />
<img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge" /> <img src="https://img.shields.io/badge/License-Apache-yellow.svg?style=for-the-badge" />
<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>
+1 -2
View File
@@ -4,8 +4,7 @@
<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" />
<img src="https://img.shields.io/badge/Neovim-0.10%2B-32c48d?style=for-the-badge&logo=neovim&logoColor=white" /> <img src="https://img.shields.io/badge/Neovim-0.10%2B-32c48d?style=for-the-badge&logo=neovim&logoColor=white" />
<img src="https://img.shields.io/github/stars/DarthMooMancer/Polydev?style=for-the-badge&logo=github" /> <img src="https://img.shields.io/github/stars/DarthMooMancer/Polydev?style=for-the-badge&logo=github" />
<img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge" /> <img src="https://img.shields.io/badge/License-Apache-yellow.svg?style=for-the-badge" />
<img src="https://img.shields.io/badge/Docs-Available-blue?style=for-the-badge&logo=readthedocs&logoColor=white" />
</p> </p>
<p align="center"> <p align="center">
-8
View File
@@ -1,11 +1,3 @@
# **Installation**
Polydev can be installed using any plugin manager of your choice — or even manually. Below are some examples for popular managers to get you started.
> **Requirement**: Neovim v0.10+
---
## **Lazy.nvim** ## **Lazy.nvim**
```lua ```lua
+1 -6
View File
@@ -1,9 +1,3 @@
### **Build**
```lua
-- Adds build attributes when compiling if you need extra arguments
build_attributes = ""
```
#### File Structure 📂 #### File Structure 📂
This is the recommended file structure for your C projects using Polydev: This is the recommended file structure for your C projects using Polydev:
@@ -28,6 +22,7 @@ Projects/
│ ├── main.c │ ├── main.c
│ └── *.c │ └── *.c
├── build/ ├── build/
│ └── <CMAKE_FILES>
│ └── <main-executable> │ └── <main-executable>
└── include/ └── include/
└── *.h └── *.h
+1 -7
View File
@@ -1,10 +1,3 @@
### Build
```lua
-- Adds build attributes when compiling if you need extra arguments
build_attributes = ""
```
---
#### File Structure 📂 #### File Structure 📂
This is the recommended file structure for your C projects using Polydev: This is the recommended file structure for your C projects using Polydev:
@@ -29,6 +22,7 @@ Projects/
│ ├── main.cpp │ ├── main.cpp
│ └── *.cpp │ └── *.cpp
├── build/ ├── build/
│ └── <CMAKE_FILES>
│ └── <main-executable> │ └── <main-executable>
└── include/ └── include/
└── *.hpp └── *.hpp
+3 -3
View File
@@ -3,8 +3,8 @@
| Binding | Description | | Binding | Description |
|------------------|-----------------| |------------------|-----------------|
| **Enter** | `Open file / Enter directory` | | **ENTER** | `Open file / Enter directory` |
| **Delete** | `Go to parent directory` | | **DELETE** | `Go to parent directory` |
| **/** | `Filter (fuzzy search)` | | **/** | `Filter (fuzzy search)` |
| **a** | `Create new folder` | | **a** | `Create new folder` |
| **%** | `Create new file` | | **%** | `Create new file` |
@@ -12,7 +12,7 @@
| **d** | `Create new project` | | **d** | `Create new project` |
| **R** | `Rename file/folder` | | **R** | `Rename file/folder` |
| **D** | `Delete file/folder` | | **D** | `Delete file/folder` |
| **q** | `Quit popup` | | **ESC** | `Quit popup` |
> **WARNING**: Do not copy the defaults. Only change what you need for your workflow! > **WARNING**: Do not copy the defaults. Only change what you need for your workflow!
-2
View File
@@ -41,14 +41,12 @@ local function default_languages(project_root)
keybinds = { keybinds = {
["<leader>pr"] = "CRun", ["<leader>pr"] = "CRun",
}, },
build_attributes = "",
}, },
cpp = { cpp = {
project_root = project_root .. "/CPP", project_root = project_root .. "/CPP",
keybinds = { keybinds = {
["<leader>pr"] = "CppRun", ["<leader>pr"] = "CppRun",
}, },
build_attributes = "",
}, },
html = { html = {
project_root = project_root .. "/Html", project_root = project_root .. "/Html",
+174
View File
@@ -0,0 +1,174 @@
local utils = require("Polydev.utils")
local configs = require("Polydev.configs")
local M = {}
M.languages = {
java = {
setup = function (self, user_opts)
local opts = vim.tbl_deep_extend("force", {}, configs.get("java"), user_opts or {})
vim.api.nvim_create_user_command("JavaRun", function() self:run() end, {})
for key, _ in pairs(opts.keybinds) do
vim.keymap.set("n", key, ":JavaRun<CR>", { silent = true })
end
end,
run = function ()
local root = utils.get_project_root()
local cmd = string.format("javac -d %s %s", root .. "/build", root .. "/src/*.java")
local output = vim.fn.system(cmd)
if not vim.v.shell_error == 0 then
local term_buf = utils.terminal({ cmd })
vim.api.nvim_buf_set_option(term_buf, "modifiable", true)
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_buf_set_option(term_buf, "modifiable", false)
else
utils.terminal({ "java -cp " .. root, "build" .. " Main" })
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_buf_set_option(term_buf, "modifiable", true)
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_buf_set_option(term_buf, "modifiable", false)
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_buf_set_option(term_buf, "modifiable", true)
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_buf_set_option(term_buf, "modifiable", false)
end
if success then
local run_cmd = "cd '" .. build_dir .. "' && ./" .. utils.get_project_name()
utils.terminal({ run_cmd })
end
end
},
html = {
setup = function (user_opts)
vim.tbl_deep_extend("force", {}, configs.get("html"), user_opts or {})
end
},
rust = {
setup = function (self, user_opts)
local opts = vim.tbl_deep_extend("force", {}, configs.get("rust"), user_opts or {})
vim.api.nvim_create_user_command("RustRun", function () self:run() end, {})
for key, _ in pairs(opts.keybinds) do
vim.keymap.set("n", key, ":RustRun<CR>", { silent = true })
end
end,
run = function ()
local root = utils.get_project_root()
if not root then return print("Error: Project root not found.") end
local cmd = { "cargo build" }
local output = vim.fn.system(table.concat(cmd))
if not vim.v.shell_error == 0 then
local term_buf = utils.terminal(cmd)
vim.api.nvim_buf_set_option(term_buf, "modifiable", true)
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_buf_set_option(term_buf, "modifiable", false)
else
utils.terminal({ "cargo run" })
end
end
},
python = {
setup = function(self, user_opts)
local opts = vim.tbl_deep_extend("force", {}, configs.get("python"), user_opts or {})
vim.api.nvim_create_user_command("PythonPip", function () self:install_dependency() end, {})
vim.api.nvim_create_user_command("PythonRun", function () self:run() end, {})
for key, command in pairs(opts.keybinds) do
if command == "PythonRun" then
vim.keymap.set("n", key, ":PythonRun<CR>", { silent = true })
end
if command == "PythonPip" then
vim.keymap.set("n", key, ":PythonPip<CR>", { silent = true })
end
end
local root = utils.get_project_root()
if root then
local venv_path = root .. "/venv/bin/activate"
if vim.fn.filereadable(venv_path) == 1 then
vim.env.VIRTUAL_ENV = venv_path
vim.env.PATH = root .. "/venv/bin:" .. vim.env.PATH
end
end
end,
install_dependency = function ()
vim.ui.input({ prompt = "Enter pip module: " }, function(pip_module)
if not pip_module or pip_module == "" then return print("Pip canceled") end
utils.terminal({ "pip install " .. pip_module })
end)
end,
run = function ()
utils.terminal({ "python3 " .. utils.get_project_root(), "main.py" })
end
},
lua = {
setup = function (self, user_opts)
local opts = vim.tbl_deep_extend("force", {}, configs.get("lua"), user_opts or {})
vim.api.nvim_create_user_command("LuaRun", function () self:run() end, {})
for key, _ in pairs(opts.keybinds) do
vim.keymap.set("n", key, ":LuaRun<CR>", { silent = true })
end
end,
run = function ()
local init_lua_path = utils.get_project_root() .. "/lua/" .. utils.get_project_name() .. "/init.lua"
if vim.fn.filereadable(init_lua_path) == 1 then
utils.terminal({ "lua " .. init_lua_path })
end
end
},
}
return M
-34
View File
@@ -1,34 +0,0 @@
local utils = require("Polydev.utils")
local M = {}
function M.setup(user_opts)
local opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("c"), user_opts or {})
vim.api.nvim_create_user_command("CRun", M.run, {})
for key, _ in pairs(opts.keybinds) do
vim.keymap.set("n", key, ":CRun<CR>", { silent = true })
end
end
function M.run()
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_buf_set_option(term_buf, "modifiable", true)
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_buf_set_option(term_buf, "modifiable", false)
end
if success then
local run_cmd = "cd " .. build_dir .. " && ./" .. utils.get_project_name()
utils.terminal({ run_cmd })
end
end
return M
-34
View File
@@ -1,34 +0,0 @@
local utils = require("Polydev.utils")
local M = {}
function M.setup(user_opts)
local opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("cpp"), user_opts or {})
vim.api.nvim_create_user_command("CppRun", M.run, {})
for key, _ in pairs(opts.keybinds) do
vim.keymap.set("n", key, ":CppRun<CR>", { silent = true })
end
end
function M.run()
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_buf_set_option(term_buf, "modifiable", true)
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_buf_set_option(term_buf, "modifiable", false)
end
if success then
local run_cmd = "cd " .. build_dir .. " && ./" .. utils.get_project_name()
utils.terminal({ run_cmd })
end
end
return M
-7
View File
@@ -1,7 +0,0 @@
local M = {}
function M.setup(user_opts)
local opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("html"), user_opts or {})
end
return M
-30
View File
@@ -1,30 +0,0 @@
local utils = require("Polydev.utils")
local M = {}
function M.setup(user_opts)
local opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("java"), user_opts or {})
vim.api.nvim_create_user_command("JavaRun", M.run, {})
for key, _ in pairs(opts.keybinds) do
vim.keymap.set("n", key, ":JavaRun<CR>", { silent = true })
end
end
function M.run()
local root = utils.get_project_root()
local cmd = string.format("javac -d %s %s", root .. "/build", root .. "/src/*.java")
local output = vim.fn.system(cmd)
if not vim.v.shell_error == 0 then
local term_buf = utils.terminal({ cmd })
vim.api.nvim_buf_set_option(term_buf, "modifiable", true)
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_buf_set_option(term_buf, "modifiable", false)
else
utils.terminal({ "java -cp " .. root, "build" .. " Main" })
end
end
return M
-19
View File
@@ -1,19 +0,0 @@
local utils = require("Polydev.utils")
local M = {}
function M.setup(user_opts)
local opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("lua"), user_opts or {})
vim.api.nvim_create_user_command("LuaRun", M.run, {})
for key, _ in pairs(opts.keybinds) do
vim.keymap.set("n", key, ":LuaRun<CR>", { silent = true })
end
end
function M.run()
local init_lua_path = utils.get_project_root() .. "/lua/" .. utils.get_project_name() .. "/init.lua"
if vim.fn.filereadable(init_lua_path) == 1 then
utils.terminal({ "lua " .. init_lua_path })
end
end
return M
-38
View File
@@ -1,38 +0,0 @@
local utils = require("Polydev.utils")
local M = {}
function M.setup(user_opts)
local opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("python"), user_opts or {})
vim.api.nvim_create_user_command("PythonPip", M.install_dependency, {})
vim.api.nvim_create_user_command("PythonRun", M.run, {})
for key, command in pairs(opts.keybinds) do
if command == "PythonRun" then
vim.keymap.set("n", key, ":PythonRun<CR>", { silent = true })
end
if command == "PythonPip" then
vim.keymap.set("n", key, ":PythonPip<CR>", { silent = true })
end
end
local root = utils.get_project_root()
if root then
local venv_path = root .. "/venv/bin/activate"
if vim.fn.filereadable(venv_path) == 1 then
vim.env.VIRTUAL_ENV = venv_path
vim.env.PATH = root .. "/venv/bin:" .. vim.env.PATH
end
end
end
function M.install_dependency()
vim.ui.input({ prompt = "Enter pip module: " }, function(pip_module)
if not pip_module or pip_module == "" then return print("Pip canceled") end
utils.terminal({ "pip install " .. pip_module })
end)
end
function M.run()
utils.terminal({ "python3 " .. utils.get_project_root(), "main.py" })
end
return M
-31
View File
@@ -1,31 +0,0 @@
local utils = require("Polydev.utils")
local M = {}
function M.setup(user_opts)
local opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("rust"), user_opts or {})
vim.api.nvim_create_user_command("RustRun", M.run, {})
for key, _ in pairs(opts.keybinds) do
vim.keymap.set("n", key, ":RustRun<CR>", { silent = true })
end
end
function M.run()
local root = utils.get_project_root()
if not root then return print("Error: Project root not found.") end
local cmd = { "cargo build" }
local output = vim.fn.system(table.concat(cmd))
if not vim.v.shell_error == 0 then
local term_buf = utils.terminal(cmd)
vim.api.nvim_buf_set_option(term_buf, "modifiable", true)
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_buf_set_option(term_buf, "modifiable", false)
else
utils.terminal({ "cargo run" })
end
end
return M
+12 -4
View File
@@ -63,11 +63,18 @@ local loaded_languages = {}
function M.load_language_module(lang, opts) function M.load_language_module(lang, opts)
if loaded_languages[lang] then return true end if loaded_languages[lang] then return true end
local ok, mod = pcall(require, "Polydev.languages." .. lang) local ok, mod = pcall(require, "Polydev.languages")
if not ok or type(mod.setup) ~= "function" then return false end if not ok or type(mod.languages) ~= "table" then
return false
end
mod.setup(opts and opts[lang] or {}) local lang_mod = mod.languages[lang]
loaded_languages[lang] = mod 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 return true
end end
@@ -308,6 +315,7 @@ function M.manager(project_root)
if not lang or lang == "" then return print("Project creation canceled") end if not lang or lang == "" then return print("Project creation canceled") end
opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get(lang), opts or {}) opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get(lang), opts or {})
if M.load_language_module(lang) and templates.projects[lang] and templates.projects[lang].run then if M.load_language_module(lang) and templates.projects[lang] and templates.projects[lang].run then
-- if templates.projects[lang] and templates.projects[lang].run then
popup:unmount() popup:unmount()
vim.schedule(function() vim.schedule(function()
vim.ui.input({ prompt = "Enter project name: " }, function(project_name) vim.ui.input({ prompt = "Enter project name: " }, function(project_name)