Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ubaldot/vim-conda-activate
Activate Conda environments in Vim.
https://github.com/ubaldot/vim-conda-activate
conda vim vim9
Last synced: 11 days ago
JSON representation
Activate Conda environments in Vim.
- Host: GitHub
- URL: https://github.com/ubaldot/vim-conda-activate
- Owner: ubaldot
- License: bsd-3-clause
- Created: 2023-05-24T11:47:38.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-26T09:32:25.000Z (3 months ago)
- Last Synced: 2024-07-26T10:54:41.598Z (3 months ago)
- Topics: conda, vim, vim9
- Language: Vim Script
- Homepage: https://www.vim.org/scripts/script.php?script_id=6074
- Size: 1.44 MB
- Stars: 18
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-vim9 - vim-conda-activate
README
# Conda-activate
Activate Conda virtual environments in Vim.
## Introduction
*Conda-activate* picks the inheritance of
[vim-conda](https://github.com/cjrh/vim-conda) by providing the same features
in a Vim9 fashion. It further accommodates changes that `conda` experienced
throughout the years.*Conda-activate* sets various environment variables such as
`$CONDA_DEFAULT_ENV`,
`$CONDA_PREFIX`, `$PATH`, etc., and set the
`pythonthreehome` and `pythonthreedll` options.The internal `sys.path` used by Vim is also set.
This plugin has been tested on **Conda 23.3.1** and it work-ish on such a release.
Work-ish means that there could be some use-cases where it performs poorly.## Requirements
You need *conda* and *Vim9*.You also need your `python` environment set properly.
Be sure that you get `1` in response to `:echo has('python3')` and
`Hello World` in response to `:python3 print('Hello World')`.> [!CAUTION]
> Vim shall be started from an activated virtual environment.
> Don't start Vim from the *base* environment or from a shell where `conda`
> has not been initialized!
> To be safe, you may consider to add the following
> in your *.basrc/.zshrc/whatever*:
>```
>conda activate myenv
>```
> or to create a `.bat` file with something like the following content:
>```
>@echo off
>call C:\Users\yourname\Miniconda3\condabin\activate.bat C:\Users\yourname\Miniconda3\envs\myenv
>gvim
>```
>
> if you are a Windows user.
> For such users, names like `Miniconda3`, `Anaconda`, etc. in the
> list of available virtual environments represent the `base` environment.
>
> Make sure that the version of Python installed in the virtual environment you use to start Vim
> matches the version of Python used to compile Vim.## Usage
This plugin has one command `CondaActivate` that takes one (optional) argument:
```
:CondaActivate # Show a popup menu
:CondaActivate myenv # Activate myenv without popup menu
```It further exposes an *autocommand-event* named `CondaEnvActivated` that
you can use to perform other actions just after you activated a virtual
environment.
Here is a simple example on how to use it:
```
autocmd! User CondaEnvActivated :echom $"{$CONDA_DEFAULT_ENV} activated."
```## Credits
Thanks to [vim-conda](https://github.com/cjrh/vim-conda) that paved the way.
I would have never done this plugin without reading (and learning)
from [vim-conda](https://github.com/cjrh/vim-conda) source code.## Contributing
Feel free to send a PR if have any improvement ideas.
For more info check `:h condaactivate.txt`.## License
BSD-3 Clause.