From 2eede5b5103d961066ca0012f9c8efef31394211 Mon Sep 17 00:00:00 2001 From: DarthMooMancer <107283522+DarthMooMancer@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:20:58 -0400 Subject: [PATCH] Update python.lua --- lua/Polydev/python.lua | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/lua/Polydev/python.lua b/lua/Polydev/python.lua index 1b8e3b8..1e935f3 100644 --- a/lua/Polydev/python.lua +++ b/lua/Polydev/python.lua @@ -10,7 +10,6 @@ M.config = { [""] = "CloseTerminal", ["pr"] = "PythonRun", ["nf"] = "NewPythonFile", - ["nh"] = "NewPythonModuleFile", }, terminal = { right_padding = 0, @@ -30,16 +29,13 @@ function M.setup(opts) if command == "CloseTerminal" then M.close_key = key end if command == "PythonRun" then M.c_run = key end if command == "NewPythonFile" then M.new_python_file = key end - if command == "NewPythonModuleFile" then M.new_python_module_file = key end end - vim.api.nvim_create_user_command("NewPythonModuleFile", M.create_new_module_file, {}) vim.api.nvim_create_user_command("NewPythonFile", M.create_new_file, {}) vim.api.nvim_create_user_command("PythonRun", M.run, {}) vim.keymap.set("n", M.c_run, ":PythonRun", { silent = true }) vim.keymap.set("n", M.new_python_file, ":NewPythonFile", { silent = true }) - vim.keymap.set("n", M.new_python_module_file, ":NewPythonModuleFile", { silent = true }) end function M.open_float_terminal(cmd) @@ -85,6 +81,17 @@ local function write_file(path, content) print(path .. " created successfully!") end +function M.get_project_root() + local dir = vim.fn.expand("%:p:h") + while dir ~= "/" do + if vim.fn.isdirectory(dir .. "/venv") == 1 or vim.fn.filereadable(dir .. "/main.py") == 1 then + return dir + end + dir = vim.fn.fnamemodify(dir, ":h") + end + return nil +end + function M.create_project() vim.ui.input({ prompt = "Enter project name: " }, function(project_name) if not project_name or project_name == "" then @@ -144,16 +151,6 @@ function M.create_new_file() end) end -function M.get_project_root() - local dir = vim.fn.expand("%:p:h") - while dir ~= "/" do - if vim.fn.isdirectory(dir .. "/venv") == 1 or vim.fn.filereadable(dir .. "/main.py") == 1 then - return dir - end - dir = vim.fn.fnamemodify(dir, ":h") - end - return nil -end function M.run() local root = M.get_project_root()