zed icon indicating copy to clipboard operation
zed copied to clipboard

Suggest autocomplete options immediately after inserting a period

Open skhaz opened this issue 11 months ago • 13 comments

Check for existing issues

  • [X] Completed

Describe the feature

As can be seen in the images below, the autocomplete only offers me suggestions after I insert a period, and this happens in any language I use daily (Go, Python & TypeScript).

This is quite annoying because it forces you to either read the documentation or start guessing the possible first letters of what you want.

My question is, is there a way to improve this? I come from using VSCode, and there it works 'as expected,' so why is it different in Zed?

In my opinion, this behavior in Zed is not productive.

After pressing period, nothing happens.

Screenshot 2024-03-03 at 11 52 55

Since I know the name of the attribute, I press L and only at that moment does it suggest what I want. Screenshot 2024-03-03 at 11 53 03

If applicable, add mockups / screenshots to help present your vision of the feature

No response

skhaz avatar Mar 03 '24 15:03 skhaz

I'm working in a TS codebase and the behaviour I'm seeing is the suggestion popover appears after showing the intent of accessing a property: inserting a period. The only time it doesn't pop up is when some code is suggested by Copilot.

https://github.com/zed-industries/zed/assets/16290753/a3a54d2d-dccc-4885-b788-7d46095adb7b

Moshyfawn avatar Mar 03 '24 16:03 Moshyfawn

@Moshyfawn, do you have any particular configuration? I haven't changed anything, it is the default installation.

Thank you.

skhaz avatar Mar 03 '24 17:03 skhaz

This has been the case with every configuration I've tried. My current settings are as follows:

{
  "theme": "Rosé Pine",
  "ui_font_size": 14,
  "buffer_font_size": 14,
  "tab_size": 2,
  "show_wrap_guides": true,
  "format_on_save": "language_server",
  "scrollbar": {
    "git_diff": false
  },
  "git": {
    "git_gutter": "tracked_files"
  }
}

Moshyfawn avatar Mar 03 '24 17:03 Moshyfawn

I believe the difference in the behavior you're seeing is due to corresponding language server's CompletionProvider not having a . in its triggerCharacters list.

Spec: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_completion

Here are the only places in Zed codebase we register those trigger characters: https://github.com/zed-industries/zed/blob/7ad714366cedcfa234e942e5032bb5b4c0a4cb0e/crates/project/src/project.rs#L2086-L2096

https://github.com/zed-industries/zed/blob/7ad714366cedcfa234e942e5032bb5b4c0a4cb0e/crates/project/src/project.rs#L3342-L3352

So, while Zed can add some heuristics to trigger more completions, a more appropriate fix seems to belong to corresponding language servers.

SomeoneToIgnore avatar Mar 03 '24 17:03 SomeoneToIgnore

Hm, the problem is: seems that all 3 mentioned servers do have . in their completion providers in main branches:

  • pyright: https://github.com/microsoft/pyright/blob/9dce19cc8761ea8397d41bd7810f52e07f79a252/packages/pyright-internal/src/languageServerBase.ts#L741
  • gopls: https://github.com/golang/tools/blob/5bf7d005299769e9d476813f09efd2a4296d5fe9/gopls/internal/server/general.go#L145
  • typescript-language-server: https://github.com/typescript-language-server/typescript-language-server/blob/b224b878652438bcdd639137a6b1d1a6630129e4/src/lsp-server.ts#L181

So maybe it's Zed's issue, after all: but still, to debug this, one would need to find a case where it reproduces reliably, then

  • check that the completion provider sends back a proper list with .
  • check that, during input (and when no active copilot suggestion exists), check that we determine input's trigger correctly: https://github.com/zed-industries/zed/blob/7ad714366cedcfa234e942e5032bb5b4c0a4cb0e/crates/editor/src/editor.rs#L2897-L2912

SomeoneToIgnore avatar Mar 03 '24 17:03 SomeoneToIgnore

PS. I do not have Copilot, but when I had, I had the same behavior.

skhaz avatar Mar 03 '24 17:03 skhaz

I would really appreciate if somebody can provide the issue with an open source project and the repro steps; or, alternatively if somebody could debug those things locally in the places mentioned above and add more context.

SomeoneToIgnore avatar Mar 03 '24 17:03 SomeoneToIgnore

I can provide tomorrow. It basically does not work in any project to me.I do not have anything on my config and I have installed using homebrew.On 3 Mar 2024, at 14:49, Kirill Bulatov @.***> wrote: I would really appreciate if somebody can provide the issue with an open source project and the repro steps; or, alternatively if somebody could debug those things locally in the places mentioned above and add more context.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

skhaz avatar Mar 03 '24 17:03 skhaz

I use asdf to install the languages that I want use, in this case, NodeJS 18.x

The exactly same setup works for VSCode.

skhaz avatar Mar 03 '24 18:03 skhaz

I am not seeing the same behavior. I am using Python, testing with a random little example:

class Test:

    def __init__(self):
        self.l = [1, 2, 3]

    def add(self, i: int):
        self.l.append(i)

something = Test()

When I type something. I immediately get a suggestions pop-up.

image

I have default configuration for Zed, Python, Pyright, etc. Copilot is disabled.

Unfortunately unable to repro.

alex-astronomer avatar Mar 06 '24 22:03 alex-astronomer

Sometimes works as expected, other no. I have no idea…

skhaz avatar Mar 06 '24 22:03 skhaz

Experiencing the same exact issue here with my TypeScript project. I absolutely need an autocomplete list after pressing . Currently running Zed 0.127.3

Edit: I restarted Zed and now it's working after pressing period? Seems inconsistent. Also worth noting that when I try to autocomplete a method, I'm not getting () automatically inserted. If the method has args, the text cursor should move inside the parens and show a tooltip for the argument the user is on, otherwise, simply move text cursor after parens.

Back to using WebStorm for now.

brenr avatar Mar 21 '24 16:03 brenr

I'm experiencing an issue with autocompletion when Copilot is enabled. Most of the time I see a list of suggested symbols immediately after inserting a period. Sometimes, there's an issue where this list doesn't appear and I have to delete and retype the previous word to get the list to show again. It seems to be a conflict with the autocompletion suggested by Copilot. I can confirm that disabling Copilot resolves this.

Copilot enabled

https://github.com/zed-industries/zed/assets/38229097/e3304f91-a3e4-4066-8273-f06805668d4e

Copilot disabled

https://github.com/zed-industries/zed/assets/38229097/7f5c6035-8323-4fdf-b925-8f75e9a57f5e

I compared with the behaviour of Copilot in VSCode and it hides Copilot suggestions unless the autocomplete list is closed (like with Esc).

cedws avatar Apr 23 '24 21:04 cedws

Should be fixed in Zed 0.135

SomeoneToIgnore avatar May 05 '24 16:05 SomeoneToIgnore

Another option is to use Control + Spacebar. Also, thank you @SomeoneToIgnore !

nrthbound avatar May 14 '24 16:05 nrthbound

I am still experiencing this problem on 0.136.2 and I have to press ctrl+space every single time to get the autocomplete options.

ShayanGsh avatar May 28 '24 09:05 ShayanGsh

It still not working on the newest version... Not sure why was closed.

skhaz avatar May 28 '24 11:05 skhaz

@skhaz

Can you provide more details? Language used; video or, at worst, a text description of the reproduction steps; ideally the project to test this on; the config.

So far, seems to work for me on a sample test project, and the test added also works — so there has to be something else, locally different for you, to trigger the behavior mismatch, or I am doing something wrong to reproduce it.

https://github.com/zed-industries/zed/assets/2690773/a0d3cf0a-eb98-4639-82cd-2182395c555c

SomeoneToIgnore avatar May 28 '24 13:05 SomeoneToIgnore

@SomeoneToIgnore

I tried it on different projects, I have come to realize that it doesn't work on big projects, while it works fine on smaller/medium-sized ones.

I have only tried it with nodejs/typescript, as I don't have any equally big projects in any other languages. When I say a big project, I'm talking over 1000 .ts files, not counting node_modules (it's terrible legacy code)

ShayanGsh avatar May 28 '24 14:05 ShayanGsh

Thank you, that might be https://github.com/zed-industries/zed/issues/4613 and/or https://github.com/zed-industries/zed/issues/5166 in play, so the issue could be closer to completion timeouts rather than the editor elements' logic.

It would be great to get a project to repro it, so if somebody has a public one, feel free to share.

SomeoneToIgnore avatar May 28 '24 14:05 SomeoneToIgnore

just started using zed yesterday and realized this is also happening to me (typescript codebase)

after a restart it works again, until it doesn't

codebase is very small, so it can't be that

atresnjo avatar Jun 08 '24 20:06 atresnjo

I am experiencing the same issue in my ts-server, and the version I am using is 0.139.3.

It seems that something is wrong in ts-server, when I restart the project, it works.

Is there anyway we can check the status for LSP? I will restart LSP when I get the issue, but I don't know the status.

fishel-feng avatar Jun 19 '24 09:06 fishel-feng

Is there a way to open the suggestion window by a keybind?

LukaPelgrom avatar Jun 24 '24 08:06 LukaPelgrom

Is there a way to open the suggestion window by a keybind?

you can try the command editor::ShowCompletions @LukaPelgrom

fishel-feng avatar Jun 24 '24 10:06 fishel-feng

Given the changing of the language server and how this problem persists, I guess it's safe to say it might not be the language server problem. And since ctrl+space works fine (and it's rather fast), I'm guessing upon inserting a period it might not be requesting anything from the language server? Can I see what requests are being made to the language server?

if what I'm saying sounds dumb, I apologize, I'm not familiar with how editors and language servers work.

ShayanGsh avatar Jun 27 '24 08:06 ShayanGsh

I'm new to zed and was experiencing this issue in a Typescript project which lead me here, however after some more testing I found that it is actually working, but with a significant delay.

The delay seems to vary. Sometimes it can be as long as 1-2 seconds, and other times its faster.

VSCode feels basically instant every time, and zed never gets as fast. Using zed and chaining multiple calls together requires a pause every time I type a period, and makes the entire experience feel very sluggish.

Seeing this get fixed would improve the DX significantly!

ryan-saffer avatar Jul 09 '24 07:07 ryan-saffer

I am also experiencing this issue, I do not get autocomplete suggestions unless I manually trigger them with control + space. I am working in a React TypeScript project on MacOS

Traviskn avatar Jul 11 '24 02:07 Traviskn

For anyone that's experiencing this issue you might be able to fix it by uninstalling the language server. If you're using a LSP that Zed downloaded it's located in this directory ~/Library/Application\ Support/Zed/languages/, and if it's an extension try uninstalling and installing the extension.

Anthony-Eid avatar Jul 11 '24 18:07 Anthony-Eid

I'm also having this problem in TypeScript while running Zed v0.143.7 installed via brew (don't know if that's valuable info). Like @Traviskn said, I need to manually trigger the ShowCompletions to pop up

Tazi0 avatar Jul 17 '24 07:07 Tazi0

@Anthony-Eid Thanks, brother. It works! You’re a legend.

Rapithvin avatar Jul 23 '24 03:07 Rapithvin