I’m trying to use coc.nvim, and it works fine with the Rust LSP. However, I’m having trouble with the coc-python extension.
I’m using a global neovim from configuration.nix and nodejs, yarn, python with jedi and mypy all installed in a shell.nix which I activate via direnv.
I also put jedi as an extraPackage of neovim in configuration.nix, for good measure.
Result: I get linting errors allright, but the rest (jump to definition, …) doesn’t work.
Opening the coc log file, I see it is using a python interpreter that is not the one of the current shell, and I suppose also not the one from nvim, because it complains that jedi is not installed (but I can import jedi fine in the shell’s python.
I also tried to compile nvim with nodeJs support and removing it from shell.nix, but then nothing works anymore.
I’m a bit lost in who is using what, what the declared requirements of nvim are and what they affect, etc.
Not 100% sure, not a nix user, yet. But I think you need to set up neovim to pick up the right python paths. Check :h g:python_host_prog & :h g:python3_host_prog
I might be able to help and I am actually interested in how you installed coc.nvim as it’s not packaged yet. Could you share this aspect of your config please ?
I’m currently handling my vim configuration outside of nix, actually (with the intent of more easy replication via a dotfiles repo to machines not running nix; assuming that’s a good reason for that).
I packaged the most basic version of coc.nvim in unstable.
You can autoinstall extensions via let g:coc_global_extensions = ['coc-extension1', 'coc-extension2', 'coc-extension3', 'coc-extension4'] though it’s not nix-declarative.
I haven’t tried the coc-python extension much as it seems to be WIP, require .Net code etc.
Instead I’ve kept my pyls config
I’ve updated the coc.nvim wiki this week with a full example Language servers · neoclide/coc.nvim Wiki · GitHub .
Btw thanks for pushing me to install coc.nvim, it’s really awesome especially with neovim 0.4-dev and the floating windows).
Hey, just wanted to share a small caveat I noticed when configuring jedi for coc-python.
vim-ghost’s python is Neovim’s python executable - python3_host_prog. But, coc-python’s python executable is the first python which is found in $PATH. Therefor, you need to use direenv or a similar workaround to use coc-python.
I use the following as a base .envrc for my Python projects:
use nix -p python37Packages.{jedi,pylint}
To be further accurate, I feel I need to note that @wizzup’s example which adds jedi to the extraPythonPackages doesn’t help coc-python at all, according to my tests.
I use the following in my ~/.config/nixpkgs/config.nix:
Black should be fine, but jedi will probably not see the packages that you install only in the environment of the project, since it’s a different Python environment.
Haven’t tried, though.
And repetition can be factored out in a derivation that you call in all environments - but I still haven’t done it ^^
you’re right… I should think about my setups as any other code, that’s what nix is for after all. If I want to DRY, there are other ways to DRY than singletons/globals.
coc-pyls is deprecated, isn’t it ? so far I don’t think anyone can or is using the microsoft server declaratively.
I’ve kinda managed to package mpls/make it accessible: https://github.com/NixOS/nixpkgs/pull/70058
but I haven’t found a way to tell coc-python to use it.
I’ve had some code to build coc from source too but didn’t have the time to test it and the current coc installer is quite straightforward.