Subject: [PATCH] 31.0.50; eglot.el does not support pyrefly LSP server (python)

From: Jostein Kjønigsen <[email-masked]>
Date: Mon, 19 May 2025 10:04:18 +0200

Hey everyone.

There's a new, fast combined type-checker and LSP-server available for Python called "pyrefly". The source can be found here:
https://github.com/facebook/pyrefly

Currently it's not possible to use this LSP-server with eglot, due to missing configuration.

Attached is a patch which fixes this.

--
Kind regards
Jostein

￼

In GNU Emacs 31.0.50 (build 5, aarch64-apple-darwin24.4.0, NS
 appkit-2575.50 Version 15.4.1 (Build 24E263)) of 2025-05-11 built on
 SOK67R3KWV97
Repository revision: 72ec1c2da4e6108175fc93e33ec92eec4bd1296e
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2575
System Description:  macOS 15.4.1

Configured using:
 'configure --with-tree-sitter --with-native-compilation
 --with-imagemagick --with-harfbuzz
 PKG_CONFIG_PATH=:/usr/local/lib/pkgconfig:/opt/local/lib/pkgconfig'

Configured features:
ACL GLIB GNUTLS IMAGEMAGICK LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY
KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP XIM ZLIB

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LC_CTYPE: UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Elisp/l

Minor modes in effect:
  bug-reference-prog-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  pyvenv-tracking-mode: t
  elisp-slime-nav-mode: t
  paredit-mode: t
  highlight-symbol-mode: t
  flycheck-mode: t
  indent-bars-mode: t
  completion-preview-mode: t
  delete-selection-mode: t
  global-auto-revert-mode: t
  editorconfig-mode: t
  all-the-icons-completion-mode: t
  marginalia-mode: t
  vertico-mode: t
  global-nlinum-mode: t
  nlinum-mode: t
  override-global-mode: t
  server-mode: t
  global-hl-line-mode: t
  pixel-scroll-precision-mode: t
  doom-modeline-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  hs-minor-mode: t

Load-path shadows:
/Users/josteink/.emacs.d/elpa/ef-themes-1.9.0/theme-loaddefs hides /Users/josteink/.emacs.d/elpa/modus-themes-20250220.647/theme-loaddefs
/Users/josteink/.emacs.d/elpa/transient-20250301.2218/transient hides /Users/josteink/build/emacs/lisp/transient
/Users/josteink/.emacs.d/elpa/ef-themes-1.9.0/theme-loaddefs hides /Users/josteink/build/emacs/lisp/theme-loaddefs

Features:
(shadow sort mail-extr emacsbug lisp-mnt whitespace js toml-ts-mode
dockerfile-ts-mode yaml-ts-mode magit-patch magit-subtree
magit-gitignore magit-ediff ediff ediff-merg ediff-mult ediff-wind
ediff-diff ediff-help ediff-init ediff-util shr-color textsec
uni-scripts idna-mapping uni-confusable textsec-check network-stream
url-http url-gw nsm url-cache url-auth sql view em-unix em-term term
ehelp em-script em-prompt em-pred em-ls em-hist em-glob em-extpipe
em-cmpl em-dirs em-basic em-banner em-alias esh-mode esh-var macros
consult-imenu tabify conf-mode make-mode json-ts-mode ido rng-xsd
xsd-regexp rng-cmpct rng-nxml rng-valid rng-loc rng-uri rng-parse
nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns nxml-mode
nxml-outln nxml-rap nxml-util nxml-enc xmltok dired-aux goto-addr
git-rebase magit-extras vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs
log-view vc bug-reference misearch multi-isearch csharp-mode c-ts-common
cc-langs cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align
cc-engine cc-vars cc-defs magit-bookmark magit-submodule magit-blame
magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch
magit-clone magit-remote magit-commit magit-sequence magit-notes
magit-worktree magit-tag magit-merge magit-branch magit-reset
magit-files magit-refs magit-status magit magit-repos magit-apply
magit-wip magit-log which-func magit-diff smerge-mode git-commit
log-edit pcvs-util add-log magit-core magit-autorevert magit-margin
magit-transient magit-process with-editor magit-mode benchmark magit-git
magit-base magit-section cursor-sensor crm llama markdown-mode
edit-indirect pyvenv eshell esh-cmd esh-ext esh-proc esh-opt esh-io
esh-arg esh-module esh-module-loaddefs esh-util help-fns radix-tree pet
let-alist elec-pair vc-git vc-dispatcher pulse disp-table oc-basic
ol-eww ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect gnus-art mm-uu
mml2015 mm-view mml-smime smime gnutls dig gnus-sum gnus-group gnus-undo
gnus-start gnus-dbus dbus gnus-cloud nnimap nnmail mail-source utf7 nnoo
gnus-spec gnus-int gnus-range message sendmail yank-media rfc822 mml
mml-sec epa derived epg rfc6068 epg-config mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev gmm-utils
mailheader gnus-win ol-docview doc-view jka-compr image-mode exif dired
dired-loaddefs ol-bibtex bibtex ol-bbdb ol-w3m ol-doi org-link-doi
org-agenda elisp-slime-nav etags fileloop paredit highlight-symbol
flycheck indent-bars-ts indent-bars cus-edit cus-start cus-load
face-remap color powershell eglot tree-widget external-completion
jsonrpc flymake diff ert ewoc debug backtrace completion-preview
hideshow eww vtable url-queue shr pixel-fill kinsoku url-file svg xml
puny mm-url gnus nnheader gnus-util mail-utils range wid-edit mm-util
mail-prsvr tramp trampver tramp-integration tramp-message tramp-compat
shell parse-time iso8601 tramp-loaddefs imenu ob-plantuml delsel
autorevert filenotify embark-org org-element org-persist org-id
org-refile org-element-ast inline avl-tree org ob ob-tangle ob-ref
ob-lob ob-table ob-exp org-macro org-src sh-script smie executable
ob-comint org-pcomplete pcomplete org-list org-footnote org-faces
org-entities noutline outline org-version ob-emacs-lisp ob-core ob-eval
org-cycle org-table ol org-fold org-fold-core org-keys oc org-loaddefs
find-func cal-menu calendar cal-loaddefs org-compat org-macs
bicep-ts-mode editorconfig editorconfig-core editorconfig-core-handle
editorconfig-fnmatch embark-consult consult bookmark embark ffap
orderless all-the-icons-completion marginalia vertico nlinum linum
use-package-bind-key bind-key server hl-line pixel-scroll cua-base
all-the-icons all-the-icons-faces data-material data-weathericons
data-octicons data-fileicons data-faicons data-alltheicons doom-modeline
doom-modeline-segments doom-modeline-env doom-modeline-core shrink-path
f s dash nerd-icons nerd-icons-faces nerd-icons-data
nerd-icons-data-mdicon nerd-icons-data-flicon nerd-icons-data-codicon
nerd-icons-data-devicon nerd-icons-data-sucicon nerd-icons-data-wicon
nerd-icons-data-faicon nerd-icons-data-powerline nerd-icons-data-octicon
nerd-icons-data-pomicon nerd-icons-data-ipsicon dracula-theme
use-package-ensure use-package-core finder-inf
all-the-icons-completion-autoloads all-the-icons-autoloads
bicep-ts-mode-autoloads bmx-mode-autoloads cargo-autoloads
cmake-mode-autoloads color-theme-sanityinc-tomorrow-autoloads
combobulate-autoloads combobulate-go combobulate-json combobulate-yaml
combobulate-css combobulate-js-ts combobulate-python combobulate-html
combobulate-toml combobulate-cursor multiple-cursors
mc-separate-operations rectangular-region-mode mc-mark-pop mc-edit-lines
mc-hide-unmatched-lines-mode mc-mark-more sgml-mode facemenu dom
thingatpt mc-cycle-cursors multiple-cursors-core advice compile
text-property-search time-date comp comp-cstr cl-extra help-mode
warnings comp-run comp-common rect combobulate-query savehist xref
files-x scheme combobulate-ui transient pp format-spec edmacro kmacro
combobulate-display combobulate-ztree combobulate-envelope
combobulate-manipulation python rx project compat comint ansi-osc ring
ansi-color combobulate-procedure combobulate-navigation combobulate-misc
combobulate-setup tempo combobulate-interface combobulate-settings
diff-mode track-changes easy-mmode treesit generator combobulate-rules
company-autoloads copilot-mode-autoloads crontab-mode-autoloads
dap-mode-autoloads bui-autoloads doom-modeline-autoloads
doom-themes-autoloads dracula-theme-autoloads edit-indirect-autoloads
ef-themes-autoloads elisp-slime-nav-autoloads embark-consult-autoloads
consult-autoloads embark-autoloads expand-region-autoloads
flycheck-autoloads highlight-symbol-autoloads indent-bars-autoloads
lsp-docker-autoloads lsp-treemacs-autoloads lsp-mode-autoloads
magit-autoloads pcase magit-section-autoloads llama-autoloads
marginalia-autoloads markdown-mode-autoloads modus-themes-autoloads
multiple-cursors-autoloads nerd-icons-autoloads nlinum-autoloads
orderless-autoloads paredit-autoloads pet-autoloads poetry-autoloads
powershell-autoloads pyvenv-autoloads shrink-path-autoloads f-autoloads
spinner-autoloads transient-autoloads treemacs-autoloads cfrs-autoloads
posframe-autoloads ht-autoloads hydra-autoloads lv-autoloads
pfuture-autoloads ace-window-autoloads avy-autoloads s-autoloads
dash-autoloads undo-tree-autoloads queue-autoloads vertico-autoloads
wgrep-autoloads info with-editor-autoloads wsd-mode-autoloads
yaml-autoloads package browse-url xdg 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 icons 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/ns-win ns-win ucs-normalize
mule-util term/common-win 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 kqueue cocoa ns lcms2 multi-tty make-network-process
tty-child-frames native-compile emacs)

Memory information:
((conses 16 2447555 344847) (symbols 48 66002 446)
 (strings 32 489686 14498) (string-bytes 1 14263771)
 (vectors 16 207782) (vector-slots 8 2952963 361044)
 (floats 8 6404 19011) (intervals 56 167341 9068) (buffers 1064 146))