emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.76k stars 879 forks source link

Random regressions due to lsp overriding user settings via `lsp-register-custom-settings` #4420

Open Hi-Angel opened 5 months ago

Hi-Angel commented 5 months ago

Thank you for the bug report

Bug description

Commit 782e1dc15a590ae9aa2c9b7e39c4cc8a65952e13 by @LaurenceWarne introduced a regression and broke mypy completely for me. That happened, because I had set the same lsp-server settings that the commit modified.

Further research shown that there's nothing wrong with the commit per se, instead the problem is in how lsp-mode handles lsp-server settings. Whatever user sets with lsp-register-custom-settings is being overwritten by lsp-mode, leading to random problems like this one.

Instead lsp-register-custom-settings should not overwrite settings that a user has set.

Steps to reproduce

  1. Create /tmp/.emacs with the following content:
    (package-initialize)
    (use-package lsp-mode
      :config
      (setq lsp-log-io t)
      (lsp-register-custom-settings '(("pylsp.plugins.pylsp_mypy.enabled" t t))))
  2. Start emacs as emacs -Q -l /tmp/.emacs test.py
  3. Start lsp-mode in the test.py buffer by evaluating M-x lsp
  4. Switch to buffer with communication log by evaluating M-x lsp-workspace-show-log
  5. Search for word pylsp_mypy and look at the value of enabled just below the pylsp_mypy line

Expected behavior

It is true.

Which Language Server did you use?

pylsp

OS

Linux

Error callstack

No response

Anything else?

No response

Hi-Angel commented 5 months ago

Should be fixed by https://github.com/emacs-lsp/lsp-mode/pull/4421