I'm currently in the process of setting up my configuration for my Neovim environment and I'm struggling with some Python related issues.
I'm on macOS with nvim 0.9.4
, installed over brew
(if that should be relevant). I created a virtualevn with pyenv
(the path to that env is /Users/name/.pyenv/versions/3.12.0/bin/
). I'm using vim-plug as a plugin manager. My configuration looks like this
syntax on
filetype plugin indent on
set number
set tabstop=4
set expandtab
set softtabstop=4
set shiftwidth=4
set autoindent
set smartindent
call plug#begin('~/.local/share/nvim/plugged')
Plug 'jiangmiao/auto-pairs'
" Telescope
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-tree/nvim-web-devicons'
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.4' }
" Theme
Plug 'daltonmenezes/aura-theme', { 'rtp': 'packages/neovim' }
" Language server
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'}
Plug 'pappasam/coc-jedi', { 'do': 'yarn install --frozen-lockfile && yarn build', 'branch': 'main' }
Plug 'neoclide/coc-tabnine', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-yaml', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-json', {'do': 'yarn install --frozen-lockfile'}
" Python
Plug 'numirias/semshi', { 'do': ':UpdateRemotePlugins' } " Syntax Highlighting
Plug 'averms/black-nvim', {'do': ':UpdateRemotePlugins'} " Black formatter
" Debugging
Plug 'puremourning/vimspector'
call plug#end()
" Theme
colorscheme aura-dark-soft-text
let g:python3_host_prog = '/Users/name/.pyenv/versions/3.12.0/bin/python3'
" Find files using Telescope command-line sugar.
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
" use Ctrl+Space to trigger completion and navigate to the next complete item
inoremap <silent><expr> <c-space> coc#refresh()
" Use <Tab> and <S-Tab> to navigate the completion list:
inoremap <expr> <Tab> coc#pum#visible() ? coc#pum#next(1) : "\<Tab>"
inoremap <expr> <S-Tab> coc#pum#visible() ? coc#pum#prev(1) : "\<S-Tab>"
" Vimspector
" mnemonic 'di' = 'debug inspect' (pick your own, if you prefer!)
" for normal mode - the word under the cursor
nmap <Leader>di <Plug>VimspectorBalloonEval
" for visual mode, the visually selected text
xmap <Leader>di <Plug>VimspectorBalloonEval
runtime coc-init.vim
After installing semshi
, I started seeing an error message when I open a Python file in nvim
, i.e.
Error detected while processing BufNewFile Autocommands for "*":
Error executing lua callback: ...brew/Cellar/neovim/0.9.4/share/nvim/runtime/filetype.lua:24: Error executing lua: ...brew/Cellar/neovim/0.9.4/share/n
vim/runtime/filetype.lua:25: BufNewFile Autocommands for "*"..FileType Autocommands for "*"..function <SNR>23_filetype_changed, line 4: Vim:E492: Not
an editor command: Semshi enable
stack traceback:
[C]: in function 'nvim_cmd'
...brew/Cellar/neovim/0.9.4/share/nvim/runtime/filetype.lua:25: in function <...brew/Cellar/neovim/0.9.4/share/nvim/runtime/filetype.lua:24>
[C]: in function 'nvim_buf_call'
...brew/Cellar/neovim/0.9.4/share/nvim/runtime/filetype.lua:24: in function <...brew/Cellar/neovim/0.9.4/share/nvim/runtime/filetype.lua:10>
stack traceback:
[C]: in function 'nvim_buf_call'
...brew/Cellar/neovim/0.9.4/share/nvim/runtime/filetype.lua:24: in function <...brew/Cellar/neovim/0.9.4/share/nvim/runtime/filetype.lua:10>
Running :checkhealth
reveals
coc: health#coc#check
- OK nvim version satisfied
- OK Environment check passed
- WARNING pyx command not work, some extensions may fail to work, checkout ":help pythonx"
- WARNING Install pynvim by command: `pip install pynvim --upgrade`
- OK Javascript bundle build/index.js found
- OK Service started
and :checkhealth provider
provider: health#provider#check
Python 3 provider (optional) ~
- pyenv: Path: /opt/homebrew/Cellar/pyenv/2.3.31/libexec/pyenv
- pyenv: $PYENV_ROOT is not set. Infer from `pyenv root`.
- pyenv: Root: /Users/name/.pyenv
- Using: g:python3_host_prog = "/Users/name/.pyenv/versions/3.12.0/bin/python3"
- Executable: /Users/name/.pyenv/versions/3.12.0/bin/python3
- Python version: 3.12.0
- pynvim version: 0.5.0dev0
- OK Latest pynvim is installed.
Python virtualenv ~
- OK no $VIRTUAL_ENV
and last but not least :echo has('python3')
returns 0
.
So I first assumed that I was missing the pynvim
package and that my Neovim had no built-in python... But
- the
pyenv
environment haspynvim
installed and up-to-date (I triple checked) - whenever I open a clean nvim session (i.e. empty, no files) and do
:echo has('python3')
I get1
.
If anybody sees something that would explain this, I would really appreciate the input. Thanks.
Update
After @VivianDeSmet's answer, I updated my pynvim
package in the virtual environment, but the issue still persists. :checkhealth
no gives
Python 3 provider (optional) ~
- pyenv: Path: /opt/homebrew/Cellar/pyenv/2.3.31/libexec/pyenv
- pyenv: $PYENV_ROOT is not set. Infer from `pyenv root`.
- pyenv: Root: /Users/name/.pyenv
- Using: g:python3_host_prog = "/Users/name/.pyenv/versions/default/bin/python3"
- Executable: /Users/name/.pyenv/versions/default/bin/python3
- Python version: 3.12.0
- pynvim version: 0.5.0dev0
- OK Latest pynvim is installed.
Python virtualenv ~
- $VIRTUAL_ENV is set to: /Users/iilak/.pyenv/versions/default
- Python version: 3.12.0
- OK $VIRTUAL_ENV provides :!python.
Eror message when opening a Python file stays the same and behaviour as well (i.e. opening non-python files and running :echo has('python3')
returns 1
, but for Python files 0
)