black-nvim
black-nvim copied to clipboard
Black() gives function not found error
if I try to run Black(), I get an unknown function error.
I can access help using :h black.
If I do :checkhealth I see no errors in the python3 section:
38 ## Python 3 provider (optional)
39 - INFO: pyenv: Path: /Users/tbrown/.pyenv/libexec/pyenv
40 - INFO: pyenv: $PYENV_ROOT is not set. Infer from pyenv root
.
41 - INFO: pyenv: Root: /Users/tbrown/.pyenv
42 - INFO: Using: g:python3_host_prog = "/opt/homebrew/bin/python3"
43 - INFO: Executable: /opt/homebrew/bin/python3
44 - INFO: Python version: 3.9.9
45 - INFO: pynvim version: 0.4.3
46 - OK: Latest pynvim is installed.
Any suggestions?
Try running :UpdateRemotePlugins before calling Black()
If @ZSarver's suggestion doesn't help, I'm not sure what the issue could be. I can't reproduce this.
Thanks for the help. I now have this working. I had two problems, and perhaps a bit more documentation might help others.
First, I didn't realize that I need to do: :Call Black()
rather that just :Black()
which is probably just my ignorance.
Then, when I tried to run UpdateRemotePlugins
it failed. I had to figure out that it was trying to run the Python code in the black/rplugin directory. From that code, I figured out that I needed to pip install black
, although I didn't see this as the error message when trying to run UpdateRemotePlugin
. I don't see in the documentation that one must use pip to install black. I had installed black on my Mac using homebrew, so it was not available as a python module, only as a command line tool. My bad, and just not thinking about it. However, it seems that a clear requirement for this in the readme would be nice.
So, now it works and it's great!
Weirdly, running :checkhealth
was all I needed to do to fix this error
Then, when I tried to run
UpdateRemotePlugins
it failed. I had to figure out that it was trying to run the Python code in the black/rplugin directory. From that code, I figured out that I needed topip install black
, although I didn't see this as the error message when trying to runUpdateRemotePlugin
. I don't see in the documentation that one must use pip to install black. I had installed black on my Mac using homebrew, so it was not available as a python module, only as a command line tool. My bad, and just not thinking about it. However, it seems that a clear requirement for this in the readme would be nice.
True, the part about setting up a virtual environment is not clear enough that there needs to be one environment with both black and pynvim installed.