Use format-all-buffer instead of blacken function; restart lsp
This commit is contained in:
parent
dce7a9dfc5
commit
8266a2c24a
@ -2267,13 +2267,7 @@ A function to run a pipenv-aware python repl:
|
||||
|
||||
Run black on the current buffer:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun blacken ()
|
||||
(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)
|
||||
(general-def 'normal python-mode-map "C-M-\\" #'format-all-buffer)
|
||||
#+END_SRC
|
||||
|
||||
* Hy
|
||||
@ -4782,7 +4776,13 @@ A package that bundles together common code beautifying tools for many languages
|
||||
(use-package format-all
|
||||
:commands (format-all-buffer)
|
||||
: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
|
||||
|
||||
* Compiling
|
||||
|
Loading…
Reference in New Issue
Block a user