Skip to content

VS Code: Autocomplete for do keyword is defoverridable #73

Description

@superhawk610

Describe the bug

When typing in an editor that supports textDocument/completion, after typing the do keyword, the only completion available is defoverridable, and pressing <Enter> (as you typically do after typing do since you're moving to the next line of an if expression, def, defmodule, etc) will accept the replacement. Here's a screenshot of my editor after typing do and then after pressing <Enter>:

Image Image

To reproduce

defmodule Foo do<Enter>

Expected behavior

Ideally, do would be available as a completion and accepted by <Enter> so that I can keep typing the expression. elixir-ls had a similar issue documented here. They've solved it by adding a do completion to the list whenever the trigger characters are d or do and there's nothing after the cursor. As a corollary, they also set preselect on the completion to have it take precedence when needed, documented here.

Here's the current implementation from elixir-ls: https://github.com/elixir-lsp/elixir-ls/blob/a9a26f4f7c21b0b6fd0e55084a7b5bd628caf78e/apps/language_server/lib/language_server/providers/completion.ex#L325-L359

Here's a quick pass I took at implementing something similar for Dexter: superhawk610#2 Note that my implementation is much simpler and doesn't cover as many edge cases, I just wanted to see whether it worked (and it does). Having it expand to do\n $0\nend is also nice, but not necessary.

I've seen some people suggest adding do\n $0\nend as a snippet, which is a viable workaround, but I'd prefer to have it fixed at the source if possible.

Environment

  • Dexter version (dexter --version): 0.7.0
  • Elixir version (elixir --version): 1.19.4
  • Editor and version: Zed 1.5.3
  • OS: macOS Tahoe 26.5

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions