zed icon indicating copy to clipboard operation
zed copied to clipboard

Autocompletions very slow

Open patillacode opened this issue 9 months ago • 9 comments

Summary

Autocompletions are very slow. I am testing with Python (both custom snippets and non-snippets)

I am aware that this was talked about in other issues and fixed in https://github.com/zed-industries/zed/pull/19013 although it is still happening.

Couple of examples:

Custom snippet: this is my .config/zed/snippets/python.json file

{
    "property": {
        "prefix": "prop",
        "body": ["@property", "def $1(self):", "    return self.$1"],
        "description": "property"
    }
}

https://github.com/user-attachments/assets/7bdaa51c-f996-4886-a3ee-2e4592e62bf3

Normal Python autocomplete (not a snippet)

https://github.com/user-attachments/assets/2d7d19e1-9dff-4c2b-9511-d99f151baa3a

Steps to trigger the snippets problem:

  1. Define a code snippet 2.Try to use it in a file 3.See slow autocomplete

or for non-snippets:

  1. Just try to write some Python code like class and check the slowness of the autocomplete.

Actual Behavior: Completions are taking >2 seconds

Expected Behavior: Autocompletions should be snappy

Below is my settings.json file where I tried to find a debounce that could be messing with the behaviour but I couldn't find it.

settings.json

Zed Version and System Specs

Zed: v0.178.5 (Zed) OS: macOS 15.3.2 Memory: 32 GiB Architecture: x86_64

patillacode avatar Mar 23 '25 19:03 patillacode

Oh, this is pretty gnarly. Does this happen for all Python projects on your end or just specific ones? Does it happen faithfully whenever you have code snippets available?

JosephTLyons avatar Mar 25 '25 19:03 JosephTLyons

IKR?

To answer your questions:

Does this happen for all Python projects on your end or just specific ones?

It happens on all of the projects, I tried several.

Does it happen faithfully whenever you have code snippets available?

It happens with and without snippets defined.

After a lot of testing I managed to bypass the issue in a way that I am not happy but it works.

The issue is definitely coming from pylsp, I switched to pyright and boom, snappy as expected. Snippets, autocompletion, all good.

Although pyright is not really what I am happy with so I just added a config for it to basically ignore the typing and just use it as a plain LSP.

Having said that, I am not sure why pylsp is that slow, or if it is my setup/config or if it is a Zed thing.

Any recommendations are welcome, maybe I can use yet another LSP for Python if you could recommend one although the issue with pylsp would still remain.

patillacode avatar Mar 26 '25 09:03 patillacode

Hello! Can confirm, started happening after recent updates (updated from 177 to 179 today). LSP auto-completions for python are essentially unusable with pylsp. Works as expected with pyright.

sadaisystems avatar Mar 27 '25 18:03 sadaisystems

Same issue here. To remove pylsp as a workaround:

"languages": {
    "Python": {
      "language_servers": ["!pylsp", "pyright", "ruff"]
    }
}

GraphtyLove avatar Apr 02 '25 11:04 GraphtyLove

"languages": { "Python": { "language_servers": ["!pylsp", "pyright", "ruff"] } }

I remember that the performance issue was solved in some previous versions. Thanks very much that it works!

Hammerklavier-cn avatar Apr 05 '25 13:04 Hammerklavier-cn

"languages": { "Python": { "language_servers": ["!pylsp", "pyright", "ruff"] } }

I remember that the performance issue was solved in some previous versions. Thanks very much that it works!

Still on issue on my side (version 0.180.3)

GraphtyLove avatar Apr 07 '25 16:04 GraphtyLove

Not sure if it's the same issue, but I am working on a TypeScript project (with Svelte) and autocompletions are very slow as well. When I start to type a component name that is in my project it can take up to like 5 seconds to show any import suggestions.

andersmmg avatar May 11 '25 04:05 andersmmg

I wanted to share that I'm using now https://github.com/astral-sh/ty and zed works much better now for me

yabirgb avatar May 15 '25 10:05 yabirgb

Hey @yabirgb

Looks interesting, would you mind sharing your setup?

I would like to give it a go. I am trying to make it work but not sure how to configure and run it properly in Zed.

Thank you for sharing

patillacode avatar May 15 '25 18:05 patillacode

I'm going to go ahead and close this as unactionable. In general slow auto complete it usually because the underlying LSP is slow at returning completions. This may be system / environment / project specific.

If you run into this in the future it may be helpful to open dev: language server logs, select the LSP in question, click "RPC messages" from the dropdown. Then you can see the request coming from Zed and the response from the LSP and you can see the delay. This may also help narrow down which LSP is providing the slow textDocument/completion.

Thanks all.

notpeter avatar Jun 04 '25 20:06 notpeter