Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggest autocomplete options immediately after inserting a period #8766

Open
1 task done
skhaz opened this issue Mar 3, 2024 · 58 comments · Fixed by #11401
Open
1 task done

Suggest autocomplete options immediately after inserting a period #8766

skhaz opened this issue Mar 3, 2024 · 58 comments · Fixed by #11401
Labels
autocompletions Feedback for code completions in the editor bug [core label] language server An umbrella label for all language servers language An umbrella label for all programming languages syntax behaviors large projects For anything relating to large volumes of files or multiple subprojects in one main project. needs info / awaiting response Issue that needs more information from the user

Comments

@skhaz
Copy link

skhaz commented Mar 3, 2024

Check for existing issues

  • 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 skhaz added admin read Pending admin review enhancement [core label] triage Maintainer needs to classify the issue labels Mar 3, 2024
@Moshyfawn
Copy link
Member

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.

zed-popover-intent.mp4

@Moshyfawn Moshyfawn added language An umbrella label for all programming languages syntax behaviors language server An umbrella label for all language servers bug [core label] popovers Feedback for tooltips, syntax hints, info popups, toasts, etc and removed triage Maintainer needs to classify the issue language An umbrella label for all programming languages syntax behaviors language server An umbrella label for all language servers labels Mar 3, 2024
@skhaz
Copy link
Author

skhaz commented Mar 3, 2024

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

Thank you.

@Moshyfawn
Copy link
Member

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"
  }
}

@SomeoneToIgnore
Copy link
Contributor

SomeoneToIgnore commented Mar 3, 2024

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:

buffer_handle.update(cx, |buffer, cx| {
buffer.set_completion_triggers(
server
.capabilities()
.completion_provider
.as_ref()
.and_then(|provider| provider.trigger_characters.clone())
.unwrap_or_default(),
cx,
);
});

buffer_handle.update(cx, |buffer, cx| {
buffer.set_completion_triggers(
language_server
.capabilities()
.completion_provider
.as_ref()
.and_then(|provider| provider.trigger_characters.clone())
.unwrap_or_default(),
cx,
)
});

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

@Moshyfawn Moshyfawn added language An umbrella label for all programming languages syntax behaviors language server An umbrella label for all language servers and removed popovers Feedback for tooltips, syntax hints, info popups, toasts, etc labels Mar 3, 2024
@SomeoneToIgnore
Copy link
Contributor

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

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:
    fn trigger_completion_on_input(&mut self, text: &str, cx: &mut ViewContext<Self>) {
    if !EditorSettings::get_global(cx).show_completions_on_input {
    return;
    }
    let selection = self.selections.newest_anchor();
    if self
    .buffer
    .read(cx)
    .is_completion_trigger(selection.head(), text, cx)
    {
    self.show_completions(&ShowCompletions, cx);
    } else {
    self.hide_context_menu(cx);
    }
    }

@skhaz
Copy link
Author

skhaz commented Mar 3, 2024

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

@SomeoneToIgnore
Copy link
Contributor

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.

@skhaz
Copy link
Author

skhaz commented Mar 3, 2024 via email

@skhaz
Copy link
Author

skhaz commented Mar 3, 2024

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

The exactly same setup works for VSCode.

@alex-astronomer
Copy link

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.

@skhaz
Copy link
Author

skhaz commented Mar 6, 2024 via email

@brenr
Copy link

brenr commented Mar 21, 2024

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.

@cedws
Copy link

cedws commented Apr 23, 2024

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

Screen.Recording.2024-04-23.at.22.53.16.mov

Copilot disabled

Screen.Recording.2024-04-23.at.22.57.59.mov

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

@klaemo
Copy link

klaemo commented Aug 3, 2024

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.

Can confirm that his worked for me with Typescript :)

@skhaz
Copy link
Author

skhaz commented Aug 3, 2024

It not worked for me.

@skhaz
Copy link
Author

skhaz commented Aug 4, 2024

I do not understand why this issue was closed; it is not working as expected.

@RUPAAK
Copy link

RUPAAK commented Aug 4, 2024

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.

Can confirm that his worked for me with Typescript :)

@klaemo can you provide us your settings.json

@skhaz
Copy link
Author

skhaz commented Aug 4, 2024

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.

Can confirm that his worked for me with Typescript :)

@klaemo can you provide us your settings.json

I did this, restarted and had same issue.

My settings have nothing.

@giovanniOfficioso
Copy link

giovanniOfficioso commented Aug 9, 2024

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.

I tried and it works. I deleted pyright folder in the location you kindly wrote and it works. But it works only for a few time. It suddenly doesn't work after a couple of minutes or when I close and reopen the app. I'm on zed Zed 0.147.2.
here is also my settings.json:

{
  "theme": "One Dark Vivid",
  "ui_font_size": 16,
  "buffer_font_size": 13,
  "show_wrap_guides": true,
  "lsp": {
    "ruff": {
      "initialization_options": {
        "settings": {
          "lineLength": 80,
          "lint": {
            "extendSelect": ["I"]
          }
        }
      }
    }
  },
  "languages": {
    "Python": {
      "format_on_save": "on",
      "formatter": [
        {
          "code_actions": {
            "source.organizeImports.ruff": true,
            "source.fixAll.ruff": true
          }
        },
        {
          "language_server": {
            "name": "ruff"
          }
        }
      ]
    }
  },
  "show_completions_on_input": true,
  "show_inline_completions": true,
  "indent_guides": {
    "enabled": true,
    "line_width": 1,
    "active_line_width": 1,
    "coloring": "fixed",
    "background_coloring": "indent_aware"
  },
  "current_line_highlight": "gutter",
  "git": {
    "git_gutter": "tracked_files",
    "inline_blame": {
      "enabled": true
    }
  },
  "terminal": {
    "font_family": "MesloLGS NF"
  },
  "cursor_blink": true,
  "vim_mode": true
}

I think it is a bug of the app. I write a script that each time I close Zed, it delete the pyright folder. In this way it works. Please fix this issue because in this way the editor isn't very useful, unless I execute my script.

@HatAndBread
Copy link

Just in case this helps anyone, I got around this issue by using TypeScript Language Server instead of Vtsls. Maybe the issue is with vtsls?

settings.json

{
  "languages": {
    "TypeScript": {
      "show_inline_completions": true,
      "language_servers": ["typescript-language-server", "!vtsls"]
    }
  },
 ...
}

@Mehoff
Copy link

Mehoff commented Aug 28, 2024

Experiencing same issue on Windows in TypeScript project. Version of Zed is 0.511.0.

@SephReed
Copy link

SephReed commented Sep 2, 2024

Having the same issue:

  • MacOs
  • Zed updated
  • Typescript@latest
  • ctrl + space works
  • suggestions work if a letter is given

Video can be found in this post: #17260 (comment)

@norpadon
Copy link

norpadon commented Sep 3, 2024

Having the same problem with Python and Pyright

  • Zed version 0.150.4
  • ctrl + space works

@danielbuechele
Copy link

Deleting vtsls from ~/Library/Application\ Support/Zed/languages/ fixed the problem for me, so it could be a problem with vtsls. Is Zed falling back to typescript-language-server when vtsls is not available?

@Iliasnolsson
Copy link

Just in case this helps anyone, I got around this issue by using TypeScript Language Server instead of Vtsls. Maybe the issue is with vtsls?

settings.json

{
  "languages": {
    "TypeScript": {
      "show_inline_completions": true,
      "language_servers": ["typescript-language-server", "!vtsls"]
    }
  },
 ...
}
example.mov

This worked for me too. But it does seem to result in duplicate suggestions

@mocenigo
Copy link

I am also a bit disappointed that I do not have autocompletion suggestions, which is something I expect almost in any editing field. Can it be enabled? It really helps writing in LaTeX.

@mocenigo
Copy link

Ok, I waw able to enable the autocompletions, but it is SLOW. It usually takes some time before the popup appears. How to make it faster?

@eatenpancreas
Copy link

Still experiencing these issues with Rust. Tried deleting rust-analyzer but no success

@godzie44
Copy link

godzie44 commented Oct 28, 2024

@eatenpancreas try to remove rust-analyzer from $HOME/.cargo/bin, it helps for me

btw, why zed prefers lsp from .cargo? I can’t find this in docs

@wizardAEI
Copy link

I remove the project settings.json or add "show_inline_completions": true, for typescript. Both solutions are effective. Could it be that project configuration overrides the default configuration?

method1:
image
method2:
image

@eatenpancreas
Copy link

@eatenpancreas try to remove rust-analyzer from $HOME/.cargo/bin, it helps for me

i tried this, and about 3 hours later it went back to not suggesting anything after inserting a .
it almost feels like it stops working after reaching a certain amount of time/suggestions

@eatenpancreas
Copy link

I don't know what it is, but no matter what i do, everytime i restart zed it works again, and after a few hours or so it'll stop working again.

Sure, i can restart zed everytime, but it's quite bothersome to do so.

@jhaemin
Copy link

jhaemin commented Nov 2, 2024

@eatenpancreas Same here. It works on restart but stops working after some time.

@TheGlorySaint

This comment has been minimized.

@giangchau92
Copy link

This is critical bug but no one fix this

@skhaz
Copy link
Author

skhaz commented Nov 9, 2024

I think I was muted by the Zed team, I have other issues totally ignored...

@eatenpancreas
Copy link

eatenpancreas commented Nov 9, 2024

I love this editor, coming from jetbrains it's leagues ahead and i'm finding the multi-buffer editing amazing, but stuff like this is very important for basic workflow. It's a bit of a dealbreaker for me and i think i will be switching until this gets resolved

@tdjlkk
Copy link

tdjlkk commented Nov 11, 2024

I don't know how useful this will be, but it seems that the issue is quite easily reproducible and connected to how Zed handles state of the language server. I'm on a fresh installation of MacOS and Zed (pretty much only that and nvm installed) so I created a Typescript file with the code below:

Screenshot 2024-11-11 at 20 52 37

When you try writing "example." at the end of the file right after the Language Server first starts, it seems to work. Then you remove that line, save the file, close the file and reopen it, now after writing "example." it doesn't work anymore up until you restart the language server. If you open a project that had non-working autocomplete and restart the language server, it wont work the first time, so you have to do it again - then it works.

I'm not much of a Rust dev, but it almost looks like the state between Zed and the Language Server is out of sync and stops communicating to eachother after the file goes inactive / gets closed.

Zed: v0.160.7 (Zed)
OS: macOS 15.1.0
Memory: 24 GiB
Architecture: aarch64

@tdjlkk
Copy link

tdjlkk commented Nov 14, 2024

Throughout my testing, my issue seems to be fixed in the latest Zed Preview release (0.162.0) through the #20471 PR. Thanks @osiewicz.

@icarusgk
Copy link

Tested on Zed Preview release (0.162.1) on a large Typescript project and it seems to be fixed too! ✅

Previously it stopped working when closing or opening a new file, now it continues to work through multiple files. Thanks @osiewicz

@eatenpancreas
Copy link

I've been testing the preview out ever since @tdjlkk suggested using it and i haven't had the issue re-appear inside Rust. I'm not sure how that could've caused it but i'm very glad that it seems to be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autocompletions Feedback for code completions in the editor bug [core label] language server An umbrella label for all language servers language An umbrella label for all programming languages syntax behaviors large projects For anything relating to large volumes of files or multiple subprojects in one main project. needs info / awaiting response Issue that needs more information from the user
Projects
None yet
Development

Successfully merging a pull request may close this issue.