Using ty with lsp-mode

2025-12-05

I’ve been a bit slow to adopt ty in my Emacs config because I was afraid it would be a lot of work to set up. However, it ended up being almost trivial, so I wanted to point that out here. Unlike eglot, lsp-mode handles multiple language servers automatically and out of the box. Further, lsp-mode has shipped with built-in support for ty since very early in ty’s development. The PR adding ty support to lsp-mode landed back in May. So all you need to do to enable ty in Emacs, alongside other language servers like Ruff, is to install it! lsp-mode will activate it automatically if it finds ty in your PATH.

The default lsp-python-ty-clients-server-command is '("ty" "server"), so if you want to run ty with uvx, for example, instead of installing it somewhere on your PATH, you may need to set this to something like:

(setq lsp-python-ty-clients-server-command '("uvx" "ty" "server"))

For me, I had an old installation of pylsp sitting around, so I also had to set:

(setq lsp-disabled-clients '(pylsp))

to make sure I was only using ty and Ruff.

To confirm that this was the case, I also learned about the very helpful lsp-describe-session command, which produces a buffer like this:

[-] /home/brent/Projects/advent25
 |-[-] ty-ls:1350600
 |  |-[-] Buffers
 |  |  `-[+] day1.py
 |  `-[+] Capabilities
 `-[-] ruff:1350599
    |-[-] Buffers
    |  `-[+] day1.py
    `-[+] Capabilities

(You might be able to spot that I ran this in my Advent of Code 2025 repo).