Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gwarf
Last active November 19, 2022 08:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gwarf/42a0a13ff2bf32a0e79d347e43831cae to your computer and use it in GitHub Desktop.
Save gwarf/42a0a13ff2bf32a0e79d347e43831cae to your computer and use it in GitHub Desktop.
Neovim, ruby and python

Environments

The environement are configured from ~/.config/nvim

dotfiles - vim setup

See https://github.com/gwarf/dotfiles

Configure python2 and python3 for Neovim

In order to avoid having to install all tools in every virtual environment it's possible to create virtualenvs dedicated to neovim.

Find appropriate stable python version.

I'm using pyenv to manage python version, but I'm not using pyenv-virtualenv as I want to manage the location of my virutal environments, ie. not under $PYENV_ROOT but under ~/.virtualenvs and as with ZSH I'm using zsh-autoswitch-virtualenv that uses this location and I prefer this than using pyenv-virtualenvwrapper that has not been active since long.

# Python 2.7: deprecated
pyenv install --list
pyenv install 2.7.18
# Create virtualenv manually
virtualenv -p $PYENV_ROOT/versions/2.7.18/bin/python ~/.virtualenvs/neovim2
source ~/.virtualenvs/neovim2/bin/activate
pip install pynvim neovim
# Optionally install some linters
pip install flake8 rstcheck jedi pylint
pyenv which python

https://neovim.io/doc/user/provider.html

# Python 3
cd ~/.config/nvim
pyenv install --list
pyenv install 3.10.8
cd ~/.config/nvim
pyenv local 3.10.8
mkdir -p ~/.virtualenvs
python -m venv ~/.virtualenvs/neovim3
source ~/.virtualenvs/neovim3/bin/activate
pip install -r requirements.txt

# Optionally install some linters?
pip install flake8 rstcheck jedi pylint
# Check path for vim conf
pyenv which python
# ~/.config/nvim/init.vim
" Dedicated virtualenvs for neovim
let g:python_host_prog = $HOME . '/.virtualenvs/neovim2/bin/python'
let g:python3_host_prog = $HOME . '/.virtualenvs/neovim3/bin/python'
# Check conf in neovim
nvim
:checkhealth
:UpdateRemotePlugins

Ruby with neovim

cd ~/.config/nvim
# Update rvm
rvm get stable
# Check known versions
rvm list known
# Install a specific version
rvm install 3.1.2 
# Create a gemst for neovim for this specific ruby version
rvm ruby-3.1.2 do rvm gemset create neovim
# Install neovim in the gemset
rvm ruby-3.1.2@neovim do gem install neovim
# Store information about the ruby-version and gemset to use
echo '3.1.2' > .ruby-version
echo 'neovim' > .ruby-gemset

Additional linters that can be used with ALE

ALE is a handy vim plugin for doing asychronous syntax checks. It will rely on various linters

brew install yamllint
brew install ansible-lint
brew install write-good
brew install proselint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment