rework: removed old get functions from each language to use utils
instead and changed run in each language to use new system to be simpler feat: added aux_files for c/c++ and reworked them to work with new update
This commit is contained in:
@@ -1,26 +1,16 @@
|
||||
---@module "Polydev.utils"
|
||||
local utils = require("Polydev.utils")
|
||||
|
||||
---@module "Polydev.configs"
|
||||
local config = require("Polydev.configs")
|
||||
|
||||
---@tyep table
|
||||
local M = {}
|
||||
|
||||
---@tyep table
|
||||
M.keybinds = {}
|
||||
M.opts = {}
|
||||
|
||||
---@type nil|table
|
||||
M.opts = nil
|
||||
|
||||
---@param opts table
|
||||
function M.setup(opts)
|
||||
M.opts = vim.tbl_deep_extend("force", {}, config.get("python"), opts or {})
|
||||
M.opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("python"), opts or {})
|
||||
for key, command in pairs(M.opts.keybinds) do
|
||||
M.keybinds[command] = key
|
||||
end
|
||||
|
||||
local root = M.get_project_root()
|
||||
local root = utils.get_project_root()
|
||||
if root then
|
||||
local venv_path = root .. "/venv/bin/activate"
|
||||
if vim.fn.filereadable(venv_path) == 1 then
|
||||
@@ -40,19 +30,6 @@ function M.setup(opts)
|
||||
end
|
||||
end
|
||||
|
||||
---@return string|nil
|
||||
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
|
||||
|
||||
---@return string|nil
|
||||
function M.install_dependency()
|
||||
vim.ui.input({ prompt = "Enter pip module: " }, function(pip_module)
|
||||
if not pip_module or pip_module == "" then
|
||||
@@ -64,15 +41,10 @@ function M.install_dependency()
|
||||
end
|
||||
|
||||
function M.run()
|
||||
local root = M.get_project_root()
|
||||
if not root then
|
||||
---@return nil
|
||||
return print("Error: Project root not found.")
|
||||
end
|
||||
local root = utils.get_project_root()
|
||||
|
||||
local main_file = root .. "/main.py"
|
||||
if vim.fn.filereadable(main_file) == 0 then
|
||||
---@return nil
|
||||
return print("Error: main.py not found in project root.")
|
||||
end
|
||||
|
||||
@@ -91,5 +63,4 @@ function M.run()
|
||||
utils.open_float_terminal(venv_cmd .. "python3 " .. main_file)
|
||||
end
|
||||
|
||||
---@return table
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user