Document botched attempt to configure eglot without pyls-flake8

This commit is contained in:
Gerard Vermeulen 2022-06-14 05:54:19 +02:00
parent 1807a3e369
commit cf9344ecfd

View File

@ -3182,7 +3182,9 @@ Listing [[lst:configure-eglot+python-lsp-server-for-python]] tangles to
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-rope/rope#readme][rope]],
and [[https://github.com/google/yapf#readme][yapf]]. In addition, install the [[https://github.com/emanspeaks/pyls-flake8#readme][pyls-flake8]] plugin to let [[https://github.com/python-lsp/python-lsp-server][python-lsp-server]]
use [[https://github.com/PyCQA/flake8][flake8]].
use [[https://github.com/PyCQA/flake8][flake8]]. The latest [[https://github.com/python-lsp/python-lsp-server#readme][python-lsp-server]] documentation tells to let it use
[[https://github.com/PyCQA/flake8][flake8]] as in [[lst:broken-configure-eglot+python-lsp-server-for-python]], but it
does not work.
Listing [[lst:on-hack-local-variables-hook-eglot-maybe]] defines a hook function to
launch [[https://github.com/joaotavora/eglot][eglot]] in presence of a proper [[info:emacs#Directory Variables][.dir-locals.el]] file in the root directory
@ -3194,21 +3196,39 @@ such a proper [[info:emacs#Directory Variables][.dir-locals.el]] file.
#+name: lst:configure-eglot+python-lsp-server-for-python
#+begin_src emacs-lisp
(with-eval-after-load 'eglot
;; (setq eglot-server-programs '((python-mode "pylsp")))
(add-to-list 'eglot-server-programs '(python-mode "pylsp"))
(setq-default
eglot-workspace-configuration
'(;; Disable the `:pyls_flake8' plugin to fall back to pycodestyle.
(:pylsp . (:plugins (:pyls_flake8 (:enabled t))))
(:pylsp . (:plugins (:jedi_completion (:cache_for ["astropy"]))))
(:pylsp . (:plugins (:jedi (:auto_import_modules ["numpy"]))))))
(:pylsp . (:plugins (:jedi (:auto_import_modules ["numpy"])))))
(:pylsp . (:plugins (:jedi_completion (:cache_for ["astropy"])))))
(define-key eglot-mode-map (kbd "C-c n") #'flymake-goto-next-error)
(define-key eglot-mode-map (kbd "C-c p") #'flymake-goto-prev-error)
(define-key eglot-mode-map (kbd "C-c r") 'eglot-rename))
#+end_src
#+caption[Broken configure =eglot= with =python-lsp-server= for Python]:
#+caption: Broken configure =eglot= with =python-lsp-server= for Python.
#+name: lst:broken-configure-eglot+python-lsp-server-for-python
#+begin_src emacs-lisp :tangle no
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs '(python-mode "pylsp" "-vvv"))
(setq-default
eglot-workspace-configuration
'(;; To use flake8 instead of pycodestyle, see:
;; https://github.com/python-lsp/python-lsp-server#configuration
(:pylsp . (:configurationSources ["flake8"]))
(:pylsp . (:plugins (:pycodestyle (:enabled :json-false))))
(:pylsp . (:plugins (:mccabe (:enabled :json-false))))
(:pylsp . (:plugins (:pyflakes (:enabled :json-false))))
(:pylsp . (:plugins (:flake8 (:enabled t))))
(:pylsp . (:plugins (:jedi (:auto_import_modules ["numpy"]))))
(:pylsp . (:plugins (:jedi_completion (:cache_for ["astropy"])))))))
#+end_src
#+caption[Start =eglot= in case of a proper =dir-local-variables-alist=]:
#+caption: Start =eglot= in case of a proper =dir-local-variables-alist=.
#+name: lst:on-hack-local-variables-hook-eglot-maybe