Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python buffers cannot be formatted on saving if python-formatter is 'lsp #16632

Open
JohnADawson opened this issue Oct 30, 2024 · 0 comments
Open

Comments

@JohnADawson
Copy link

Description :octocat:

The Python layer's documentation states

To enable automatic buffer formatting on save set the variable python-format-on-save to t. The formatter specified by python-formatter will be used.

https://develop.spacemacs.org/layers/+lang/python/README.html#automatic-buffer-formatting-on-save

But Python buffers are not formatted on saving when python-format-on-save is t and python-formatter is 'lsp (even if SPC m = = and SPC m = b do format the buffer).

Reproduction guide 🪲

  • In Bash run
mkdir ~/Documents/play
cd ~/Documents/play
python3 -m venv .venv
source .venv/bin/activate
pip install python-lsp-server ruff
  • In .spacemacs put
(setq-default
 dotspacemacs-configuration-layers
 '((python :variables
           python-format-on-save t
           python-formatter 'lsp)
   lsp))
  • Restart Emacs.
  • Do SPC f f ~/Documents/play/play.py.
  • If prompted choose the project of play.py.
  • Write x=['a' ].
  • Do SPC f s

Observed behaviour: 👀 💔
x=['a' ] remains unchanged.

Expected behaviour: ❤️ 😄
x=['a' ] becomes x = ["a"]. (This is the change effected by SPC m = = or SPC m = b.)

System Info 💻

  • OS: gnu/linux
  • Emacs: 29.3
  • Spacemacs: 0.999.0
  • Spacemacs branch: develop (rev. 4d7be22)
  • Graphic display: t
  • Running in daemon: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
((python :variables python-format-on-save t python-formatter 'lsp)
 emacs-lisp helm lsp multiple-cursors treemacs)
  • System configuration features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant