Closed fast-90 closed 1 year ago
After some further searching I found https://github.com/polymode/polymode/issues/305#issuecomment-1018700437 and found a way to fix this issue in my config by adding the following lines:
(add-to-list 'polymode-run-these-after-change-functions-in-other-buffers 'eglot--after-change)
(add-to-list 'polymode-run-these-before-change-functions-in-other-buffers 'eglot--before-change)
I'm not sure whether this is something that needs be fixed in Eglot (or Polymode) or whether it is just something users have to put in their config, however since my issue is solved for now I'm happy to close this one. Feel free to open again if you think it needs addressing in Eglot.
Summary
Eglot works fine in a single Python block in polymode, however creating a second Python block results in an error.
If
eglot reconnect
is invoked after the creation of the second block (with the cursor in the block), then it starts to work as expected again until another block is created.Not sure if related to #1085, however my setup is different so think it's good to separate the discussion for now.
Setup used:
Please let me know if I need to provide additional details to investigate.
Reports
eglot-events-buffer
``` [internal] Sun Jun 4 15:59:36 2023: (:message "Running language server: /Users/duynguyen/.local/bin/pylsp") [client-request] (id:1) Sun Jun 4 15:59:36 2023: (:jsonrpc "2.0" :id 1 :method "initialize" :params (:processId 17951 :rootPath "/Users/duynguyen/repos/myfunc/" :rootUri "file:///Users/duynguyen/repos/myfunc" :initializationOptions #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data ()) :capabilities (:workspace (:applyEdit t :executeCommand (:dynamicRegistration :json-false) :workspaceEdit (:documentChanges t) :didChangeWatchedFiles (:dynamicRegistration t) :symbol (:dynamicRegistration :json-false) :configuration t :workspaceFolders t) :textDocument (:synchronization (:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didSave t) :completion (:dynamicRegistration :json-false :completionItem (:snippetSupport :json-false :deprecatedSupport t :tagSupport (:valueSet [1])) :contextSupport t) :hover (:dynamicRegistration :json-false :contentFormat ["markdown" "plaintext"]) :signatureHelp (:dynamicRegistration :json-false :signatureInformation (:parameterInformation (:labelOffsetSupport t) :activeParameterSupport t)) :references (:dynamicRegistration :json-false) :definition (:dynamicRegistration :json-false :linkSupport t) :declaration (:dynamicRegistration :json-false :linkSupport t) :implementation (:dynamicRegistration :json-false :linkSupport t) :typeDefinition (:dynamicRegistration :json-false :linkSupport t) :documentSymbol (:dynamicRegistration :json-false :hierarchicalDocumentSymbolSupport t :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 :json-false) :codeAction (:dynamicRegistration :json-false :codeActionLiteralSupport (:codeActionKind (:valueSet ["quickfix" "refactor" "refactor.extract" "refactor.inline" "refactor.rewrite" "source" "source.organizeImports"])) :isPreferredSupport t) :formatting (:dynamicRegistration :json-false) :rangeFormatting (:dynamicRegistration :json-false) :rename (:dynamicRegistration :json-false) :publishDiagnostics (:relatedInformation :json-false :codeDescriptionSupport :json-false :tagSupport (:valueSet [1 2]))) :experimental #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data ())) :workspaceFolders [(:uri "file:///Users/duynguyen/repos/myfunc" :name "~/repos/myfunc/")])) [server-reply] (id:1) Sun Jun 4 15:59:37 2023: (:jsonrpc "2.0" :id 1 :result (:capabilities (:codeActionProvider t :codeLensProvider (:resolveProvider :json-false) :completionProvider (:resolveProvider t :triggerCharacters ["."]) :documentFormattingProvider t :documentHighlightProvider t :documentRangeFormattingProvider t :documentSymbolProvider t :definitionProvider t :executeCommandProvider (:commands ["pylsp_rope.quickfix.generate" "pylsp_rope.refactor.introduce_parameter" "pylsp_rope.refactor.extract.method" "pylsp_rope.refactor.extract.variable" "pylsp_rope.refactor.inline" "pylsp_rope.refactor.local_to_field" "pylsp_rope.refactor.method_to_method_object" "pylsp_rope.refactor.use_function" "pylsp_rope.source.organize_import"]) :hoverProvider t :referencesProvider t :renameProvider t :foldingRangeProvider t :signatureHelpProvider (:triggerCharacters ["(" "," "="]) :textDocumentSync (:change 2 :save (:includeText t) :openClose t) :workspace (:workspaceFolders (:supported t :changeNotifications t)) :experimental nil) :serverInfo (:name "pylsp" :version "1.7.2"))) [client-notification] Sun Jun 4 15:59:37 2023: (:jsonrpc "2.0" :method "initialized" :params #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data ())) [client-notification] Sun Jun 4 15:59:37 2023: (:jsonrpc "2.0" :method "textDocument/didOpen" :params (:textDocument (:uri "file:///Users/duynguyen/repos/myfunc/mre.md" :version 0 :languageId "python" :text "```{python}\nprint(\"Hello!\")\n```"))) [client-notification] Sun Jun 4 15:59:37 2023: (:jsonrpc "2.0" :method "workspace/didChangeConfiguration" :params (:settings #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data ()))) [server-notification] Sun Jun 4 15:59:38 2023: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///Users/duynguyen/repos/myfunc/mre.md" :diagnostics [(:range (:start (:line 0 :character 1) :end (:line 0 :character 2)) :message "SyntaxError: Got unexpected token `" :severity 1 :code "E999" :source "ruff" :tags []) (:source "mypy" :range (:start (:line 0 :character 0) :end (:line 0 :character 1000)) :message "mypy: can't read file '/Users/duynguyen/repos/myfunc/mre.md': No such file or directory\n" :severity 1)])) [client-notification] Sun Jun 4 15:59:45 2023: (:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "file:///Users/duynguyen/repos/myfunc/mre.md" :version 4) :contentChanges [(:range (:start (:line 5 :character 1) :end (:line 5 :character 1)) :rangeLength 0 :text "r") (:range (:start (:line 5 :character 2) :end (:line 5 :character 2)) :rangeLength 0 :text "i") (:range (:start (:line 5 :character 3) :end (:line 5 :character 3)) :rangeLength 0 :text "n") (:range (:start (:line 5 :character 4) :end (:line 5 :character 4)) :rangeLength 0 :text "t")])) [client-request] (id:2) Sun Jun 4 15:59:45 2023: (:jsonrpc "2.0" :id 2 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/duynguyen/repos/myfunc/mre.md") :position (:line 5 :character 5))) [client-request] (id:3) Sun Jun 4 15:59:45 2023: (:jsonrpc "2.0" :id 3 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/duynguyen/repos/myfunc/mre.md") :position (:line 5 :character 5))) [client-request] (id:4) Sun Jun 4 15:59:45 2023: (:jsonrpc "2.0" :id 4 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/duynguyen/repos/myfunc/mre.md") :position (:line 5 :character 5))) [stderr] 2023-06-04 15:59:46,031 CEST - WARNING - pylsp.config.config - Failed to load hook pylsp_signature_help: `line` parameter is not in a valid range. [stderr] Traceback (most recent call last): [stderr] File "/Users/duynguyen/.local/lib/python3.10/site-packages/pylsp/config/config.py", line 33, in _hookexec [stderr] return self._inner_hookexec(hook_name, methods, kwargs, firstresult) [stderr] File "/Users/duynguyen/.local/lib/python3.10/site-packages/pluggy/_manager.py", line 327, in traced_hookexec [stderr] return outcome.get_result() [stderr] File "/Users/duynguyen/.local/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result [stderr] raise ex[1].with_traceback(ex[2]) [stderr] File "/Users/duynguyen/.local/lib/python3.10/site-packages/pluggy/_result.py", line 33, in from_call [stderr] result = func() [stderr] File "/Users/duynguyen/.local/lib/python3.10/site-packages/pluggy/_manager.py", line 324, inBacktrace
``` Debugger entered--Lisp error: (wrong-type-argument plistp []) plist-member([] :signatures) #f(compiled-function (jsonrpc-lambda-elem10) #MRE recipe (tested with
emacs -Q
)pylsp
LSP is installed viapip install
and available in path.eglot
,python
andpoly-markdown
(available on MELPA).Example config
```elisp (require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (package-initialize) (package-refresh-contents) (package-install 'poly-markdown) (require 'poly-markdown) (require 'python) (require 'eglot) ```mre.md
) with the following content: