mattn / efm-langserver

General purpose Language Server
MIT License
1.37k stars 61 forks source link

Python venv and monorepo #224

Open laurentS opened 2 years ago

laurentS commented 2 years ago

I use a monorepo for a project such as:

/myproject
/myproject/.git
/myproject/python_pkg/
/myproject/python_pkg/pyproject.toml
/myproject/node_pkg/
/myproject/node_pkg/package.json

I am trying to configure efm to format python files (under /myproject/python_pkg) using black with { formatCommand = "poetry run black --quiet -", formatStdin = true }. This works on "normal" repos where the pyproject.toml file is at the same level as .git, but if I start nvim under /myproject then I can't seem to find a way to make this work (because efm seems to execute poetry in /myproject where it cannot find its config. Running without poetry run misses the project-level config, so it's not a solution either.

I tried wrapping the formatCommand in a bit of lua that would detect the current filename and extract the path from it, but I'm too noob with lua to figure it out.

Is there a way to handle this situation?

Also, thanks for a very nice little plugin :)

itaranto commented 2 years ago

I have the same problem at work, the problem seems to be that root_markers expect certain files to be there to trigger efm's actions.

What I did was an ugly hack where I have all my linters config file in the root, for example .flake8, .style.yapf, .isort.config, etc. and then I create a symbolic link to then in each subproject's directory.

It's not ideal, I know, and I don't even know if it works in Windows actually.