REFACTOR: Completely changed how project creation is done so I can make
other languages easier and hopefully faster
This commit is contained in:
@@ -221,45 +221,6 @@ M.languages = {
|
||||
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 {})
|
||||
|
||||
Reference in New Issue
Block a user