Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70ff086e0c | ||
|
|
b348710bd5 | ||
|
|
dc0cf79188 | ||
|
|
0ac0267888 |
@@ -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/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/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>
|
||||
|
||||
|
||||
+1
-2
@@ -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/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/badge/License-MIT-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/License-Apache-yellow.svg?style=for-the-badge" />
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
|
||||
@@ -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**
|
||||
|
||||
```lua
|
||||
|
||||
+1
-6
@@ -1,9 +1,3 @@
|
||||
### **Build**
|
||||
```lua
|
||||
-- Adds build attributes when compiling if you need extra arguments
|
||||
build_attributes = ""
|
||||
```
|
||||
|
||||
#### File Structure 📂
|
||||
This is the recommended file structure for your C projects using Polydev:
|
||||
|
||||
@@ -28,6 +22,7 @@ Projects/
|
||||
│ ├── main.c
|
||||
│ └── *.c
|
||||
├── build/
|
||||
│ └── <CMAKE_FILES>
|
||||
│ └── <main-executable>
|
||||
└── include/
|
||||
└── *.h
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
### Build
|
||||
```lua
|
||||
-- Adds build attributes when compiling if you need extra arguments
|
||||
build_attributes = ""
|
||||
```
|
||||
---
|
||||
|
||||
#### File Structure 📂
|
||||
This is the recommended file structure for your C projects using Polydev:
|
||||
|
||||
@@ -29,6 +22,7 @@ Projects/
|
||||
│ ├── main.cpp
|
||||
│ └── *.cpp
|
||||
├── build/
|
||||
│ └── <CMAKE_FILES>
|
||||
│ └── <main-executable>
|
||||
└── include/
|
||||
└── *.hpp
|
||||
|
||||
+3
-3
@@ -3,8 +3,8 @@
|
||||
|
||||
| Binding | Description |
|
||||
|------------------|-----------------|
|
||||
| **Enter** | `Open file / Enter directory` |
|
||||
| **Delete** | `Go to parent directory` |
|
||||
| **ENTER** | `Open file / Enter directory` |
|
||||
| **DELETE** | `Go to parent directory` |
|
||||
| **/** | `Filter (fuzzy search)` |
|
||||
| **a** | `Create new folder` |
|
||||
| **%** | `Create new file` |
|
||||
@@ -12,7 +12,7 @@
|
||||
| **d** | `Create new project` |
|
||||
| **R** | `Rename 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!
|
||||
|
||||
|
||||
@@ -41,14 +41,12 @@ local function default_languages(project_root)
|
||||
keybinds = {
|
||||
["<leader>pr"] = "CRun",
|
||||
},
|
||||
build_attributes = "",
|
||||
},
|
||||
cpp = {
|
||||
project_root = project_root .. "/CPP",
|
||||
keybinds = {
|
||||
["<leader>pr"] = "CppRun",
|
||||
},
|
||||
build_attributes = "",
|
||||
},
|
||||
html = {
|
||||
project_root = project_root .. "/Html",
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
@@ -63,11 +63,18 @@ local loaded_languages = {}
|
||||
function M.load_language_module(lang, opts)
|
||||
if loaded_languages[lang] then return true end
|
||||
|
||||
local ok, mod = pcall(require, "Polydev.languages." .. lang)
|
||||
if not ok or type(mod.setup) ~= "function" then return false end
|
||||
local ok, mod = pcall(require, "Polydev.languages")
|
||||
if not ok or type(mod.languages) ~= "table" then
|
||||
return false
|
||||
end
|
||||
|
||||
mod.setup(opts and opts[lang] or {})
|
||||
loaded_languages[lang] = mod
|
||||
local lang_mod = mod.languages[lang]
|
||||
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
|
||||
end
|
||||
|
||||
@@ -308,6 +315,7 @@ function M.manager(project_root)
|
||||
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 {})
|
||||
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()
|
||||
vim.schedule(function()
|
||||
vim.ui.input({ prompt = "Enter project name: " }, function(project_name)
|
||||
|
||||
Reference in New Issue
Block a user