You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rust-mode-treesitter-derive with lsp-mode breaks electric-pair-mode #562
I noticed that electric-pair-mode stopped working in rust files.
After a few hours of investigation, I was able to narrow it down to using treesitter with rust-mode-treesitter-derive.
The difficulty was, that it breaks it only after the second emacs start (after a fresh install).
Here is a minimal example to reproduce the issue:
(require'package)
(setq package-archives '(("melpa"."https://melpa.org/packages/")
("gnu"."https://elpa.gnu.org/packages/")))
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require'use-package)
(setq use-package-always-ensure t)
(electric-pair-mode 1) ;; this stops working after the second emacs start
(use-package rust-mode
:hook (rust-mode . lsp-deferred)
:init
(setq rust-mode-treesitter-derive t) ;; this causes the bug:config
(setq rust-format-on-save nil))
(use-package lsp-mode)
My test protocol was:
delete .config/emacs/elpa and .config/emacs/eln-cache folder (i didn't delete the .config/emacs/treesitter folder)
Save the above init.el in .config/emacs/init.el
Open a rust file emacs main.rs
Wait for the packages to get installed
Write a few brackets in the rust file to ensure electric-pair is working.
Close emacs
Open the same rust file again
Write a few brackets in the rust file. electric-pair is no more working. 🐛
ls ~/.config/emacs/elpa
lv-20200507.1518 s-20220902.1511
dash-20240510.1327 ht-20230703.558 markdown-mode-20240829.324 spinner-1.7.4
f-20241003.1131 lsp-mode-20241015.1503 rust-mode-20240903.1233 spinner-1.7.4.signed
emacs --version
GNU Emacs 29.4
Activity
nealsid commentedon Jun 18, 2025
Can you add the output of
C-h v electric-pair-modeandC-h v post-self-insert-hookin a buffer whereelectric-pair-modeis not working?