-
Notifications
You must be signed in to change notification settings - Fork 24
Description
When using python-lsp-ruff from emacs with eglot, most things work fine, including autocomplete, linting, jump to definition. Two things do not work at all, though: auto-formatting and quick fixes. Those do work when I use the ruff server, so they are supported by eglot/emacs.
I use the following config in emacs:
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'(python-base-mode . ("pylsp" :initializationOptions
(:pylsp (:plugins (:ruff
(:enabled t
:formatEnabled t))))))))
Below is a log of a short session where I try to format and ask for fixes.
----- Start log ----
[jsonrpc] D[00:18:10.925] Running language server: pylsp
[jsonrpc] e[00:18:10.925] --> initialize[1] {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"processId":83283,"clientInfo":{"name":"Eglot","version":"1.17.30"},"rootPath":"/tmp/test/","rootUri":"file:///private/tmp/test","initializationOptions":{"pylsp":{"plugins":{"ruff":{"enabled":true,"formatEnabled":true}}}},"capabilities":{"workspace":{"applyEdit":true,"executeCommand":{"dynamicRegistration":false},"workspaceEdit":{"documentChanges":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":false},"configuration":true,"workspaceFolders":true},"textDocument":{"synchronization":{"dynamicRegistration":false,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":false,"completionItem":{"snippetSupport":true,"deprecatedSupport":true,"resolveSupport":{"properties":["documentation","details","additionalTextEdits"]},"tagSupport":{"valueSet":[1]}},"contextSupport":true},"hover":{"dynamicRegistration":false,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":false,"signatureInformation":{"parameterInformation":{"labelOffsetSupport":true},"documentationFormat":["markdown","plaintext"],"activeParameterSupport":true}},"references":{"dynamicRegistration":false},"definition":{"dynamicRegistration":false,"linkSupport":true},"declaration":{"dynamicRegistration":false,"linkSupport":true},"implementation":{"dynamicRegistration":false,"linkSupport":true},"typeDefinition":{"dynamicRegistration":false,"linkSupport":true},"documentSymbol":{"dynamicRegistration":false,"hierarchicalDocumentSymbolSupport":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"documentHighlight":{"dynamicRegistration":false},"codeAction":{"dynamicRegistration":false,"resolveSupport":{"properties":["edit","command"]},"dataSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"isPreferredSupport":true},"formatting":{"dynamicRegistration":false},"rangeFormatting":{"dynamicRegistration":false},"rename":{"dynamicRegistration":false},"inlayHint":{"dynamicRegistration":false},"publishDiagnostics":{"relatedInformation":false,"codeDescriptionSupport":false,"tagSupport":{"valueSet":[1,2]}}},"window":{"showDocument":{"support":true},"workDoneProgress":true},"general":{"positionEncodings":["utf-32","utf-8","utf-16"]},"experimental":{}},"workspaceFolders":[{"uri":"file:///private/tmp/test","name":"/tmp/test/"}]}}
[jsonrpc] e[00:18:11.430] <-- initialize[1] {"jsonrpc":"2.0","id":1,"result":{"capabilities":{"codeActionProvider":true,"codeLensProvider":{"resolveProvider":false},"completionProvider":{"resolveProvider":true,"triggerCharacters":["."]},"documentFormattingProvider":true,"documentHighlightProvider":true,"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"definitionProvider":true,"typeDefinitionProvider":true,"executeCommandProvider":{"commands":[]},"hoverProvider":true,"referencesProvider":true,"renameProvider":true,"foldingRangeProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",",","="]},"textDocumentSync":{"change":2,"save":{"includeText":true},"openClose":true},"notebookDocumentSync":{"notebookSelector":[{"cells":[{"language":"python"}]}]},"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":true}},"experimental":{}},"serverInfo":{"name":"pylsp","version":"1.14.0"}}}
[jsonrpc] e[00:18:11.430] --> initialized {"jsonrpc":"2.0","method":"initialized","params":{}}
[jsonrpc] e[00:18:11.431] --> textDocument/didOpen {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///private/tmp/test/test.py","version":0,"languageId":"python-base","text":"import sys\n\nprint(sys.argv )\n"}}}
[jsonrpc] e[00:18:11.431] --> workspace/didChangeConfiguration {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}
[jsonrpc] e[00:18:11.943] <-- textDocument/publishDiagnostics {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///private/tmp/test/test.py","diagnostics":[]}}
[jsonrpc] e[00:18:16.700] --> textDocument/hover[2] {"jsonrpc":"2.0","id":2,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///private/tmp/test/test.py"},"position":{"line":1,"character":0}}}
[jsonrpc] e[00:18:16.700] --> textDocument/documentHighlight[3] {"jsonrpc":"2.0","id":3,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///private/tmp/test/test.py"},"position":{"line":1,"character":0}}}
[jsonrpc] e[00:18:16.700] --> textDocument/signatureHelp[4] {"jsonrpc":"2.0","id":4,"method":"textDocument/signatureHelp","params":{"textDocument":{"uri":"file:///private/tmp/test/test.py"},"position":{"line":1,"character":0}}}
[jsonrpc] e[00:18:16.795] <-- textDocument/hover[2] {"jsonrpc":"2.0","id":2,"result":{"contents":""}}
[jsonrpc] e[00:18:16.820] <-- textDocument/documentHighlight[3] {"jsonrpc":"2.0","id":3,"result":null}
[jsonrpc] e[00:18:16.820] <-- textDocument/signatureHelp[4] {"jsonrpc":"2.0","id":4,"result":{"signatures":[]}}
[jsonrpc] e[00:18:19.194] --> textDocument/formatting[5] {"jsonrpc":"2.0","id":5,"method":"textDocument/formatting","params":{"textDocument":{"uri":"file:///private/tmp/test/test.py"},"options":{"tabSize":8,"insertSpaces":true,"insertFinalNewline":true,"trimFinalNewlines":true}}}
[jsonrpc] e[00:18:19.195] <-- textDocument/formatting[5] {"jsonrpc":"2.0","id":5,"result":null}
[jsonrpc] e[00:18:44.840] --> textDocument/codeAction[6] {"jsonrpc":"2.0","id":6,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///private/tmp/test/test.py"},"range":{"start":{"line":1,"character":0},"end":{"line":1,"character":0}},"context":{"diagnostics":[]}}}
[jsonrpc] e[00:18:44.841] <-- textDocument/codeAction[6] {"jsonrpc":"2.0","id":6,"result":[]}