Subject: 30.0.91; Eglot (and clangd) out of sync after switching git branches in magit

From: Mikael Springer <[email-masked]>
Date: Thu, 26 Sep 2024 08:20:52 +0000

1. Visit buffer with C++ code -> Eglot starts.
2. Listing references for a variable in Eglot works.
3. Switch Git branch in magit.
4. Go back to C++ buffer. Listing references for a variable using Eglot
does not work, error message in echo buffer; "jsonrpc-request:
jsonrpc-error: "request id=44 failed:", (jsonrpc-error-code . -32602),
(jsonrpc-error-message . "trying to get AST for non-added document"),
(jsonrpc-error-data)"
5. Closing the buffer and opening it again fixes the problem, or doing
eglot-reconnect also fixes the problem, listing references is working
again.
6. This is true for all open C++ buffers handled by Eglot before the
branch switch.

In GNU Emacs 30.0.91 (build 1, aarch64-apple-darwin23.6.0, NS
appkit-2487.70 Version 14.6.1 (Build 23G93)) of 2024-09-16 built on
phobos.local
Windowing system distributor 'Apple', version 10.3.2566
System Description: macOS 15.0

Configured using:
'configure --disable-dependency-tracking --disable-silent-rules
--enable-locallisppath=/opt/homebrew/share/emacs/site-lisp
--infodir=/opt/homebrew/Cellar/emacs-plus@30/30.0.91/share/info/emacs
--prefix=/opt/homebrew/Cellar/emacs-plus@30/30.0.91 --with-xml2
--with-gnutls --with-native-compilation=aot --without-compress-install
--without-dbus --with-imagemagick --with-modules --with-rsvg
--with-webp --with-ns --disable-ns-self-contained 'CFLAGS=-O2
-DFD_SETSIZE=10000 -DDARWIN_UNLIMITED_SELECT
-I/opt/homebrew/opt/gcc/include -I/opt/homebrew/opt/libgccjit/include'
'LDFLAGS=-L/opt/homebrew/lib/gcc/14 -I/opt/homebrew/opt/gcc/include
-I/opt/homebrew/opt/libgccjit/include''

Configured features:
ACL GIF GLIB GMP GNUTLS IMAGEMAGICK JPEG LCMS2 LIBXML2 MODULES
NATIVE_COMP NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM ZLIB

Important settings:
value of $LC_ALL: en_US.UTF-8
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix

Major mode: C++//

Minor modes in effect:
eldoc-box-hover-mode: t
company-box-mode: t
display-line-numbers-mode: t
smartparens-mode: t
rainbow-delimiters-mode: t
yas-minor-mode: t
breadcrumb-mode: t
breadcrumb-local-mode: t
copilot-mode: t
hexl-follow-ascii: t
delete-selection-mode: t
s3ed-mode: t
eglot--managed-mode: t
flymake-mode: t
global-treesit-auto-mode: t
recentf-mode: t
pdf-occur-global-minor-mode: t
google-this-mode: t
which-key-mode: t
treemacs-filewatch-mode: t
treemacs-follow-mode: t
treemacs-git-mode: t
treemacs-fringe-indicator-mode: t
eshell-syntax-highlighting-global-mode: t
git-gutter-mode: t
bug-reference-prog-mode: t
global-git-commit-mode: t
magit-auto-revert-mode: t
server-mode: t
csv-field-index-mode: t
pyvenv-tracking-mode: t
pyvenv-mode: t
pulsar-global-mode: t
pulsar-mode: t
dimmer-mode: t
desktop-save-mode: t
ns-auto-titlebar-mode: t
windmove-mode: t
global-auto-revert-mode: t
save-place-mode: t
global-emojify-mode: t
emojify-mode: t
display-battery-mode: t
doom-modeline-mode: t
company-quickhelp-mode: t
company-quickhelp-local-mode: t
company-mode: t
activities-mode: t
projectile-mode: t
helm-mode: t
helm-minibuffer-history-mode: t
helm-autoresize-mode: t
async-bytecomp-package-mode: t
override-global-mode: t
hl-line-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tab-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
minibuffer-regexp-mode: t
column-number-mode: t
line-number-mode: t
indent-tabs-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t

Load-path shadows:
/Users/mikael/.emacs.d/elpa/cmake-mode-20240814.1725/cmake-mode hides 
/opt/homebrew/share/emacs/site-lisp/cmake/cmake-mode
/Users/mikael/.emacs.d/elpa/transient-20240918.1138/transient hides 
/opt/homebrew/Cellar/emacs-plus@30/30.0.91/share/emacs/30.0.91/lisp/transient 

/Users/mikael/.emacs.d/elpa/editorconfig-20240813.801/editorconfig hides 
/opt/homebrew/Cellar/emacs-plus@30/30.0.91/share/emacs/30.0.91/lisp/editorconfig
/Users/mikael/.emacs.d/elpa/editorconfig-20240813.801/editorconfig-conf-mode 
hides 
/opt/homebrew/Cellar/emacs-plus@30/30.0.91/share/emacs/30.0.91/lisp/editorconfig-conf-mode
/Users/mikael/.emacs.d/elpa/editorconfig-20240813.801/editorconfig-core 
hides 
/opt/homebrew/Cellar/emacs-plus@30/30.0.91/share/emacs/30.0.91/lisp/editorconfig-core
/Users/mikael/.emacs.d/elpa/editorconfig-20240813.801/editorconfig-tools 
hides 
/opt/homebrew/Cellar/emacs-plus@30/30.0.91/share/emacs/30.0.91/lisp/editorconfig-tools
/Users/mikael/.emacs.d/elpa/editorconfig-20240813.801/editorconfig-core-handle 
hides 
/opt/homebrew/Cellar/emacs-plus@30/30.0.91/share/emacs/30.0.91/lisp/editorconfig-core-handle
/Users/mikael/.emacs.d/elpa/editorconfig-20240813.801/editorconfig-fnmatch 
hides 
/opt/homebrew/Cellar/emacs-plus@30/30.0.91/share/emacs/30.0.91/lisp/editorconfig-fnmatch

Features:
(shadow mail-extr emacsbug vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs
vc-rcs log-view magit-extras emacsql-sqlite-builtin sqlite help-fns
radix-tree cl-print transpose-frame winner tramp-archive tramp-gvfs
helm-command helm-elisp helm-eval edebug helm-info heaven-and-hell
noxml-fold rng-cmpct xml-format reformatter rng-nxml rng-valid nxml-mode
nxml-outln nxml-rap sgml-mode elfeed-show elfeed-search elfeed-csv
elfeed elfeed-curl elfeed-log elfeed-db elfeed-lib xml-query sql view
json-mode json-snatcher plantuml-mode vc eldoc-box checkdoc
aggressive-indent company-box company-box-doc frame-local
company-box-icons company-oddmuse company-keywords company-etags
company-gtags company-dabbrev-code company-dabbrev company-files
company-clang company-capf company-cmake company-semantic
company-template company-bbdb display-line-numbers smartparens loadhist
rainbow-delimiters yasnippet-snippets yasnippet breadcrumb copilot
copilot-balancer c++-ts-mode c-ts-mode dape hexl gdb-mi gud repeat
toc-org org-bullets org-appear flyspell ispell org-indent oc-basic
ol-eww ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect gnus-art mm-uu
mml2015 mm-view mml-smime smime dig ol-docview doc-view ol-bibtex bibtex
ol-bbdb ol-w3m ol-doi org-link-doi time delsel ms-remote dired-rsync
rsync-mode spinner ms-ai ms-music spotify ms-devops terraform-doc
terraform-mode hcl-mode ms-aws s3ed s3ed-mode s3ed-io s3ed-util
ms-spelling ms-privacy pinentry ms-math gnuplot info-look ms-eglot
xcscope eglot-hierarchy hierarchy eglot external-completion jsonrpc
flymake ert debug backtrace ms-treesitter treesit-auto ms-draw ms-utils
restclient pandoc-mode pandoc-mode-utils dashboard dashboard-widgets
ffap recentf tree-widget restart-emacs ms-read-write pdf-occur tablist
tablist-filter semantic/wisent/comp semantic/wisent
semantic/wisent/wisent semantic/util-modes semantic/util semantic
semantic/tag semantic/lex semantic/fw mode-local cedet pdf-isearch
pdf-misc pdf-tools cus-edit cus-load pdf-view jka-compr pdf-cache
pdf-info tq pdf-util pdf-macs writeroom-mode visual-fill-column darkroom
ms-browse-and-search ddg-search ddg-mode ddg google-translate
google-translate-default-ui google-translate-core-ui facemenu popup ido
google-translate-core google-translate-backend google-this ms-notebooks
ms-help-docs devdocs-browser eww url-queue mm-url devdocs info-colors
free-keys which-key ms-debug logview datetime extmap ms-news reddigg
promise promise-rejection-tracking promise-finally promise-done
promise-es6-extensions promise-core ms-org ox-confluence ox-jira ox-odt
rng-loc rng-uri rng-parse rng-match rng-pttrn nxml-parse nxml-ns
nxml-enc xmltok nxml-util ox-latex ox-icalendar ox-html table ox-ascii
ox-publish ox org-attach org-sidebar org-ql-search org-ql-view ov
org-super-agenda org-ql peg ts org-habit org-agenda org-duration
org-element org-persist org-id org-refile org-element-ast avl-tree
org-kanban re-builder org-journal org-crypt cal-iso org-jira
org-jira-sdk jiralib soap-client rng-xsd rng-dt rng-util xsd-regexp
org-clock helm-org-rifle ob-ein ein-cell ein-shared-output
ein-output-area ein-kernel ein-ipdb ein-query ein-events ein-websocket
websocket bindat ein-node ewoc ein-log ein-classes ein-core request ein
ein-utils anaphora deferred ob-octave ob-dot ob-sqlite ob-sql
ob-makefile ob-C ob-python python ob-plantuml ob-shell ms-file-browse
all-the-icons-dired ranger dired+ image-file image-converter
dired-subtree dired-hacks-utils dired-aux ls-lisp dirvish treemacs-magit
treemacs-projectile treemacs-all-the-icons treemacs treemacs-header-line
treemacs-compatibility treemacs-mode treemacs-bookmarks treemacs-tags
treemacs-interface treemacs-persistence treemacs-filewatch-mode
treemacs-follow-mode treemacs-rendering treemacs-annotations
treemacs-async treemacs-workspaces treemacs-dom treemacs-visuals
treemacs-fringe-indicator treemacs-macros ms-snippets ms-shell mistty
mistty-undo mistty-queue mistty-log mistty-term mistty-changeset
mistty-util multi-vterm vterm vterm-module term/xterm xterm multi-term
eshell-syntax-highlighting em-prompt em-alias eshell-toggle esh-mode
esh-var eshell-git-prompt eat term disp-table ehelp ms-vc vdiff-magit
magit-ediff ediff ediff-merg ediff-mult ediff-wind ediff-diff ediff-help
ediff-init ediff-util vdiff diffview git-gutter-fringe fringe-helper
git-gutter git-timemachine vc-git vc-dispatcher git-modes gitignore-mode
gitconfig-mode conf-mode gitattributes-mode forge-repos forge-tablist
forge-topics forge-commands forge-semi forge-bitbucket buck forge-gogs
gogs forge-gitea gtea forge-gitlab glab forge-github ghub-graphql treepy
gsexp ghub let-alist forge-notify forge-revnote forge-pullreq
forge-issue forge-topic yaml eieio-custom bug-reference forge-post
markdown-mode forge-repo forge forge-core forge-db magit-lfs
magit-bookmark magit-submodule magit-blame magit-stash magit-reflog
magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote
magit-commit magit-sequence magit-notes magit-worktree magit-tag
magit-merge magit-branch magit-reset magit-files magit-refs magit-status
magit magit-repos magit-apply magit-wip magit-log which-func magit-diff
smerge-mode diff diff-mode track-changes git-commit log-edit pcvs-util
add-log magit-core magit-autorevert magit-margin magit-transient
magit-process with-editor server magit-mode transient benchmark
magit-git magit-base magit-section cursor-sensor crm ms-mode csv-mode
sort ninja-mode cmake-mode rst rtf-mode generic groovy-mode ms-web-env
typescript-mode skewer-mode cache-table js2-mode etags fileloop js
c-ts-common cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs imenu simple-httpd ms-python-env
pylint blacken pydoc goto-addr pyvenv eshell esh-cmd esh-ext esh-opt
esh-proc esh-io esh-arg esh-module esh-module-loaddefs esh-util
ms-flymake ms-dumb-jump ms-editor hydra lv prettier editorconfig
editorconfig-core editorconfig-core-handle editorconfig-fnmatch nvm
iter2 generator bookmark+ bookmark+-key dired-x bookmark+-1 gnus-sum shr
pixel-fill kinsoku url-file svg dom gnus-group gnus-undo gnus-start
gnus-dbus gnus-cloud nnimap nnmail mail-source utf7 nnoo gnus-spec
gnus-int gnus-range gnus-win gnus nnheader range bookmark+-bmu helm-org
org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-src
sh-script smie treesit executable ob-comint org-pcomplete org-list
org-footnote org-faces org-entities noutline outline org-version
ob-emacs-lisp ob-core ob-eval org-cycle org-table ol org-fold
org-fold-core org-keys oc org-loaddefs cal-menu calendar cal-loaddefs
org-compat org-macs bookmark+-lit bookmark+-mac pulsar pulse
auto-highlight-symbol dimmer face-remap color ms-frame desktop frameset
ns-auto-titlebar ms-window golden-ratio windmove ms-buffer autorevert
saveplace vlf-setup vlf vlf-base vlf-tune ms-icons ms-faces emojify
advice apropos tar-mode arc-mode archive-mode ms-themes
doom-themes-ext-treemacs doom-themes-ext-org doom-nord-aurora-theme
doom-themes doom-themes-base ms-modeline diminish battery dbus xml
doom-modeline doom-modeline-segments doom-modeline-env
doom-modeline-core shrink-path ms-company company-quickhelp pos-tip
company ms-projects activities persist bookmark pp helm-rg
ibuffer-projectile helm-projectile tramp-cache time-stamp projectile
lisp-mnt grep compile ibuf-ext ibuffer ibuffer-loaddefs thingatpt
ms-helm helm-xref xref project helm-icons nerd-icons nerd-icons-faces
nerd-icons-data nerd-icons-data-mdicon nerd-icons-data-flicon
nerd-icons-data-codicon nerd-icons-data-devicon nerd-icons-data-sucicon
nerd-icons-data-wicon nerd-icons-data-faicon nerd-icons-data-powerline
nerd-icons-data-octicon nerd-icons-data-pomicon nerd-icons-data-ipsicon
treemacs-icons treemacs-scope treemacs-themes treemacs-core-utils
treemacs-logging treemacs-customization pfuture inline ht treemacs-faces
f s dash helm-mode helm-misc helm-files image-dired image-dired-tags
image-dired-external image-dired-util image-mode exif filenotify
helm-buffers all-the-icons all-the-icons-faces data-material
data-weathericons data-octicons data-fileicons data-faicons
data-alltheicons helm-occur helm-tags helm-locate helm-grep helm-regexp
helm-utils helm-help helm-types ms-env helm-osx-app cl list-processes+
list-environment exec-path-from-shell ms-variables ms-package epkg-elpa
epkg-utils epkg-list epkg-desc wid-edit find-func epkg closql
emacsql-sqlite-common emacsql emacsql-compiler eieio-base llama comp
comp-cstr warnings comp-run comp-common compat helm-system-packages helm
helm-global-bindings edmacro kmacro helm-core async-bytecomp helm-source
helm-multi-match helm-lib async tramp-sh tramp trampver
tramp-integration files-x tramp-message tramp-compat xdg shell pcomplete
comint ansi-osc ring parse-time iso8601 format-spec ansi-color
tramp-loaddefs use-package-ensure-system-package system-packages
use-package use-package-delight use-package-diminish
use-package-bind-key bind-key cl-extra help-mode use-package-ensure
use-package-core finder-inf mm-archive message sendmail yank-media dired
dired-loaddefs rfc822 mml mml-sec epa derived gnus-util
text-property-search time-date mailabbrev gmm-utils mailheader mm-decode
mm-bodies mm-encode mail-utils gnutls network-stream url-cache url-http
url-auth mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums
mail-prsvr url-gw nsm puny epg rfc6068 epg-config a-autoloads
activities-autoloads aggressive-indent-autoloads
all-the-icons-dired-autoloads all-the-icons-ibuffer-autoloads
ansible-autoloads ansible-doc-autoloads apples-mode-autoloads
auto-highlight-symbol-autoloads axe-autoloads blacken-autoloads
breadcrumb-autoloads buffer-move-autoloads bui-autoloads
calibredb-autoloads chatgpt-shell-autoloads cmake-mode-autoloads
company-box-autoloads company-quickhelp-autoloads company-autoloads
copilot-autoloads copilot-chat-autoloads crux-autoloads
csv-mode-autoloads dape-autoloads darkroom-autoloads
dash-at-point-autoloads dashboard-autoloads deadgrep-autoloads
demap-autoloads easy-mmode demap demap-modes hl-line demap-minimap
demap-tools devdocs-autoloads devdocs-browser-autoloads
diffview-autoloads diminish-autoloads dimmer-autoloads
dired-git-info-autoloads dired-narrow-autoloads dired-rsync-autoloads
dired-subtree-autoloads dired-hacks-utils-autoloads dirvish-autoloads
doom-modeline-autoloads doom-themes-autoloads dumb-jump-autoloads
eat-autoloads ein-autoloads deferred-autoloads anaphora-autoloads
eldoc-box-autoloads elfeed-webkit-autoloads elfeed-autoloads
emms-autoloads emojify-autoloads epkg-autoloads
eshell-git-prompt-autoloads eshell-syntax-highlighting-autoloads
eshell-toggle-autoloads exec-path-from-shell-autoloads
expand-region-autoloads faust-mode-autoloads flycheck-plantuml-autoloads
flycheck-autoloads flyspell-correct-helm-autoloads
flyspell-correct-autoloads forge-autoloads closql-autoloads
emacsql-autoloads frame-local-autoloads free-keys-autoloads
ghub-autoloads git-gutter-fringe-autoloads fringe-helper-autoloads
git-gutter-autoloads git-modes-autoloads git-timemachine-autoloads
gnuplot-autoloads golden-ratio-autoloads google-this-autoloads
google-translate-autoloads goto-chg-autoloads gptel-autoloads
groovy-mode-autoloads heaven-and-hell-autoloads
helm-c-yasnippet-autoloads helm-descbinds-autoloads helm-icons-autoloads
helm-make-autoloads helm-org-autoloads helm-easymenu
helm-org-rifle-autoloads helm-osx-app-autoloads
helm-projectile-autoloads helm-rg-autoloads
helm-system-packages-autoloads helm-xref-autoloads helm-autoloads
helm-core-autoloads async-autoloads helpful-autoloads
elisp-refs-autoloads hmac-autoloads ibuffer-projectile-autoloads
info-colors-autoloads ini-mode-autoloads json-mode-autoloads rx
json-snatcher-autoloads list-environment-autoloads llama-autoloads
logview-autoloads datetime-autoloads extmap-autoloads lua-mode-autoloads
magit-lfs-autoloads markdown-mode-autoloads mimetypes-autoloads
minions-autoloads mistty-autoloads multi-term-autoloads
multi-vterm-autoloads nerd-icons-autoloads nov-autoloads esxml-autoloads
kv-autoloads noxml-fold-autoloads ns-auto-titlebar-autoloads
org-appear-autoloads org-bullets-autoloads org-jira-autoloads
org-journal-autoloads org-kanban-autoloads org-sidebar-autoloads
org-ql-autoloads org-super-agenda-autoloads origami-autoloads
ov-autoloads ox-jira-autoloads pandoc-mode-autoloads pdf-tools-autoloads
persist-autoloads pinentry-autoloads plantuml-mode-autoloads
polymode-autoloads popup-autoloads pos-tip-autoloads prettier-autoloads
editorconfig-autoloads nvm-autoloads iter2-autoloads pulsar-autoloads
pydoc-autoloads pylint-autoloads pyvenv-autoloads
rainbow-delimiters-autoloads ranger-autoloads realgud-ipdb-autoloads
realgud-lldb-autoloads realgud-autoloads realgud-recursive-autoloads
loc-changes-autoloads load-relative-autoloads reddigg-autoloads
restart-emacs-autoloads restclient-autoloads rsync-mode-autoloads
rust-mode-autoloads s3ed-autoloads shell-maker-autoloads
shrink-path-autoloads f-autoloads skewer-mode-autoloads
js2-mode-autoloads simple-httpd-autoloads smartparens-autoloads
spinner-autoloads spotify-autoloads string-inflection-autoloads
sublimity-autoloads system-packages-autoloads tablist-autoloads
terraform-doc-autoloads promise-autoloads request-autoloads
terraform-mode-autoloads hcl-mode-autoloads test-simple-autoloads
toc-org-autoloads transpose-frame-autoloads
treemacs-all-the-icons-autoloads all-the-icons-autoloads
treemacs-magit-autoloads treemacs-projectile-autoloads
treemacs-autoloads cfrs-autoloads posframe-autoloads ht-autoloads
pfuture-autoloads ace-window-autoloads avy-autoloads
projectile-autoloads treepy-autoloads treesit-auto-autoloads
ts-autoloads s-autoloads typescript-mode-autoloads uuidgen-autoloads
vdiff-magit-autoloads magit-autoloads pcase transient-autoloads
magit-section-autoloads dash-autoloads vdiff-autoloads hydra-autoloads
lv-autoloads vlf-autoloads vterm-autoloads web-mode-autoloads
websocket-autoloads wfnames-autoloads with-editor-autoloads info
writeroom-mode-autoloads visual-fill-column-autoloads xcscope-autoloads
xml-format-autoloads reformatter-autoloads xmlgen-autoloads
yaml-autoloads yaml-mode-autoloads yapfify-autoloads
yasnippet-snippets-autoloads yasnippet-autoloads package browse-url url
url-proxy url-privacy url-expand url-methods url-history url-cookie
generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs icons password-cache json
subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib
rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/ns-win ns-win
ucs-normalize mule-util term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads kqueue cocoa ns lcms2
multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 3816539 895611) (symbols 48 101299 35)
(strings 32 1940307 58790) (string-bytes 1 156393461)
(vectors 16 219328) (vector-slots 8 3204831 423739)
(floats 8 11561 13488) (intervals 56 61264 8007) (buffers 992 74))