black-nvim icon indicating copy to clipboard operation
black-nvim copied to clipboard

Black() gives function not found error

Open tthkbw opened this issue 3 years ago • 3 comments

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?

tthkbw avatar Jan 04 '22 18:01 tthkbw

Try running :UpdateRemotePlugins before calling Black()

ZSarver avatar Jan 25 '22 15:01 ZSarver

If @ZSarver's suggestion doesn't help, I'm not sure what the issue could be. I can't reproduce this.

averms avatar Jan 26 '22 06:01 averms

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!

tthkbw avatar Jan 26 '22 16:01 tthkbw

Weirdly, running :checkhealth was all I needed to do to fix this error

mikejar avatar Aug 15 '22 16:08 mikejar

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.

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.

averms avatar Sep 15 '22 08:09 averms