Open phst opened 2 years ago
Thanks @phst for a "proper" reproduction recipe (at least the way I intended it)
I somehow suspectthis is a Flymake problem, not an Eglot problem, but if Eglot+clangd is useful in reproducing it, why not? :-)
Can you say when in your LSP log you typed C-x 4 c
? Either say the time in relation to that log, or edit the transcript with a clear comment. Thanks
Sorry for the delay, here's another transcript on a different machine (on macOS, but the symptoms are the same):
Before cloning the buffer:
[internal] Sat Apr 23 21:07:44 2022:
(:message "Running language server: (/usr/bin/clangd)")
[client-request] (id:1) Sat Apr 23 21:07:44 2022:
(:jsonrpc "2.0" :id 1 :method "initialize" :params
(:processId 79116 :rootPath "/tmp/" :rootUri "file:///private/tmp" :initializationOptions #s(hash-table size 65 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
["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 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data
()))
:workspaceFolders
[(:uri "file:///private/tmp" :name "/tmp/")]))
[stderr] I[21:07:44.572] Apple clangd version 13.1.6 (clang-1316.0.21.2.3)
[stderr] I[21:07:44.572] Features: mac+xpc
[stderr] I[21:07:44.572] PID: 79117
[stderr] I[21:07:44.572] Working directory: /tmp
[stderr] I[21:07:44.572] argv[0]: /Library/Developer/CommandLineTools/usr/bin/clangd
[stderr] I[21:07:44.572] Starting LSP over stdin/stdout
[stderr] I[21:07:44.572] <-- initialize(1)
[stderr] I[21:07:44.576] --> reply:initialize(1) 3 ms
[server-reply] (id:1) Sat Apr 23 21:07:44 2022:
(:id 1 :jsonrpc "2.0" :result
(:capabilities
(:astProvider t :callHierarchyProvider t :codeActionProvider
(:codeActionKinds
["quickfix" "refactor" "info"])
:compilationDatabase
(:automaticReload t)
:completionProvider
(:allCommitCharacters
[" " " " "(" ")" "[" "]" "{" "}" "<" ">" ":" ";" "," "+" "-" "/" "*" "%" "^" "&" "#" "?" "." "=" "\"" "'" "|"]
:resolveProvider :json-false :triggerCharacters
["." "<" ">" ":" "\"" "/"])
:declarationProvider t :definitionProvider t :documentFormattingProvider t :documentHighlightProvider t :documentLinkProvider
(:resolveProvider :json-false)
:documentOnTypeFormattingProvider
(:firstTriggerCharacter "\n" :moreTriggerCharacter
[])
:documentRangeFormattingProvider t :documentSymbolProvider t :executeCommandProvider
(:commands
["clangd.applyFix" "clangd.applyTweak"])
:hoverProvider t :implementationProvider t :memoryUsageProvider t :referencesProvider t :renameProvider t :selectionRangeProvider t :semanticTokensProvider
(:full
(:delta t)
:legend
(:tokenModifiers
["declaration" "deprecated" "deduced" "readonly" "static" "abstract" "dependentName" "defaultLibrary" "functionScope" "classScope" "fileScope" "globalScope"]
:tokenTypes
["variable" "variable" "parameter" "function" "method" "function" "property" "variable" "class" "interface" "enum" "enumMember" "type" "type" "unknown" "namespace" "typeParameter" "concept" "type" "macro" "comment"])
:range :json-false)
:signatureHelpProvider
(:triggerCharacters
["(" ","])
:textDocumentSync
(:change 2 :openClose t :save t)
:typeHierarchyProvider t :workspaceSymbolProvider t)
:serverInfo
(:name "clangd" :version "Apple clangd version 13.1.6 (clang-1316.0.21.2.3) mac+xpc")))
[client-notification] Sat Apr 23 21:07:44 2022:
(:jsonrpc "2.0" :method "initialized" :params #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data
()))
[client-notification] Sat Apr 23 21:07:44 2022:
(:jsonrpc "2.0" :method "textDocument/didOpen" :params
(:textDocument
(:uri "file:///private/tmp/a.c" :version 0 :languageId "c" :text "")))
[client-notification] Sat Apr 23 21:07:44 2022:
(:jsonrpc "2.0" :method "workspace/didChangeConfiguration" :params
(:settings nil))
[server-notification] Sat Apr 23 21:07:44 2022:
(:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params
(:diagnostics
[]
:uri "file:///private/tmp/a.c" :version 0))
[stderr] I[21:07:44.591] <-- initialized
[stderr] I[21:07:44.591] <-- textDocument/didOpen
[stderr] I[21:07:44.591] Failed to find compilation database for /private/tmp/a.c
[stderr] I[21:07:44.591] ASTWorker building file /private/tmp/a.c version 0 with command clangd fallback
[stderr] [/private/tmp]
[stderr] /Library/Developer/CommandLineTools/usr/bin/clang /private/tmp/a.c -resource-dir=/Library/Developer/CommandLineTools/usr/lib/clang/13.1.6
[stderr] I[21:07:44.601] <-- workspace/didChangeConfiguration
[stderr] I[21:07:44.608] --> textDocument/publishDiagnostics
[client-request] (id:2) Sat Apr 23 21:07:45 2022:
(:jsonrpc "2.0" :id 2 :method "textDocument/signatureHelp" :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 0)))
[client-request] (id:3) Sat Apr 23 21:07:45 2022:
(:jsonrpc "2.0" :id 3 :method "textDocument/hover" :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 0)))
[client-request] (id:4) Sat Apr 23 21:07:45 2022:
(:jsonrpc "2.0" :id 4 :method "textDocument/documentHighlight" :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 0)))
[server-reply] (id:3) Sat Apr 23 21:07:45 2022:
(:id 3 :jsonrpc "2.0" :result nil)
[server-reply] (id:4) Sat Apr 23 21:07:45 2022:
(:id 4 :jsonrpc "2.0" :result
[])
[stderr] I[21:07:45.172] <-- textDocument/signatureHelp(2)
[stderr] I[21:07:45.173] <-- textDocument/hover(3)
[stderr] I[21:07:45.174] --> reply:textDocument/hover(3) 0 ms
[stderr] I[21:07:45.174] <-- textDocument/documentHighlight(4)
[stderr] I[21:07:45.174] --> reply:textDocument/documentHighlight(4) 0 ms
[server-reply] (id:2) Sat Apr 23 21:07:45 2022:
(:id 2 :jsonrpc "2.0" :result
(:activeParameter 0 :activeSignature 0 :signatures
[]))
[stderr] I[21:07:45.185] --> reply:textDocument/signatureHelp(2) 12 ms
After cloning the buffer, before typing:
[client-request] (id:5) Sat Apr 23 21:08:35 2022:
(:jsonrpc "2.0" :id 5 :method "textDocument/signatureHelp" :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 0)))
[client-request] (id:6) Sat Apr 23 21:08:35 2022:
(:jsonrpc "2.0" :id 6 :method "textDocument/hover" :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 0)))
[client-request] (id:7) Sat Apr 23 21:08:35 2022:
(:jsonrpc "2.0" :id 7 :method "textDocument/documentHighlight" :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 0)))
[server-reply] (id:6) Sat Apr 23 21:08:35 2022:
(:id 6 :jsonrpc "2.0" :result nil)
[server-reply] (id:7) Sat Apr 23 21:08:35 2022:
(:id 7 :jsonrpc "2.0" :result
[])
[stderr] I[21:08:35.041] <-- textDocument/signatureHelp(5)
[stderr] I[21:08:35.042] <-- textDocument/hover(6)
[stderr] I[21:08:35.042] --> reply:textDocument/hover(6) 0 ms
[stderr] I[21:08:35.042] <-- textDocument/documentHighlight(7)
[stderr] I[21:08:35.042] --> reply:textDocument/documentHighlight(7) 0 ms
[server-reply] (id:5) Sat Apr 23 21:08:35 2022:
(:id 5 :jsonrpc "2.0" :result
(:activeParameter 0 :activeSignature 0 :signatures
[]))
[stderr] I[21:08:35.053] --> reply:textDocument/signatureHelp(5) 12 ms
After typing and getting the error:
[internal] (id:8) Sat Apr 23 21:09:15 2022:
(:deferring :textDocument/signatureHelp :id 8 :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 1)))
[internal] (id:9) Sat Apr 23 21:09:15 2022:
(:deferring :textDocument/hover :id 9 :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 1)))
[internal] (id:10) Sat Apr 23 21:09:15 2022:
(:deferring :textDocument/documentHighlight :id 10 :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 1)))
[client-notification] Sat Apr 23 21:09:15 2022:
(:jsonrpc "2.0" :method "textDocument/didChange" :params
(:textDocument
(:uri "file:///private/tmp/a.c" :version 1)
:contentChanges
[(:range
(:start
(:line 0 :character 0)
:end
(:line 0 :character 0))
:rangeLength 0 :text "a")]))
[internal] Sat Apr 23 21:09:15 2022:
(:maybe-run-deferred
(8 9 10))
[client-request] (id:8) Sat Apr 23 21:09:15 2022:
(:jsonrpc "2.0" :id 8 :method "textDocument/signatureHelp" :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 1)))
[client-request] (id:9) Sat Apr 23 21:09:15 2022:
(:jsonrpc "2.0" :id 9 :method "textDocument/hover" :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 1)))
[client-request] (id:10) Sat Apr 23 21:09:15 2022:
(:jsonrpc "2.0" :id 10 :method "textDocument/documentHighlight" :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 1)))
[stderr] I[21:09:15.455] <-- textDocument/didChange
[stderr] I[21:09:15.455] <-- textDocument/signatureHelp(8)
[stderr] I[21:09:15.456] <-- textDocument/hover(9)
[stderr] I[21:09:15.456] <-- textDocument/documentHighlight(10)
[stderr] I[21:09:15.456] Failed to find compilation database for /private/tmp/a.c
[stderr] I[21:09:15.456] ASTWorker building file /private/tmp/a.c version 1 with command clangd fallback
[stderr] [/private/tmp]
[stderr] /Library/Developer/CommandLineTools/usr/bin/clang /private/tmp/a.c -resource-dir=/Library/Developer/CommandLineTools/usr/lib/clang/13.1.6
[server-reply] (id:8) Sat Apr 23 21:09:15 2022:
(:id 8 :jsonrpc "2.0" :result
(:activeParameter 0 :activeSignature 0 :signatures
[]))
[stderr] I[21:09:15.465] --> reply:textDocument/signatureHelp(8) 9 ms
[server-reply] (id:9) Sat Apr 23 21:09:15 2022:
(:id 9 :jsonrpc "2.0" :result nil)
[server-reply] (id:10) Sat Apr 23 21:09:15 2022:
(:id 10 :jsonrpc "2.0" :result
[])
[server-notification] Sat Apr 23 21:09:15 2022:
(:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params
(:diagnostics
[(:code "unknown_typename" :message "Unknown type name 'a'" :range
(:end
(:character 1 :line 0)
:start
(:character 0 :line 0))
:severity 1 :source "clang")
(:code "expected_either" :message "Expected identifier or '('" :range
(:end
(:character 1 :line 0)
:start
(:character 1 :line 0))
:severity 1 :source "clang")]
:uri "file:///private/tmp/a.c" :version 1))
[stderr] I[21:09:15.471] --> reply:textDocument/hover(9) 15 ms
[stderr] I[21:09:15.471] --> reply:textDocument/documentHighlight(10) 14 ms
[stderr] I[21:09:15.487] --> textDocument/publishDiagnostics
[client-request] (id:11) Sat Apr 23 21:09:18 2022:
(:jsonrpc "2.0" :id 11 :method "textDocument/signatureHelp" :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 1)))
[client-request] (id:12) Sat Apr 23 21:09:18 2022:
(:jsonrpc "2.0" :id 12 :method "textDocument/hover" :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 1)))
[client-request] (id:13) Sat Apr 23 21:09:18 2022:
(:jsonrpc "2.0" :id 13 :method "textDocument/documentHighlight" :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 1)))
[server-reply] (id:12) Sat Apr 23 21:09:18 2022:
(:id 12 :jsonrpc "2.0" :result nil)
[server-reply] (id:13) Sat Apr 23 21:09:18 2022:
(:id 13 :jsonrpc "2.0" :result
[])
[stderr] I[21:09:18.050] <-- textDocument/signatureHelp(11)
[stderr] I[21:09:18.051] <-- textDocument/hover(12)
[stderr] I[21:09:18.051] --> reply:textDocument/hover(12) 0 ms
[stderr] I[21:09:18.052] <-- textDocument/documentHighlight(13)
[stderr] I[21:09:18.052] --> reply:textDocument/documentHighlight(13) 0 ms
[server-reply] (id:11) Sat Apr 23 21:09:18 2022:
(:id 11 :jsonrpc "2.0" :result
(:activeParameter 0 :activeSignature 0 :signatures
[]))
[stderr] I[21:09:18.060] --> reply:textDocument/signatureHelp(11) 10 ms
[internal] (id:8) Sat Apr 23 21:09:25 2022:
(:timed-out :textDocument/signatureHelp :id 8 :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 1)))
[internal] (id:9) Sat Apr 23 21:09:25 2022:
(:timed-out :textDocument/hover :id 9 :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 1)))
[internal] (id:10) Sat Apr 23 21:09:25 2022:
(:timed-out :textDocument/documentHighlight :id 10 :params
(:textDocument
(:uri "file:///private/tmp/a.c")
:position
(:line 0 :character 1)))
Here's a corresponding backtrace:
Debugger entered--Lisp error: (error "[Flymake] Obsolete report from backend eglot-flyma...")
signal(error ("[Flymake] Obsolete report from backend eglot-flyma..."))
error("[Flymake] Obsolete report from backend eglot-flyma...")
flymake-error("Obsolete report from backend %s with explanation %..." eglot-flymake-backend nil)
flymake--handle-report(eglot-flymake-backend backend-token19 (#s(flymake--diag :locus #<buffer a.c> :beg 1 :end 3 :type eglot-error :text "clang: Unknown type name 'aa'" :backend nil :data ((eglot-lsp-diag :code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 1 :orig-end 3) #s(flymake--diag :locus #<buffer a.c> :beg 2 :end 3 :type eglot-error :text "clang: Expected identifier or '('" :backend nil :data ((eglot-lsp-diag :code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 2 :orig-end 3)) :region (1 . 3))
apply(flymake--handle-report eglot-flymake-backend backend-token19 ((#s(flymake--diag :locus #<buffer a.c> :beg 1 :end 3 :type eglot-error :text "clang: Unknown type name 'aa'" :backend nil :data ((eglot-lsp-diag :code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 1 :orig-end 3) #s(flymake--diag :locus #<buffer a.c> :beg 2 :end 3 :type eglot-error :text "clang: Expected identifier or '('" :backend nil :data ((eglot-lsp-diag :code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 2 :orig-end 3)) :region (1 . 3)))
#f(compiled-function (&rest args) #<bytecode -0x1d787f877e6e25dc>)((#s(flymake--diag :locus #<buffer a.c> :beg 1 :end 3 :type eglot-error :text "clang: Unknown type name 'aa'" :backend nil :data ((eglot-lsp-diag :code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 1 :orig-end 3) #s(flymake--diag :locus #<buffer a.c> :beg 2 :end 3 :type eglot-error :text "clang: Expected identifier or '('" :backend nil :data ((eglot-lsp-diag :code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 2 :orig-end 3)) :region (1 . 3))
funcall(#f(compiled-function (&rest args) #<bytecode -0x1d787f877e6e25dc>) (#s(flymake--diag :locus #<buffer a.c> :beg 1 :end 3 :type eglot-error :text "clang: Unknown type name 'aa'" :backend nil :data ((eglot-lsp-diag :code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 1 :orig-end 3) #s(flymake--diag :locus #<buffer a.c> :beg 2 :end 3 :type eglot-error :text "clang: Expected identifier or '('" :backend nil :data ((eglot-lsp-diag :code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 2 :orig-end 3)) :region (1 . 3))
(save-restriction (widen) (funcall eglot--current-flymake-report-fn diags :region (cons (point-min) (point-max))))
eglot--report-to-flymake((#s(flymake--diag :locus #<buffer a.c> :beg 1 :end 3 :type eglot-error :text "clang: Unknown type name 'aa'" :backend nil :data ((eglot-lsp-diag :code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 1 :orig-end 3) #s(flymake--diag :locus #<buffer a.c> :beg 2 :end 3 :type eglot-error :text "clang: Expected identifier or '('" :backend nil :data ((eglot-lsp-diag :code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 2 :orig-end 3)))
(cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--diagnostics diags)))
(let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list (let ((object-once diag-spec)) (let* (... ... ... ... ... ...) (progn ... ... ...))))))) (cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--diagnostics diags))) nil)
(save-current-buffer (set-buffer buffer) (let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list (let (...) (let* ... ...)))))) (cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--diagnostics diags))) nil))
(if buffer (save-current-buffer (set-buffer buffer) (let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list (let ... ...))))) (cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--diagnostics diags))) nil)) (let* ((path (expand-file-name (eglot--uri-to-path uri))) (--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list (let (...) (let* ... ...)))))) (setq flymake-list-only-diagnostics (assoc-delete-all path flymake-list-only-diagnostics #'string=)) (setq flymake-list-only-diagnostics (cons (cons path diags) flymake-list-only-diagnostics)) nil))
(let* ((buffer (and t (find-buffer-visiting (eglot--uri-to-path uri))))) (if buffer (save-current-buffer (set-buffer buffer) (let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list ...)))) (cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--diagnostics diags))) nil)) (let* ((path (expand-file-name (eglot--uri-to-path uri))) (--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list (let ... ...))))) (setq flymake-list-only-diagnostics (assoc-delete-all path flymake-list-only-diagnostics #'string=)) (setq flymake-list-only-diagnostics (cons (cons path diags) flymake-list-only-diagnostics)) nil)))
(progn (let* ((buffer (and t (find-buffer-visiting (eglot--uri-to-path uri))))) (if buffer (save-current-buffer (set-buffer buffer) (let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- ...) (< --cl-idx-- ...)) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags ...))) (cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--diagnostics diags))) nil)) (let* ((path (expand-file-name (eglot--uri-to-path uri))) (--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list ...)))) (setq flymake-list-only-diagnostics (assoc-delete-all path flymake-list-only-diagnostics #'string=)) (setq flymake-list-only-diagnostics (cons (cons path diags) flymake-list-only-diagnostics)) nil))))
(let* ((--cl-eglot--diag-type-- #'(lambda (sev) (cond ((null sev) 'eglot-error) ((<= sev 1) 'eglot-error) ((= sev 2) 'eglot-warning) (t 'eglot-note))))) (progn (let* ((buffer (and t (find-buffer-visiting (eglot--uri-to-path uri))))) (if buffer (save-current-buffer (set-buffer buffer) (let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and ... ...) (setq diag-spec ...) (setq diags ...)) (cond (eglot--current-flymake-report-fn ...) (t ...)) nil)) (let* ((path (expand-file-name ...)) (--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- ...) (< --cl-idx-- ...)) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags ...))) (setq flymake-list-only-diagnostics (assoc-delete-all path flymake-list-only-diagnostics #'string=)) (setq flymake-list-only-diagnostics (cons (cons path diags) flymake-list-only-diagnostics)) nil)))))
(let* ((uri (car (cdr (plist-member --cl-rest-- ':uri)))) (diagnostics (car (cdr (plist-member --cl-rest-- ':diagnostics))))) (let* ((--cl-eglot--diag-type-- #'(lambda (sev) (cond (... ...) (... ...) (... ...) (t ...))))) (progn (let* ((buffer (and t (find-buffer-visiting ...)))) (if buffer (save-current-buffer (set-buffer buffer) (let* (... ... ... ...) (while ... ... ...) (cond ... ...) nil)) (let* ((path ...) (--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and ... ...) (setq diag-spec ...) (setq diags ...)) (setq flymake-list-only-diagnostics (assoc-delete-all path flymake-list-only-diagnostics ...)) (setq flymake-list-only-diagnostics (cons ... flymake-list-only-diagnostics)) nil))))))
(progn (let* ((uri (car (cdr (plist-member --cl-rest-- ':uri)))) (diagnostics (car (cdr (plist-member --cl-rest-- ':diagnostics))))) (let* ((--cl-eglot--diag-type-- #'(lambda (sev) (cond ... ... ... ...)))) (progn (let* ((buffer (and t ...))) (if buffer (save-current-buffer (set-buffer buffer) (let* ... ... ... nil)) (let* (... ... ... ... ...) (while ... ... ...) (setq flymake-list-only-diagnostics ...) (setq flymake-list-only-diagnostics ...) nil)))))))
(closure (revert-buffer-preserve-modes eglot--managed-mode eglot-lsp-context company-tooltip-align-annotations company-backends markdown-fontify-code-blocks-natively t) (_server _method &rest --cl-rest--) "Handle notification publishDiagnostics.\n\n(fn SERVE..." (progn (let* ((uri (car (cdr ...))) (diagnostics (car (cdr ...)))) (let* ((--cl-eglot--diag-type-- #'...)) (progn (let* (...) (if buffer ... ...)))))))(#<eglot-lsp-server eglot-lsp-server-4c135e32> textDocument/publishDiagnostics :diagnostics [(:code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang") (:code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")] :uri "file:///private/tmp/a.c" :version 2)
apply((closure (revert-buffer-preserve-modes eglot--managed-mode eglot-lsp-context company-tooltip-align-annotations company-backends markdown-fontify-code-blocks-natively t) (_server _method &rest --cl-rest--) "Handle notification publishDiagnostics.\n\n(fn SERVE..." (progn (let* ((uri (car (cdr ...))) (diagnostics (car (cdr ...)))) (let* ((--cl-eglot--diag-type-- #'...)) (progn (let* (...) (if buffer ... ...))))))) #<eglot-lsp-server eglot-lsp-server-4c135e32> textDocument/publishDiagnostics (:diagnostics [(:code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang") (:code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")] :uri "file:///private/tmp/a.c" :version 2))
eglot-handle-notification(#<eglot-lsp-server eglot-lsp-server-4c135e32> textDocument/publishDiagnostics :diagnostics [(:code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang") (:code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")] :uri "file:///private/tmp/a.c" :version 2)
apply(eglot-handle-notification #<eglot-lsp-server eglot-lsp-server-4c135e32> textDocument/publishDiagnostics (:diagnostics [(:code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang") (:code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")] :uri "file:///private/tmp/a.c" :version 2))
(let ((eglot--cached-server server)) (apply fn server method (append params nil)))
(closure ((fn . eglot-handle-notification) (initargs :process (closure ((contact "/usr/bin/clangd") (more-initargs) (probe) (contact "/usr/bin/clangd") (server-info "/usr/bin/clangd") (autostart-inferior-process) (readable-name . "EGLOT (tmp/c-mode)") (nickname . "tmp") (language-id . "c") (contact "/usr/bin/clangd") (class . eglot-lsp-server) (project transient . "/tmp/") (managed-major-mode . c-mode) eglot--managed-mode eglot-lsp-context company-tooltip-align-annotations company-backends markdown-fontify-code-blocks-natively t) nil (let ((default-directory default-directory)) (make-process :name readable-name :command (setq server-info ...) :connection-type 'pipe :coding 'utf-8-emacs-unix :noquery t :stderr (get-buffer-create ...) :file-handler t)))) (contact "/usr/bin/clangd") (server-info "/usr/bin/clangd") (autostart-inferior-process) (readable-name . "EGLOT (tmp/c-mode)") (nickname . "tmp") (language-id . "c") (contact "/usr/bin/clangd") (class . eglot-lsp-server) (project transient . "/tmp/") (managed-major-mode . c-mode) eglot--managed-mode eglot-lsp-context company-tooltip-align-annotations company-backends markdown-fontify-code-blocks-natively t) (server method params) (let ((eglot--cached-server server)) (apply fn server method (append params nil))))(#<eglot-lsp-server eglot-lsp-server-4c135e32> textDocument/publishDiagnostics (:diagnostics [(:code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang") (:code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")] :uri "file:///private/tmp/a.c" :version 2))
jsonrpc-connection-receive(#<eglot-lsp-server eglot-lsp-server-4c135e32> (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:diagnostics [(:code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang") (:code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")] :uri "file:///private/tmp/a.c" :version 2)))
jsonrpc--process-filter(#<process EGLOT (tmp/c-mode)> "Content-Length: 37\15\n\15\n{\"id\":16,\"jsonrpc\":\"2.0\",\"re...")
Can you say when in your LSP log you typed
C-x 4 c
?
I can reproduce this issue. I think what @phst means is : execute M-x, clone-indirect-buffer-other-window
( C-x 4 c ) in test.c
buffer, and will create a test.c<2>
buffer. Then edit thetest.c<2>
buffer you will get error.
I tested it with latest commit of emacs 29.0.50 on macOS, with latest eglot.
I sometimes use indirect buffers to edit a single function and ran into this problem too. Just adding a +1.
emacs -Q -l eglot.el
from a checkout of this repository.LSP transcript - M-x eglot-events-buffer (mandatory unless Emacs inoperable)
Backtrace (mandatory, unless no error message seen or heard):
Minimal configuration (mandatory)
No additional configuration, but ensure that clangd is installed. (The precise language server and version shouldn't matter, this appears to be an Eglot-internal problem.) Then, visit any C/C++ file (/tmp/a.c in my example), clone the buffer with C-x 4 c, and start typing in the cloned buffer. Flymake will immediately signal an error.