PYTHON: added venv creation

This commit is contained in:
2026-10-20 17:42:25 -04:00
parent 0f542d56ef
commit 57e8eb0248
4 changed files with 53 additions and 160 deletions
+7 -11
View File
@@ -15,27 +15,25 @@ NOTE: The plugin may not work well with lazy or any other package manager other
## Features ## Features
* Create and manage projects directly from Neovim * Create projects directly from Neovim
* Generate new files quickly * Generate new files quickly
* Build your code with customizable build systems * Build your code with customizable build systems
* Run programs without leaving the editor * Run programs without leaving the editor
* Integrated terminal for flexible command execution * Integrated terminal for flexible command execution
* Lightweight, fast project manager UI
* Minimal configuration with extensibility in mind * Minimal configuration with extensibility in mind
* Built-in diagnostics with `:checkhealth Vern.nvim`
> 📚 [View the full documentation](https://git.moomancer.xyz/DarthMooMancer/polydev/wiki/Home$0) for setup, configuration, and usage details. > 📚 [View the full documentation](https://git.moomancer.xyz/DarthMooMancer/vern.nvim/wiki/Home$0) for setup, configuration, and usage details.
## Supported Languages ## Supported Languages
Vern.nvim currently supports the following languages: Vern.nvim currently supports the following languages:
* Java
* Python * Python
* C / C++ <!-- * Java -->
* Lua <!-- * C / C++ -->
* Rust <!-- * Lua -->
* HTML <!-- * Rust -->
<!-- * HTML -->
Additional language support is planned for future releases. Additional language support is planned for future releases.
@@ -44,8 +42,6 @@ Additional language support is planned for future releases.
Current focus: Current focus:
* **Refactoring and internal cleanup.** * **Refactoring and internal cleanup.**
* **Remaking it not in nui to make tabs, mainly for recent projects as the main page**
## Contributing ## Contributing
+5 -7
View File
@@ -2,11 +2,9 @@ local M = {}
M.create_project = function(opts) M.create_project = function(opts)
opts = opts or {} opts = opts or {}
vim.ui.input({ vim.ui.input(
prompt = "Project language (e.g. python): ", { prompt = "Project language (e.g. python): ", completion = "filetype" },
default = "", function(ft)
completion = "filetype",
}, function(ft)
ft = ft and vim.trim(ft) ft = ft and vim.trim(ft)
if not ft or vim.trim(ft) == "" then if not ft or vim.trim(ft) == "" then
return return
@@ -21,14 +19,14 @@ M.create_project = function(opts)
title = "Vern Project", title = "Vern Project",
}) })
end end
end) end
)
end end
M.create_file = function(opts) M.create_file = function(opts)
opts = opts or {} opts = opts or {}
vim.ui.input({ vim.ui.input({
prompt = "File language (e.g. python): ", prompt = "File language (e.g. python): ",
default = "",
completion = "filetype", completion = "filetype",
}, function(ft) }, function(ft)
ft = ft and vim.trim(ft) ft = ft and vim.trim(ft)
+3
View File
@@ -33,6 +33,9 @@ function M.create_project(opts)
dump("spec", "pyproject.toml", "pyproject") dump("spec", "pyproject.toml", "pyproject")
utils.init_git(root, "python") utils.init_git(root, "python")
local venv_path = root .. "/venv"
vim.fn.system("python3 -m venv " .. venv_path)
vim.cmd.edit(vim.fn.fnameescape(bin)) vim.cmd.edit(vim.fn.fnameescape(bin))
end) end)
end end
+25 -129
View File
@@ -30,22 +30,13 @@ end
M.languages = { M.languages = {
javascript = { javascript = {
setup = function(self, user_opts) setup = function(self, user_opts)
local opts = vim.tbl_deep_extend( local opts =
"force", vim.tbl_deep_extend("force", {}, configs.get("javascript"), user_opts or {})
{},
configs.get("javascript"),
user_opts or {}
)
vim.api.nvim_create_user_command("JavascriptRun", function() vim.api.nvim_create_user_command("JavascriptRun", function()
self:run() self:run()
end, {}) end, {})
for key, _ in pairs(opts.keybinds) do for key, _ in pairs(opts.keybinds) do
vim.keymap.set( vim.keymap.set("n", key, ":JavascriptRun<CR>", { silent = true })
"n",
key,
":JavascriptRun<CR>",
{ silent = true }
)
end end
end, end,
run = function() run = function()
@@ -56,11 +47,7 @@ M.languages = {
if not vim.v.shell_error == 0 then if not vim.v.shell_error == 0 then
local term_buf = utils.terminal({ cmd }) local term_buf = utils.terminal({ cmd })
vim.api.nvim_set_option_value( vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf })
"modifiable",
true,
{ buf = term_buf }
)
vim.api.nvim_buf_set_lines( vim.api.nvim_buf_set_lines(
term_buf, term_buf,
0, 0,
@@ -71,11 +58,7 @@ M.languages = {
vim.split(output, "\n", { trimempty = true }) vim.split(output, "\n", { trimempty = true })
) )
) )
vim.api.nvim_set_option_value( vim.api.nvim_set_option_value("modifiable", false, { buf = term_buf })
"modifiable",
false,
{ buf = term_buf }
)
else else
utils.terminal({ "node " .. root .. "/main.js" }) utils.terminal({ "node " .. root .. "/main.js" })
end end
@@ -83,12 +66,7 @@ M.languages = {
}, },
java = { java = {
setup = function(self, user_opts) setup = function(self, user_opts)
local opts = vim.tbl_deep_extend( local opts = vim.tbl_deep_extend("force", {}, configs.get("java"), user_opts or {})
"force",
{},
configs.get("java"),
user_opts or {}
)
vim.api.nvim_create_user_command("JavaRun", function() vim.api.nvim_create_user_command("JavaRun", function()
self:run() self:run()
end, {}) end, {})
@@ -99,20 +77,12 @@ M.languages = {
run = function() run = function()
local root = utils.get_project_root() local root = utils.get_project_root()
local cmd = string.format( local cmd = string.format("javac -d %s %s", root .. "/build", root .. "/src/*.java")
"javac -d %s %s",
root .. "/build",
root .. "/src/*.java"
)
local output = vim.fn.system(cmd) local output = vim.fn.system(cmd)
if not vim.v.shell_error == 0 then if not vim.v.shell_error == 0 then
local term_buf = utils.terminal({ cmd }) local term_buf = utils.terminal({ cmd })
vim.api.nvim_set_option_value( vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf })
"modifiable",
true,
{ buf = term_buf }
)
vim.api.nvim_buf_set_lines( vim.api.nvim_buf_set_lines(
term_buf, term_buf,
0, 0,
@@ -123,11 +93,7 @@ M.languages = {
vim.split(output, "\n", { trimempty = true }) vim.split(output, "\n", { trimempty = true })
) )
) )
vim.api.nvim_set_option_value( vim.api.nvim_set_option_value("modifiable", false, { buf = term_buf })
"modifiable",
false,
{ buf = term_buf }
)
else else
utils.terminal({ "java -cp " .. root, "build" .. " Main" }) utils.terminal({ "java -cp " .. root, "build" .. " Main" })
end end
@@ -135,12 +101,7 @@ M.languages = {
}, },
c = { c = {
setup = function(self, user_opts) setup = function(self, user_opts)
local opts = vim.tbl_deep_extend( local opts = vim.tbl_deep_extend("force", {}, configs.get("c"), user_opts or {})
"force",
{},
configs.get("c"),
user_opts or {}
)
vim.api.nvim_create_user_command("CRun", function() vim.api.nvim_create_user_command("CRun", function()
self:run() self:run()
end, {}) end, {})
@@ -158,11 +119,7 @@ M.languages = {
if not success then if not success then
local term_buf = utils.terminal({ cmd }) local term_buf = utils.terminal({ cmd })
vim.api.nvim_set_option_value( vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf })
"modifiable",
true,
{ buf = term_buf }
)
vim.api.nvim_buf_set_lines( vim.api.nvim_buf_set_lines(
term_buf, term_buf,
0, 0,
@@ -173,29 +130,17 @@ M.languages = {
vim.split(output, "\n", { trimempty = true }) vim.split(output, "\n", { trimempty = true })
) )
) )
vim.api.nvim_set_option_value( vim.api.nvim_set_option_value("modifiable", false, { buf = term_buf })
"modifiable",
false,
{ buf = term_buf }
)
end end
if success then if success then
local run_cmd = "cd '" local run_cmd = "cd '" .. build_dir .. "' && ./" .. utils.get_project_name()
.. build_dir
.. "' && ./"
.. utils.get_project_name()
utils.terminal({ run_cmd }) utils.terminal({ run_cmd })
end end
end, end,
}, },
cpp = { cpp = {
setup = function(self, user_opts) setup = function(self, user_opts)
local opts = vim.tbl_deep_extend( local opts = vim.tbl_deep_extend("force", {}, configs.get("cpp"), user_opts or {})
"force",
{},
configs.get("cpp"),
user_opts or {}
)
vim.api.nvim_create_user_command("CppRun", function() vim.api.nvim_create_user_command("CppRun", function()
self:run() self:run()
end, {}) end, {})
@@ -214,11 +159,7 @@ M.languages = {
if not success then if not success then
local term_buf = utils.terminal({ cmd }) local term_buf = utils.terminal({ cmd })
vim.api.nvim_set_option_value( vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf })
"modifiable",
true,
{ buf = term_buf }
)
vim.api.nvim_buf_set_lines( vim.api.nvim_buf_set_lines(
term_buf, term_buf,
0, 0,
@@ -229,39 +170,22 @@ M.languages = {
vim.split(output, "\n", { trimempty = true }) vim.split(output, "\n", { trimempty = true })
) )
) )
vim.api.nvim_set_option_value( vim.api.nvim_set_option_value("modifiable", false, { buf = term_buf })
"modifiable",
false,
{ buf = term_buf }
)
end end
if success then if success then
local run_cmd = "cd '" local run_cmd = "cd '" .. build_dir .. "' && ./" .. utils.get_project_name()
.. build_dir
.. "' && ./"
.. utils.get_project_name()
utils.terminal({ run_cmd }) utils.terminal({ run_cmd })
end end
end, end,
}, },
html = { html = {
setup = function(user_opts) setup = function(user_opts)
vim.tbl_deep_extend( vim.tbl_deep_extend("force", {}, configs.get("html"), user_opts or {})
"force",
{},
configs.get("html"),
user_opts or {}
)
end, end,
}, },
rust = { rust = {
setup = function(self, user_opts) setup = function(self, user_opts)
local opts = vim.tbl_deep_extend( local opts = vim.tbl_deep_extend("force", {}, configs.get("rust"), user_opts or {})
"force",
{},
configs.get("rust"),
user_opts or {}
)
vim.api.nvim_create_user_command("RustRun", function() vim.api.nvim_create_user_command("RustRun", function()
self:run() self:run()
end, {}) end, {})
@@ -280,11 +204,7 @@ M.languages = {
if not vim.v.shell_error == 0 then if not vim.v.shell_error == 0 then
local term_buf = utils.terminal(cmd) local term_buf = utils.terminal(cmd)
vim.api.nvim_set_option_value( vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf })
"modifiable",
true,
{ buf = term_buf }
)
vim.api.nvim_buf_set_lines( vim.api.nvim_buf_set_lines(
term_buf, term_buf,
0, 0,
@@ -295,11 +215,7 @@ M.languages = {
vim.split(output, "\n", { trimempty = true }) vim.split(output, "\n", { trimempty = true })
) )
) )
vim.api.nvim_set_option_value( vim.api.nvim_set_option_value("modifiable", false, { buf = term_buf })
"modifiable",
false,
{ buf = term_buf }
)
else else
utils.terminal({ "cargo run" }) utils.terminal({ "cargo run" })
end end
@@ -307,12 +223,7 @@ M.languages = {
}, },
python = { python = {
setup = function(self, user_opts) setup = function(self, user_opts)
local opts = vim.tbl_deep_extend( local opts = vim.tbl_deep_extend("force", {}, configs.get("python"), user_opts or {})
"force",
{},
configs.get("python"),
user_opts or {}
)
vim.api.nvim_create_user_command("PythonPip", function() vim.api.nvim_create_user_command("PythonPip", function()
self:install_dependency() self:install_dependency()
end, {}) end, {})
@@ -321,20 +232,10 @@ M.languages = {
end, {}) end, {})
for key, command in pairs(opts.keybinds) do for key, command in pairs(opts.keybinds) do
if command == "PythonRun" then if command == "PythonRun" then
vim.keymap.set( vim.keymap.set("n", key, ":PythonRun<CR>", { silent = true })
"n",
key,
":PythonRun<CR>",
{ silent = true }
)
end end
if command == "PythonPip" then if command == "PythonPip" then
vim.keymap.set( vim.keymap.set("n", key, ":PythonPip<CR>", { silent = true })
"n",
key,
":PythonPip<CR>",
{ silent = true }
)
end end
end end
@@ -361,12 +262,7 @@ M.languages = {
}, },
lua = { lua = {
setup = function(self, user_opts) setup = function(self, user_opts)
local opts = vim.tbl_deep_extend( local opts = vim.tbl_deep_extend("force", {}, configs.get("lua"), user_opts or {})
"force",
{},
configs.get("lua"),
user_opts or {}
)
vim.api.nvim_create_user_command("LuaRun", function() vim.api.nvim_create_user_command("LuaRun", function()
self:run() self:run()
end, {}) end, {})