Closed vihu closed 1 year ago
My suspicion is that somehow pyright takes priority and since it does not have formatting capabilities that could be a problem?
No, lsp-format iterates over all clients.
The config you posted looks fine. Try to set logLevel = 5
in the efm settings and see if you get any logs that are helpful. You get the log path with :lua print(vim.lsp.get_log_path())
[ERROR][2022-09-05 19:26:20] .../vim/lsp/rpc.lua:420 "rpc" "efm-langserver" "stderr" "2022/09/05 19:26:20 jsonrpc2 handler: sending response 2: jsonrpc2: connection is closed\n2022/09/05 19:26:20 efm-langserver: connections closed\n"
[START][2022-09-05 19:26:22] LSP logging initiated
[ERROR][2022-09-05 19:26:22] .../vim/lsp/rpc.lua:420 "rpc" "efm-langserver" "stderr" "2022/09/05 19:26:22 efm-langserver: reading on stdin, writing on stdout\n"
[ERROR][2022-09-05 19:26:22] .../vim/lsp/rpc.lua:420 "rpc" "efm-langserver" "stderr" '2022/09/05 19:26:22 jsonrpc2 handler: notification "workspace/didChangeConfiguration" handling error: json: cannot unmarshal object into Go struct field Config.settings.languages of type []langserver.Language\n'
[WARN][2022-09-05 19:26:22] ...-format/init.lua:124 '"textDocument/formatting" is not supported for pyright, not attaching lsp-format'
[WARN][2022-09-05 19:26:22] ...lsp/handlers.lua:110 "The language server pyright triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless"
[WARN][2022-09-05 19:26:22] ...lsp/handlers.lua:457 "stubPath typings is not a valid directory."
Those jsonrpc2 errors seem to be the culprit here? I wonder if I need to install efm-langserver
differently? I basically did this: go install github.com/mattn/efm-langserver@latest
and added the binary to my $PATH
variable.
Ah sorry, I missed it as well. You are missing one level of braces. Because you can have more than one formatter per filetype.
python = {
{
formatCommand = "black --quiet -",
formatStdin = true,
},
}
Ah sorry, I missed it as well. You are missing one level of braces. Because you can have more than one formatter per filetype.
python = { { formatCommand = "black --quiet -", formatStdin = true, }, }
Oh yes, that worked perfectly! Much thanks and my bad for missing those extra curlies.
Summary
I'm unable to format python files with black formatter using efm language server.
Configuration
lsp-config.lua
language servers connected to python:
My suspicion is that somehow
pyright
takes priority and since it does not have formatting capabilities that could be a problem? Any advice would be helpful, thanks!