Use format-all-buffer instead of blacken function; restart lsp

This commit is contained in:
Jeremy Dormitzer 2020-01-30 10:49:03 -05:00
parent dce7a9dfc5
commit 8266a2c24a

View File

@ -2267,13 +2267,7 @@ A function to run a pipenv-aware python repl:
Run black on the current buffer: Run black on the current buffer:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun blacken () (general-def 'normal python-mode-map "C-M-\\" #'format-all-buffer)
(interactive)
(let ((start (if (use-region-p) (region-beginning) (point-min)))
(end (if (use-region-p) (region-end) (point-max))))
(shell-command-on-region start end "black -q -" nil t)))
(general-def 'normal python-mode-map "C-M-\\" #'blacken)
#+END_SRC #+END_SRC
* Hy * Hy
@ -4782,7 +4776,13 @@ A package that bundles together common code beautifying tools for many languages
(use-package format-all (use-package format-all
:commands (format-all-buffer) :commands (format-all-buffer)
:init :init
(leader-def-key "cf" 'format-all-buffer)) (leader-def-key "cf" 'format-all-buffer)
:config
(with-eval-after-load 'lsp-mode
(add-hook 'format-all-after-format-functions
(lambda (formatter status)
(when lsp-mode
(lsp-restart-workspace))))))
#+END_SRC #+END_SRC
* Compiling * Compiling