-
Notifications
You must be signed in to change notification settings - Fork 0
Automatically source venvs #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -516,6 +516,34 @@ require("lazy").setup({ | |||||||||||||||||||
| { "fladson/vim-kitty" }, | ||||||||||||||||||||
| }) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ------------------------------------------------------------------------------- | ||||||||||||||||||||
| -- Python Virtualenv Auto-activation | ||||||||||||||||||||
| ------------------------------------------------------------------------------- | ||||||||||||||||||||
| local function activate_virtualenv() | ||||||||||||||||||||
| if vim.env.VIRTUAL_ENV then | ||||||||||||||||||||
| return | ||||||||||||||||||||
| end | ||||||||||||||||||||
|
|
||||||||||||||||||||
| local venv_paths = { "venv", ".venv" } | ||||||||||||||||||||
| local cwd = vim.fn.getcwd() | ||||||||||||||||||||
|
|
||||||||||||||||||||
| for _, venv_name in ipairs(venv_paths) do | ||||||||||||||||||||
| local venv_path = cwd .. "/" .. venv_name | ||||||||||||||||||||
| local python_path = venv_path .. "/bin/python" | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if vim.fn.isdirectory(venv_path) == 1 and vim.fn.executable(python_path) == 1 then | ||||||||||||||||||||
| vim.env.VIRTUAL_ENV = venv_path | ||||||||||||||||||||
| vim.env.PATH = venv_path .. "/bin:" .. vim.env.PATH | ||||||||||||||||||||
|
||||||||||||||||||||
| return | ||||||||||||||||||||
| end | ||||||||||||||||||||
| end | ||||||||||||||||||||
| end | ||||||||||||||||||||
|
|
||||||||||||||||||||
| vim.api.nvim_create_autocmd("VimEnter", { | ||||||||||||||||||||
|
||||||||||||||||||||
| vim.api.nvim_create_autocmd("VimEnter", { | |
| vim.api.nvim_create_autocmd({ "VimEnter", "DirChanged" }, { |
Copilot
AI
Feb 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The autocmd is not assigned to an augroup, which is inconsistent with other autocmds in this file (e.g., line 661 uses vim.api.nvim_create_augroup). Consider creating an augroup with clear = true to ensure the autocmd doesn't get duplicated if the config is reloaded.
| vim.api.nvim_create_autocmd("VimEnter", { | |
| local venv_augroup = vim.api.nvim_create_augroup("PythonVirtualenvAutoActivation", { clear = true }) | |
| vim.api.nvim_create_autocmd("VimEnter", { | |
| group = venv_augroup, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code uses Unix-specific path separators ("/bin/python"). While this may be intentional if the configuration is only used on Unix-like systems, consider using vim.fn.has('win32') to check the platform and use appropriate path separators, or use path manipulation functions that handle this automatically. This would make the configuration more portable.