Closed binamkayastha closed 2 years ago
Hello! Thanks for the detailed report with suggestions! I know pylsp allows toggling certain behavior by providing your own configuration (they've got it documented here).
I see they also provide a JSON schema for this configuration, so I just pushed a commit that incorporates it into the installer UI, so you can explore it from within neovim as well:
I wonder if you'll be able to do what you want to by just changing some configurations, for example setting
lsp_installer.on_server_ready(function (server)
local opts = {}
if server.name == "pylsp" then
opts.settings = {
pylsp = {
plugins = {
pycodestyle = { enabled = false },
yapf = { enabled = false }
}
}
}
end
server:setup(opts)
end)
Oh my gosh yes it works! That's a much better solution 😅
I was trying to do that earlier but I missed the "enabled" 🤦 . I was doing yapf = false
instead of yapf = {enabled = false}
fyi - I only needed to disable yapf and didn't need to touch pycodestyle.
The UI is awesome~ You're the best, thank you so much!
@binamkayastha May I ask you that if I want this behaviour that is described in the link (with image): https://github.com/hrsh7th/nvim-cmp/issues/823 Then which option should I enable?
NOTE: while the link it's about pyright
but the same problem happen in pylsp
.
(thank you for your work on the installer)
Describe the issue
For the
pylsp
server after running:PylspInstall python-lsp-black
does not use the black formatter. It uses the autopep8 and yapf formatters instead because:LspInstall pylsp
installs the python lsp with the[all]
descriptor (python-lsp-server[all]
).Links nvim-lsp-installer PylspInstall code python-lsp-server python-lsp-black
System info (please complete the following information):
Checkhealth output (
:checkhealth nvim-lsp-installer
): LinuxOSx
Replication Steps
Create a temporary python file
Run the formatter
Expected behavior
Expected (single quotes are replaced with double quotes):
Actual (single quotes are kept as is):
Workaround
DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far (In case there is someone out there like who is specifically running neovim, nvim-lspconfig, nvim-lsp-installer, pylsp, python-lsp-black, and black :)
After I understood that PylspInstall wax creating the virtualenv in
~/.local/share/nvim/
I was able to fix my issue by uninstalling yapf and autopep8 specifically:It started working after that.
Possible Solutions
These are just off the top of my head, there might be other solutions as well. I also don't know what the "right" solution is.
Modify
:LspInstall pylsp
to not install with[all]
extras.python-lsp-server[all]
would becomepython-lsp-server
:heavy_plus_sign: The black formatter plugin won't conflict with the yapf and autopep8 when it's installed :heavy_minus_sign: We'll need to add extra commands that allow the user to installpython-lsp-server[yapf]
andpython-lsp-server[all]
:heavy_minus_sign: It won't include the linters and other packages by default (see pip freeze packages below)Modify PylspInstall to uninstall other formatters when it installs black
:heavy_plus_sign: "It just works" for the user :heavy_plus_sign: It will include packages from [all] like the formatter :heavy_minus_sign: There's no way to "undo" adding the formatter for black. :heavy_minus_sign: You also still run into the issue when one project uses black, but another may not.
Allow PylspInstall to specify which virtualenv to install the plugins
:heavy_plus_sign: Pylsp can be configured to have per project configurations when these projects have virtualenvs. :heavy_plus_sign: Can use the default virtualenv (the current one in .loacl) when one is not provided :heavy_minus_sign: You still own't be able to run black in the default virtualenv :heavy_minus_sign: This is probably more of a feature request an a bugfix
pip freeze info
pip freeze
forpip install python-lsp-server[all]
pip freeze
forpip install python-lsp-server[yapf]
pip freeze
forpip install python-lsp-server