0

I'm using recent nightly emacs in Linux/WSL2. I have lsp and lsp-ui, and am using pyright as the python LSP service. (pip install pyright). I like flycheck rather than flymake.

I've been using lsp with typescript for a few years and it works nicely, but I'm not getting good results with lsp+lsp_ui+pyright+flycheck for python code. I mostly just want diagnostics, but signatures & doc are nice too. I've found that the yellow webkit windows disappear after a few seconds, so I don't use those. It seems that child frame on mouse works well for function signatures & doc, but not diagnostics. Diagnostics are what I have most trouble with; I have it configured now for diagnostics in the right sideline (the default) but it only shows some of the errors, not all.

Here's my full config:

;;; Set up package system -- straight.el
(defvar bootstrap-version)
(or (boundp 'native-comp-deferred-compilation-deny-list)
    (setq native-comp-deferred-compilation-deny-list '()))

(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

;;; Meta-package system: use-package. Auto-installs and configures packages.
(straight-use-package 'use-package)
(defvar straight-use-package-by-default)
(setq straight-use-package-by-default t) ; make use-package use straight

(use-package lsp-mode
  :commands lsp
  :hook ((python-mode . lsp)
         )
  :init
  (setq lsp-keymap-prefix "C-c C-l") ; default is super-l
  :config
  (setq lycheck-checker-error-threshold 1000
        lsp-pylsp-plugins-pylint-enabled nil
        )
  )
(use-package lsp-ui)
(use-package lsp-pyright
  :ensure t)

(use-package flycheck)

If you try this (emacs -Q -l test-init.el foo.py) with this foo.py:

def foo(v: int):
    """Test function `foo`"""
    bar(v)
    print(bar(x+))

s="string"
foo(s)
foo(123)

and put the cursor on the foo(s) line, which has a type error, you'll see the red squiggle but it won't show the error in the sideline.

M-x flycheck-list-errors shows all errors including the one that doesn't get shown, and the buffer has the red chevron in the sidebar, so I know it's there.

screenshot

I assume I just need to configure it all better; what am I missing?

GaryO
  • 476
  • 2
  • 16
  • Try to add to your configuration the ```lsp-pyright``` package, which is the client (interface) between emacs and pyright server. See https://github.com/emacs-lsp/lsp-pyright . Take care - if not typing error - see ```lycheck-checker-error-threshold``` which should be ```flycheck-....```. – Ian Apr 06 '22 at 11:42

0 Answers0