local M = {} M.setup = function() -- Python-specific settings vim.opt.tabstop = 4 vim.opt.shiftwidth = 4 vim.opt.expandtab = true -- Quick run and lint commands vim.api.nvim_create_user_command("PythonRun", function() vim.cmd("!python3 %") end, {}) vim.api.nvim_create_user_command("PythonLint", function() vim.cmd("!flake8 %") end, {}) -- Optional: Virtual environment detection local function activate_venv() local venv_path = vim.fn.getcwd() .. "/venv/bin/activate" if vim.fn.filereadable(venv_path) == 1 then vim.env.VIRTUAL_ENV = venv_path vim.cmd("source " .. venv_path) end end -- Try to activate virtual environment when opening Python file vim.api.nvim_create_autocmd("FileType", { pattern = "python", callback = activate_venv }) end return M