Cleanup the "Eglot for python-mode" section

This commit is contained in:
Gerard Vermeulen 2023-02-26 10:05:28 +01:00
parent 2feb06bc34
commit 31e60b0ab7

View File

@ -4603,17 +4603,14 @@ ruff "$@" | cat
Listing [[lst:configure-eglot+pylsp-ruff]] configures [[https://github.com/joaotavora/eglot][eglot]] for [[https://www.python.org][Python]] using the
[[https://github.com/python-lsp/python-lsp-server][python-lsp-server]] with the [[https://github.com/python-lsp/python-lsp-ruff#readme][pylsp-ruff]] plugin for the easiest way to let
[[https://github.com/python-lsp/python-lsp-server][python-lsp-server]] use [[https://pypi.org/project/ruff/][Ruff]]. The latest [[https://github.com/python-lsp/python-lsp-server#readme][python-lsp-server]] documentation tells to
configure it for [[https://github.com/PyCQA/flake8][flake8]] as in listing [[lst:configure-eglot+pylsp+flake8]]. In order
to enable all builtin [[https://github.com/python-lsp/python-lsp-server][python-lsp-server]] capabilities, ensure installation of the
Python packages [[https://github.com/hhatto/autopep8#readme][autopep8]], [[https://github.com/PyCQA/flake8][flake8]], [[https://github.com/PyCQA/pydocstyle#readme][pydocstyle]], [[https://github.com/PyCQA/pylint#readme][pylint]], [[https://github.com/python-lsp/python-lsp-server][python-lsp-server]], [[https://github.com/python-rope/rope#readme][rope]],
and [[https://github.com/google/yapf#readme][yapf]]. This method is under investigation (it feels flaky since it shows
some error messages twice).
[[https://github.com/python-lsp/python-lsp-server][python-lsp-server]] use [[https://pypi.org/project/ruff/][Ruff]]. It is better to uninstall the Python packages
[[https://github.com/hhatto/autopep8#readme][autopep8]], [[https://github.com/PyCQA/flake8][flake8]], [[https://github.com/PyCQA/pydocstyle#readme][pydocstyle]], [[https://github.com/PyCQA/pylint#readme][pylint]], and [[https://github.com/python-rope/rope#readme][rope]].
Listing [[lst:eglot-directory-variables-for-python]] shows a proper [[info:emacs#Directory Variables][.dir-locals.el]]
file in the root directory of any [[https://www.python.org][Python]] project to start [[https://github.com/joaotavora/eglot][eglot]] automatically
according to the configuration in listing [[lst:eglot-maybe-ensure]]. Type
{{{kbd(M-x eglot-show-workspace-configuration)}}} to dump a =JSON=
according to the configuration in listing [[lst:eglot-maybe-ensure]].
Type {{{kbd(M-x eglot-show-workspace-configuration)}}} to dump a =JSON=
representation of src_emacs-lisp{eglot-workspace-configuration} for debugging.
The comment in listing [[lst:minimal-eglot-setup][minimal Eglot setup]] also shows how to decrease
or to increase the verbosity of [[https://github.com/python-lsp/python-lsp-server][Python LSP server]] log output for debugging.
@ -4630,39 +4627,11 @@ or to increase the verbosity of [[https://github.com/python-lsp/python-lsp-serve
'(:pylsp (:plugins
(:pylsp_ruff
(:enabled t)
:flake8
:flake8 ;; It is better to uninstall flake8
(:enabled :json-false)
:mccabe
:mccabe ;; It is better to uninstall mccabe
(:enabled :json-false)
:pycodestyle
(:enabled :json-false)
:jedi
(:auto_import_modules ["numpy"])
:jedi_completion
(:cache_for ["astropy"]))))))
#+end_src
#+caption[Configure =eglot= with =python-lsp-server= and the =flake8= plugin]:
#+caption: Configure =eglot= with =python-lsp-server= and the =flake8= plugin.
#+name: lst:configure-eglot+pylsp+flake8
#+begin_src emacs-lisp -n :results silent :tangle no
(with-eval-after-load 'eglot
(setq-default
eglot-workspace-configuration
;; How to use flake8 instead of pycodestyle or ruff, see:
;; https://github.com/python-lsp/python-lsp-server#configuration
'(:pylsp (:configurationSources
["flake8"]
:plugins
(:flake8
(:enabled t)
:mccabe
(:enabled :json-false)
:pycodestyle
(:enabled :json-false)
:pyflakes
(:enabled :json-false)
:pylsp-ruff
:pycodestyle ;; It is better to uninstall pycodestyle
(:enabled :json-false)
:jedi
(:auto_import_modules ["numpy"])
@ -4685,11 +4654,11 @@ or to increase the verbosity of [[https://github.com/python-lsp/python-lsp-serve
. (:pylsp (:plugins
(:pylsp_ruff
(:enabled t)
:flake8
:flake8 ;; It is better to uninstall flake8
(:enabled :json-false)
:mccabe
:mccabe ;; It is better to uninstall mccabe
(:enabled :json-false)
:pycodestyle
:pycodestyle ;; It is better to uninstall pycodestyle
(:enabled :json-false)
:jedi
(:auto_import_modules ["numpy"])