Closed deb75 closed 3 years ago
Hi,
I think it should be possible to bound lsp-format-buffer
to a custom function calling yapf
. I have it installed together with the palantir language server which is configured to call yapf
when invoking lsp-format-buffer
.
Unfortunately, I am not skilled enough in lisp
to perform that. Should anyone know how to call an external program (python script) and apply it to the current buffer, could provide me an example how to do that.
Try shell-command
function?
Try this snippet or https://github.com/JorisE/yapfify.
(defun lsp-python-ms-format-buffer ()
(interactive)
(when (and (executable-find "yapf") buffer-file-name)
(call-process "yapf" nil nil nil "-i" buffer-file-name)))
(add-hook 'python-mode-hook
(lambda ()
(add-hook 'after-save-hook #'lsp-python-ms-format-buffer t t)))
Thanks, this wonderfully makes the job. I still have to bound this function to C-c l = =
when in a python buffer.
Regards
hello,
I tried
lsp-format-buffer
and it answeers :Can i add a formatter along microsoft language server ?
Regards