ms-jpq / coq_nvim

Fast as FUCK nvim completion. SQLite, concurrent scheduler, hundreds of hours of optimization.
GNU General Public License v3.0
3.58k stars 99 forks source link

What must I do to install python dependencies in headless mode? #554

Open rogueinkamp opened 1 year ago

rogueinkamp commented 1 year ago

Hello, thank you for the great plugin.

I am wondering how to support headless install. This is to set up my environment in Docker.

I have tried to do:

RUN nvim --headless +COQdeps +qa

But this does not seem to complete the install.

I have noticed that it attempts to install to .local/share/nvim/plugged/coq_nvim/.vars/runtime/ so I have tried to install the dependencies there:

RUN mkdir -p $HOME/.local/share/nvim/plugged/coq_nvim/.vars/runtime
RUN python3.10 -m venv $HOME/.local/share/nvim/plugged/coq_nvim/.vars/runtime/
RUN $HOME/.local/share/nvim/plugged/coq_nvim/.vars/runtime/bin/python3.10 -m pip install pynvim msgpack PyYAML
RUN $HOME/.local/share/nvim/plugged/coq_nvim/.vars/runtime/bin/python3.10 -m pip install https://github.com/ms-jpq/pynvim_pp/archive/pp.tar.gz
RUN $HOME/.local/share/nvim/plugged/coq_nvim/.vars/runtime/bin/python3.10 -m pip install https://github.com/ms-jpq/std2/archive/std.tar.gz

However, when launching nvim, it still insists I run COQdeps.

Afterwards, it appears that the dependencies are fairly the same as they were before:

root@2a3596a65f8d:/root# .local/share/nvim/plugged/coq_nvim/.vars/runtime/bin/pip3 freezegreenlet==2.0.2
msgpack==1.0.4
pynvim==0.4.3
pynvim-pp @ https://github.com/ms-jpq/pynvim_pp/archive/pp.tar.gz
PyYAML==6.0
std2 @ https://github.com/ms-jpq/std2/archive/std.tar.gz

Then run neovim and COQdeps. Now check again:

root@2a3596a65f8d:/root# .local/share/nvim/plugged/coq_nvim/.vars/runtime/bin/pip3 freeze
msgpack==1.0.4
pynvim-pp @ https://github.com/ms-jpq/pynvim_pp/archive/456765f6dc8cef6df39ae3e61c79585258d38517.tar.gz
PyYAML==5.4.1
std2 @ https://github.com/ms-jpq/std2/archive/963cf22346620926c0bd64f628ff4d8141123db5.tar.gz

How do I properly set up python beforehand so I do not have to run COQdeps?

Again, thank you for this great plugin. Have a great day.

psadi commented 3 months ago

I would very much like this, Im configuring nvim as part of CI and would like COQdeps to run in headless mode. Any updates on this yet ?

TheLeoP commented 2 weeks ago

This approach doesnt' work because the :COQdeps command starts a process in a terminal and doing :qa immediately after finishes Neovim befor the process has finished.

The command simply calls the following

https://github.com/ms-jpq/coq_nvim/blob/db12581bea4e83b8d8142c15daa9632d796636cf/lua/coq.lua#L118-L120

Which executes python3 -s -u -m coq deps on the cwd ~/.local/share/nvim/lazy/coq_nvim (or wherever coq_nvim is installed on your machine) setting the following environment variablels for that process

PYTHONSAFEPATH="1"
PYTHONPATH="~/.local/share/nvim/lazy/coq_nvim"

So, you could simply execute that instead of calling :COQdeps in a headless Neovim instance.

Another option would be to, on a timer, check for the text COQ EXITED on the terminal buffer and finish the Neovim process after that, not immediately