Skip to content

rust-mode-treesitter-derive with lsp-mode breaks electric-pair-mode #562

@forgemo

Description

@forgemo

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:

  1. delete .config/emacs/elpa and .config/emacs/eln-cache folder (i didn't delete the .config/emacs/treesitter folder)
  2. Save the above init.el in .config/emacs/init.el
  3. Open a rust file emacs main.rs
  4. Wait for the packages to get installed
  5. Write a few brackets in the rust file to ensure electric-pair is working.
  6. Close emacs
  7. Open the same rust file again
  8. 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

I'm using Kubuntu 24.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions