From 57e8eb0248c6aaa344ad1cfbebec0bee5b2d5ca9 Mon Sep 17 00:00:00 2001 From: Andrew Haynes Date: Tue, 20 Oct 2026 17:42:25 -0400 Subject: [PATCH] PYTHON: added venv creation --- README.md | 18 ++-- lua/vern/actions/init.lua | 38 ++++---- lua/vern/actions/python.lua | 3 + lua/vern/languages-deprecated.lua | 154 +++++------------------------- 4 files changed, 53 insertions(+), 160 deletions(-) diff --git a/README.md b/README.md index 6e31131..d1ccb47 100644 --- a/README.md +++ b/README.md @@ -15,27 +15,25 @@ NOTE: The plugin may not work well with lazy or any other package manager other ## Features -* Create and manage projects directly from Neovim +* Create projects directly from Neovim * Generate new files quickly * Build your code with customizable build systems * Run programs without leaving the editor * Integrated terminal for flexible command execution -* Lightweight, fast project manager UI * 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 Vern.nvim currently supports the following languages: -* Java * Python -* C / C++ -* Lua -* Rust -* HTML + + + + + Additional language support is planned for future releases. @@ -44,8 +42,6 @@ Additional language support is planned for future releases. Current focus: * **Refactoring and internal cleanup.** -* **Remaking it not in nui to make tabs, mainly for recent projects as the main page** - ## Contributing diff --git a/lua/vern/actions/init.lua b/lua/vern/actions/init.lua index bf1bded..0bc95be 100644 --- a/lua/vern/actions/init.lua +++ b/lua/vern/actions/init.lua @@ -2,33 +2,31 @@ local M = {} M.create_project = function(opts) opts = opts or {} - vim.ui.input({ - prompt = "Project language (e.g. python): ", - default = "", - completion = "filetype", - }, function(ft) - ft = ft and vim.trim(ft) - if not ft or vim.trim(ft) == "" then - return + vim.ui.input( + { prompt = "Project language (e.g. python): ", completion = "filetype" }, + function(ft) + ft = ft and vim.trim(ft) + if not ft or vim.trim(ft) == "" then + return + end + local ok, actions = pcall(require, "vern.actions." .. ft) + local configs = require("vern.configs." .. ft) + local args = vim.tbl_deep_extend("force", {}, configs, opts or {}) + if ok and actions and type(actions.create_project) == "function" then + actions.create_project(args) + else + vim.notify("Unknown Filetype: " .. ft, vim.log.levels.WARN, { + title = "Vern Project", + }) + end end - local ok, actions = pcall(require, "vern.actions." .. ft) - local configs = require("vern.configs." .. ft) - local args = vim.tbl_deep_extend("force", {}, configs, opts or {}) - if ok and actions and type(actions.create_project) == "function" then - actions.create_project(args) - else - vim.notify("Unknown Filetype: " .. ft, vim.log.levels.WARN, { - title = "Vern Project", - }) - end - end) + ) end M.create_file = function(opts) opts = opts or {} vim.ui.input({ prompt = "File language (e.g. python): ", - default = "", completion = "filetype", }, function(ft) ft = ft and vim.trim(ft) diff --git a/lua/vern/actions/python.lua b/lua/vern/actions/python.lua index 5b0822b..76087d8 100644 --- a/lua/vern/actions/python.lua +++ b/lua/vern/actions/python.lua @@ -33,6 +33,9 @@ function M.create_project(opts) dump("spec", "pyproject.toml", "pyproject") 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)) end) end diff --git a/lua/vern/languages-deprecated.lua b/lua/vern/languages-deprecated.lua index 6f6b24f..35de63f 100644 --- a/lua/vern/languages-deprecated.lua +++ b/lua/vern/languages-deprecated.lua @@ -30,22 +30,13 @@ end M.languages = { javascript = { setup = function(self, user_opts) - local opts = vim.tbl_deep_extend( - "force", - {}, - configs.get("javascript"), - user_opts or {} - ) + local opts = + vim.tbl_deep_extend("force", {}, configs.get("javascript"), user_opts or {}) vim.api.nvim_create_user_command("JavascriptRun", function() self:run() end, {}) for key, _ in pairs(opts.keybinds) do - vim.keymap.set( - "n", - key, - ":JavascriptRun", - { silent = true } - ) + vim.keymap.set("n", key, ":JavascriptRun", { silent = true }) end end, run = function() @@ -56,11 +47,7 @@ M.languages = { if not vim.v.shell_error == 0 then local term_buf = utils.terminal({ cmd }) - vim.api.nvim_set_option_value( - "modifiable", - true, - { buf = term_buf } - ) + vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf }) vim.api.nvim_buf_set_lines( term_buf, 0, @@ -71,11 +58,7 @@ M.languages = { 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 }) else utils.terminal({ "node " .. root .. "/main.js" }) end @@ -83,12 +66,7 @@ M.languages = { }, java = { setup = function(self, user_opts) - local opts = vim.tbl_deep_extend( - "force", - {}, - configs.get("java"), - user_opts or {} - ) + local opts = vim.tbl_deep_extend("force", {}, configs.get("java"), user_opts or {}) vim.api.nvim_create_user_command("JavaRun", function() self:run() end, {}) @@ -99,20 +77,12 @@ M.languages = { run = function() local root = utils.get_project_root() - local cmd = string.format( - "javac -d %s %s", - root .. "/build", - root .. "/src/*.java" - ) + 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_set_option_value( - "modifiable", - true, - { buf = term_buf } - ) + vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf }) vim.api.nvim_buf_set_lines( term_buf, 0, @@ -123,11 +93,7 @@ M.languages = { 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 }) else utils.terminal({ "java -cp " .. root, "build" .. " Main" }) end @@ -135,12 +101,7 @@ M.languages = { }, c = { setup = function(self, user_opts) - local opts = vim.tbl_deep_extend( - "force", - {}, - configs.get("c"), - user_opts or {} - ) + local opts = vim.tbl_deep_extend("force", {}, configs.get("c"), user_opts or {}) vim.api.nvim_create_user_command("CRun", function() self:run() end, {}) @@ -158,11 +119,7 @@ M.languages = { if not success then local term_buf = utils.terminal({ cmd }) - vim.api.nvim_set_option_value( - "modifiable", - true, - { buf = term_buf } - ) + vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf }) vim.api.nvim_buf_set_lines( term_buf, 0, @@ -173,29 +130,17 @@ M.languages = { 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 if success then - local run_cmd = "cd '" - .. build_dir - .. "' && ./" - .. utils.get_project_name() + 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 {} - ) + local opts = vim.tbl_deep_extend("force", {}, configs.get("cpp"), user_opts or {}) vim.api.nvim_create_user_command("CppRun", function() self:run() end, {}) @@ -214,11 +159,7 @@ M.languages = { if not success then local term_buf = utils.terminal({ cmd }) - vim.api.nvim_set_option_value( - "modifiable", - true, - { buf = term_buf } - ) + vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf }) vim.api.nvim_buf_set_lines( term_buf, 0, @@ -229,39 +170,22 @@ M.languages = { 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 if success then - local run_cmd = "cd '" - .. build_dir - .. "' && ./" - .. utils.get_project_name() + 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 {} - ) + 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 {} - ) + local opts = vim.tbl_deep_extend("force", {}, configs.get("rust"), user_opts or {}) vim.api.nvim_create_user_command("RustRun", function() self:run() end, {}) @@ -280,11 +204,7 @@ M.languages = { if not vim.v.shell_error == 0 then local term_buf = utils.terminal(cmd) - vim.api.nvim_set_option_value( - "modifiable", - true, - { buf = term_buf } - ) + vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf }) vim.api.nvim_buf_set_lines( term_buf, 0, @@ -295,11 +215,7 @@ M.languages = { 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 }) else utils.terminal({ "cargo run" }) end @@ -307,12 +223,7 @@ M.languages = { }, python = { setup = function(self, user_opts) - local opts = vim.tbl_deep_extend( - "force", - {}, - configs.get("python"), - user_opts or {} - ) + 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, {}) @@ -321,20 +232,10 @@ M.languages = { end, {}) for key, command in pairs(opts.keybinds) do if command == "PythonRun" then - vim.keymap.set( - "n", - key, - ":PythonRun", - { silent = true } - ) + vim.keymap.set("n", key, ":PythonRun", { silent = true }) end if command == "PythonPip" then - vim.keymap.set( - "n", - key, - ":PythonPip", - { silent = true } - ) + vim.keymap.set("n", key, ":PythonPip", { silent = true }) end end @@ -361,12 +262,7 @@ M.languages = { }, lua = { setup = function(self, user_opts) - local opts = vim.tbl_deep_extend( - "force", - {}, - configs.get("lua"), - user_opts or {} - ) + local opts = vim.tbl_deep_extend("force", {}, configs.get("lua"), user_opts or {}) vim.api.nvim_create_user_command("LuaRun", function() self:run() end, {})