All Projects → rafi → vim-venom

rafi / vim-venom

Licence: other
Select Python runtimes or activate virtual-environments while working in Neo/Vim.

Programming Languages

Vim Script
2826 projects
lua
6591 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to vim-venom

objc-runtime-CN
Objective-C Runtime Analysis (Objective-C运行时分析)
Stars: ✭ 28 (-15.15%)
Mutual labels:  runtime
AROS
www.axrt.org
Stars: ✭ 33 (+0%)
Mutual labels:  runtime
vercel-bref
▲ Vercel bref runtime • brefphp • vercel-bref
Stars: ✭ 25 (-24.24%)
Mutual labels:  runtime
webpack-extract-translation-keys
This plugin extracts translation keys for applications requiring runtime translations
Stars: ✭ 35 (+6.06%)
Mutual labels:  runtime
golden
a benchmark for compile-time and/or runtime Nim 🏆
Stars: ✭ 28 (-15.15%)
Mutual labels:  runtime
tesseract-ocr-re
Tesseract 4 OCR Runtime Environment - Docker Container
Stars: ✭ 94 (+184.85%)
Mutual labels:  runtime
Node
Node.js JavaScript runtime ✨🐢🚀✨
Stars: ✭ 83,731 (+253630.3%)
Mutual labels:  runtime
runtime-snaps
Core repository for Solus runtime snaps
Stars: ✭ 32 (-3.03%)
Mutual labels:  runtime
badass-runtime-plugin
Create a custom runtime image of your non-modular application
Stars: ✭ 143 (+333.33%)
Mutual labels:  runtime
DotNetJS
Consume C# in JavaScript with comfort: single-file UMD library, auto-generated 2-way bindings and type definitions
Stars: ✭ 551 (+1569.7%)
Mutual labels:  runtime
vite-node
Vite as Node.js runtime
Stars: ✭ 422 (+1178.79%)
Mutual labels:  runtime
oasis-sdk
Official SDK for the Oasis Network.
Stars: ✭ 57 (+72.73%)
Mutual labels:  runtime
subwasm
Subwasm is a cli utility to help you know more about WASM Runtimes. It help downloading, inspecting and comparing Substrate based chains such as Polkadot or Kusama.
Stars: ✭ 53 (+60.61%)
Mutual labels:  runtime
orion
Elegant tweak development in pure Swift
Stars: ✭ 149 (+351.52%)
Mutual labels:  runtime
cache
Simple and easy go cache micro framework
Stars: ✭ 12 (-63.64%)
Mutual labels:  runtime
node-wasm-run
Run arbitrary WASM/WASI files
Stars: ✭ 65 (+96.97%)
Mutual labels:  runtime
renv
Creating virtual environments for R.
Stars: ✭ 18 (-45.45%)
Mutual labels:  virtual-environment
runtime-config-loader
This is an Angular library that provides an easy way to load a configuration JSON file for runtime configuration.
Stars: ✭ 32 (-3.03%)
Mutual labels:  runtime
py lsp.nvim
Lsp Plugin for working with Python virtual environments
Stars: ✭ 58 (+75.76%)
Mutual labels:  virtualenv
CFE-Blank-Project
A blank Django Starter Project that includes Docker support.
Stars: ✭ 17 (-48.48%)
Mutual labels:  virtualenv

Vim Venom

Activates your Python virtual-environments while working in Neo/Vim.

Features

  • Select python runtime for current project
  • Detect pyenv and virtualenvwrapper placeholders (.venv and .python-version)
  • Detect virtualenv via popular tools: pipenv, poetry, etc.
  • User Vim events on de/activation
  • Optional Lua light-weight version

Lua Version

If you choose to use the Lua version, disable vim-plugin before loading the plugin, and once loaded, run setup:

vim.g.venom_loaded = 1     -- Before plugin loaded
require('venom').setup()   -- After plugin loaded

However, the current implement does not support tools (poetry, pipenv) and Vim commands and events.

The Lua API:

  • require('venom').activate()
  • require('venom').deactivate()
  • require('venom').statusline()

packer.nvim install example:

vim.g.venom_loaded = 1

use {
  'rafi/vim-venom',
  ft = {'python'},
  config = 'require("venom").setup()'
}

dein.vim install example:

call dein#add('rafi/vim-venom', {
  \ 'on_ft': 'python',
  \ 'hook_add': 'let g:venom_loaded = 1',
  \ 'hook_post_source': 'lua require("venom").setup()'
  \ })

You can change the default configuration:

require('venom').setup({
  auto_activate = true,
  echo = true,
  quiet = false,
  symbol = '🐍',
  root_patterns = {'.venv', '.python-version'},
  use_tools = true,
  tools = {},
})

Vim Version

If you choose to use the vim plugin, ensure your neo/vim instance supports python3, i.e. :echo has('python3') should print 1. Use your favorite plugin-manager, for example dein.vim:

call dein#add('rafi/vim-venom', { 'on_ft': 'python' })

Or, if you're using vim-plug, I got your back too:

Plug 'rafi/vim-venom', { 'for': 'python' }

You can change the default configuration:

Variable Description Default
g:venom_auto_activate Automatically tries to detect and activate virtualenv 1
g:venom_use_tools Use external-tools to detect virtualenv 1
g:venom_echo Upon activation show friendly message 1
g:venom_quiet Be quiet when failing to find environments 0
g:venom_symbol Icon for statusline helper function 🐍
g:venom_tools External-tools configuration See here

Functions & Commands

  • :VenomActivate [path] / venom#activate([path])
    • Without argument: Try to detect virtual-environment
    • With argument: Find python runtime in path and place a marker to persist selection.
  • :VenomDeactivate / venom#deactivate()
  • venom#statusline()

Python Runtime Selection

User can activate a different Python runtime, and use auto-completion when selecting one, using :VenomActivate and Tab.

⚠️ Only tested with Neovim.

Virtual-Environment Detection

Once activation runs manually (without arguments) or automatically when g:venom_auto_activate is enabled, plugin will attempt to detect the project's virtual-environment path using several strategies:

  1. Detect .venv/ directory in project's directory.
  2. Detect .venv file containing environment path in plain-text.
  3. Detect with external-tools (if g:venom_use_tools is enabled).

See the following g:venom_tools for external tools usage & support.

External Tools Integration

Enabling g:venom_use_tools leverages external tools in-order to resolve the project's virtual-environment path, plugin currently supports:

You can extend and change the usage. These are the default values:

let g:venom_use_tools = 1
let g:venom_tools = {
  \ 'poetry': 'poetry env info -p',
  \ 'pipenv': 'pipenv --venv'
  \ }

User Events

As a user, you have two events you can hook triggers to extend behavior:

  • VenomActivated
  • VenomDeactivated

For example, if you use deoplete and deoplete-jedi together:

" Deoplete Jedi: Set python executable from PATH
autocmd User VenomActivated,VenomDeactivated
  \ let g:deoplete#sources#jedi#python_path =
  \   exepath('python' . (has('win32') ? '.exe' : ''))

Or use jedi-vim's new :JediUseEnvironment feature (pending #836):

" Jedi: Set environment from PATH
autocmd User VenomActivated,VenomDeactivated
  \ silent! execute 'JediUseEnvironment ' .
  \   exepath('python' . (has('win32') ? '.exe' : ''))

Caveats

  • By default, FileType python event triggers plugin activation. You can add other events yourself, e.g.: autocmd BufWinEnter *.py call venom#activate()
  • Plugin doesn't alter Neovim's g:python3_host_prog. I don't think it should.
  • Mostly tested with Neovim

Copyright

© 2019-2022 Rafael Bodill

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].