Subject: 30.0.50; eglot with pyright breaks completion-at-point

From: dalanicolai <[email-masked]>
Date: Thu, 6 Apr 2023 20:54:35 +0200

I am not sure in how far this can be called a bug, but I guess it could
be considered a genuine one.

I am happy to provide a recipe, but I think in this case it just
'complicates' the bug report. So I will describe the behavior and my
observations.

Without eglot, when in a python buffer, we can start an inferior shell
and send code to the sell to get completion-at-point (via the
python-completion-at-point completion function). This functionality is
working fine, also for functions that become available after importing
some module (in my case the 'fitz' module from the pymupdf library).

But after activating eglot, with the freshly updated pyright-langserver
(v. 1.1.302), the completion does not work anymore, because
eglot-completion-at-point function is added before the
python-completion-at-point-function in the completion-at-point-functions
list (the completion can be fixed by changing the order of these two
functions in that list).

I should mention that it only partly breaks completion at point. For
example, eglot-completion-at-point does work for functions from e.g. the
'os' module (even without sending the 'import os' line to the inferior
shell). But for functions from the fitz module,
eglot-completion-at-point does not work (present candidates), while the
completion does work when using the python-completion-at-point function.
Unfortunately, eglot-completion-at-point 'hijacks' the completion, and
python-completion-at-point never gets called.

finally when trying to complete the function from the fitz module then
the message(s) in the eglot event buffer looks as follows

(:jsonrpc "2.0" :id 32 :method "textDocument/completion" :params
 (:textDocument
  (:uri
"file:///home/dalanicolai/git/emacs-doc-tools-pymupdf/doc-pymupdf-epc-server.py")
  :position
  (:line 13 :character 8)
  :context
  (:triggerKind 1)))
[server-reply] (id:32) Thu Apr  6 20:47:43 2023:
(:jsonrpc "2.0" :id 32 :result
 (:items
  []
  :isIncomplete t))

while when trying to complete a function from the os module, the message
looks as follows

(:jsonrpc "2.0" :id 57 :method "textDocument/completion" :params
 (:textDocument
  (:uri
"file:///home/dalanicolai/git/emacs-doc-tools-pymupdf/doc-pymupdf-epc-server.py")
  :position
  (:line 15 :character 5)
  :context
  (:triggerKind 1)))
[server-reply] (id:57) Thu Apr  6 20:50:16 2023:
(:jsonrpc "2.0" :id 57 :result
 (:items
  [(:label "__package__" :kind 6 :data
   (:workspacePath "/home/dalanicolai/git/emacs-doc-tools-pymupdf"
:filePath
"/home/dalanicolai/git/emacs-doc-tools-pymupdf/doc-pymupdf-epc-server.py"
:position
   (:line 15 :character 5)
   :funcParensDisabled t :symbolLabel "__package__")
   :sortText "11.9999.__package__")
   (:label "__path__" :kind 6 :data
   (:workspacePath "/home/dalanicolai/git/emacs-doc-tools-pymupdf"
:filePath
"/home/dalanicolai/git/emacs-doc-tools-pymupdf/doc-pymupdf-epc-server.py"
:position
   (:line 15 :character 5)
   :funcParensDisabled t :symbolLabel "__path__")
   :sortText "11.9999.__path__")
   (:label "_path" :kind 9 :data
   (:workspacePath "/home/dalanicolai/git/emacs-doc-tools-pymupdf"
:filePath
"/home/dalanicolai/git/emacs-doc-tools-pymupdf/doc-pymupdf-epc-server.py"
:position
   (:line 15 :character 5)
   :funcParensDisabled t :symbolLabel "_path")
   :sortText "09.9999._path")
   (:label "path" :kind 6 :data
   (:workspacePath "/home/dalanicolai/git/emacs-doc-tools-pymupdf"
:filePath
"/home/dalanicolai/git/emacs-doc-tools-pymupdf/doc-pymupdf-epc-server.py"
:position
   (:line 15 :character 5)
   :funcParensDisabled t :symbolLabel "path")
   :sortText "09.9999.path")

etc.

Of course I am happy to provide any more info if desired.
Thank you!

In GNU Emacs 30.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version
 3.24.37, cairo version 1.17.6) of 2023-04-02 built on fedora
Repository revision: dec09aaeb616e7648f4694d76090cc8e269471e0
Repository branch: master
System Description: Fedora Linux 37 (Workstation Edition)

Configured using:
 'configure --with-pgtk --with-modules --with-cairo
 --with-native-compilation --with-json'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBSELINUX LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PGTK PNG
RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER
XIM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Python

Minor modes in effect:
  eglot--managed-mode: t
  flymake-mode: t
  outline-minor-mode: t
  shell-dirtrack-mode: t
  global-hl-todo-mode: t
  hl-todo-mode: t
  vertico-mode: t
  ivy-rich-mode: t
  counsel-mode: t
  ivy-mode: t
  smartparens-global-mode: t
  smartparens-mode: t
  global-evil-surround-mode: t
  evil-surround-mode: t
  global-evil-collection-unimpaired-mode: t
  evil-collection-unimpaired-mode: t
  which-key-mode: t
  evil-mode: t
  evil-local-mode: t
  recentf-mode: t
  savehist-mode: t
  server-mode: t
  global-tab-line-mode: t
  tab-line-mode: t
  auto-insert-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/dalanicolai/.config/emacs/elpa/transient-20230315.1520/transient
hides /home/dalanicolai/git/emacs/lisp/transient
/home/dalanicolai/.config/emacs/elpa/eglot-20221020.1010/eglot hides
/home/dalanicolai/git/emacs/lisp/progmodes/eglot
/home/dalanicolai/.config/emacs/elpa/project-0.9.8/project hides
/home/dalanicolai/git/emacs/lisp/progmodes/project

Features:
(shadow sort flyspell ispell mail-extr emacsbug message yank-media
rfc822 mml mml-sec evil-collection-epa epa epg rfc6068 epg-config
gnus-util mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader
sendmail mail-utils find-dired evil-collection-grep grep
evil-collection-eglot eglot array evil-collection-ert ert ewoc
evil-collection-debug debug backtrace filenotify jsonrpc
evil-collection-flymake flymake-proc flymake evil-collection-imenu imenu
mule-util evil-collection-vc-git vc-git evil-collection-diff-mode
diff-mode vc-dispatcher evil-collection-custom cus-edit cus-start
cus-load ement-autoloads svg-lib-autoloads taxy-magit-section-autoloads
taxy-autoloads plz-autoloads ox-moderncv org-cv-utils ox-odt rng-loc
rng-uri rng-parse rng-match rng-dt rng-util rng-pttrn nxml-parse nxml-ns
nxml-enc xmltok nxml-util ox-latex ox-icalendar org-agenda ox-html table
ox-ascii ox-publish ox org-element org-persist org-id org-refile
ob-python evil-collection-python python treesit evil-collection-org org
org-macro org-pcomplete org-list org-footnote org-faces org-entities
evil-collection-outline noutline outline ob-emacs-lisp org-table
org-loaddefs find-func evil-collection-calendar cal-menu calendar
cal-loaddefs avl-tree generator ob-jupyter jupyter-tramp tramp-cache
time-stamp tramp tramp-loaddefs trampver tramp-integration files-x
tramp-compat shell pcomplete parse-time iso8601 time-date ls-lisp
jupyter-server jupyter-server-ioloop jupyter-ioloop-comm jupyter-ioloop
zmq zmq-core jupyter-rest-api url-http url-auth mail-parse rfc2231
rfc2047 rfc2045 mm-util ietf-drums mail-prsvr url-gw nsm
jupyter-org-extensions jupyter-org-client ob ob-tangle ol org-src ob-ref
ob-lob ob-table ob-exp ob-comint ob-core org-cycle org-fold
org-fold-core ob-eval org-keys oc org-compat org-version org-macs
format-spec jupyter-repl easy-mmode derived jupyter-kernel-manager
jupyter-channel jupyter-widget-client websocket bindat simple-httpd pp
jupyter-client jupyter-comm-layer jupyter-messages hmac-def jupyter-mime
shr pixel-fill kinsoku url-file puny svg xml dom jupyter-kernelspec
jupyter-env jupyter-base eieio-base jupyter-autoloads
websocket-autoloads simple-httpd-autoloads zmq-autoloads fasd-autoloads
hl-todo hl-todo-autoloads imenu-list-autoloads org-wc-autoloads
all-the-icons-autoloads mastodon-autoloads ts-autoloads s-autoloads
persist-autoloads request-autoloads vterm-autoloads evil-iedit-state
iedit iedit-lib evil-iedit-state-autoloads iedit-autoloads ladebug
doc-tools-autoloads epc-autoloads ctable-autoloads concurrent-autoloads
deferred-autoloads org-journal-autoloads rg-autoloads wgrep-autoloads
magit-autoloads magit-section-autoloads git-commit-autoloads
with-editor-autoloads transient-autoloads eglot-autoloads
project-autoloads evil-collection-vertico vertico compat
consult-autoloads vertico-autoloads ivy-rich counsel xdg
evil-collection-xref xref project evil-collection-compile compile
text-property-search evil-collection-comint comint ansi-osc ansi-color
swiper evil-collection-ivy ivy delsel ivy-faces ivy-overlay colir color
ivy-rich-autoloads counsel-autoloads swiper-autoloads ivy-autoloads
htmlize-autoloads org-superstar-autoloads smartparens loadhist dash
smartparens-autoloads dash-autoloads evil-surround
evil-surround-autoloads evil-collection-unimpaired
evil-collection-which-key evil-collection-tabulated-list
evil-collection-tab-bar evil-collection-simple evil-collection-replace
evil-collection-process-menu evil-collection-package-menu
evil-collection-info evil-collection-indent evil-collection-image
image-mode evil-collection-dired dired dired-loaddefs exif
evil-collection-help evil-collection-elisp-mode evil-collection-eldoc
evil-collection-buff-menu evil-collection annalist
evil-collection-autoloads annalist-autoloads kill-file-path
kill-file-path-autoloads link-hint-autoloads avy-autoloads
embark-autoloads compat-autoloads which-key which-key-autoloads
spacemacs-dark-theme spacemacs-common spacemacs-theme-autoloads
finder-inf pcase evil evil-integration evil-maps evil-commands reveal
evil-jumps evil-command-window evil-search evil-ex evil-types
evil-macros evil-repeat evil-states evil-core comp comp-cstr warnings
icons rx cl-extra help-mode advice evil-common thingatpt rect
evil-digraphs evil-vars ring edmacro kmacro info evil-autoloads
goto-chg-autoloads recentf tree-widget wid-edit savehist server tab-line
autoinsert package browse-url url url-proxy url-privacy url-expand
url-methods url-history url-cookie generate-lisp-file url-domsuf
url-util mailcap url-handlers url-parse auth-source cl-seq eieio
eieio-core cl-macs password-cache json subr-x map byte-opt gv bytecomp
byte-compile url-vars cl-loaddefs cl-lib rmc iso-transl tooltip cconv
eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/pgtk-win pgtk-win term/common-win pgtk-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq
simple cl-generic indonesian philippine cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button
loaddefs theme-loaddefs faces cus-face macroexp files window
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget keymap hashtable-print-readable backquote threads dbusbind
inotify dynamic-setting system-font-setting font-render-setting cairo
gtk pgtk multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 694707 57076)
 (symbols 48 41849 1)
 (strings 32 174124 8435)
 (string-bytes 1 5791434)
 (vectors 16 71345)
 (vector-slots 8 1288960 34132)
 (floats 8 413 270)
 (intervals 56 1763 0)
 (buffers 984 22))