Skip to content

Add do snippet, structural snippets, and use-injection dedup (#73)#76

Merged
JesseHerrick merged 4 commits into
mainfrom
fix/do-completion-snippets
Jun 12, 2026
Merged

Add do snippet, structural snippets, and use-injection dedup (#73)#76
JesseHerrick merged 4 commits into
mainfrom
fix/do-completion-snippets

Conversation

@JesseHerrick

@JesseHerrick JesseHerrick commented Jun 7, 2026

Copy link
Copy Markdown
Member

Closes #73

  • Add "do" to elixirFormSnippets: expands to do..end block with tab stop
    when snippet support is enabled; falls back to plain keyword with
    Preselect when snippet support is off.
  • Add structural snippets with parameter slots:
    defmodule, def, defp, defmacro, defmacrop
  • Update if snippet to include else clause.
  • Add test and describe snippets for ExUnit.
  • Add elixirKeywords list: do and end appear as plain keyword completions
    to prevent VS Code from falling back to word-based suggestions.
  • Add form-snippet dedup in addCompletionsFromUsing: use-injected
    functions (e.g. ExUnit.Case.test/1) no longer duplicate with their
    form snippet counterpart.

Note

Low Risk
Changes are limited to LSP completion/snippet generation and parser token acceptance for def names; no auth, persistence, or runtime behavior outside the editor.

Overview
Improves Elixir LSP completions with richer snippets, smarter insert text, and fewer duplicate items.

Structural / special-form snippets expand elixirFormSnippets (e.g. defmodule, def/defp, defstruct, if with else, standalone doend). Plain do/end keyword items (with Preselect) avoid VS Code word-based replacements when snippets are off or for simple keyword insert.

Use/import dedup: Kernel and addCompletionsFromUsing skip functions whose names match a form snippet so you get one keyword-style completion instead of a macro call duplicate.

Call-style completions: noParenFuncs emits space-separated args for ExUnit-style macros; doBlockSnippets (macros only via kind) produce full blocks for test, describe, setup, etc. applySnippet now takes kind to choose those templates.

Parser: isValidFuncNameToken treats tokens like defstruct as function names after defmacro, so Kernel-style defs index correctly for completion tests.

Reviewed by Cursor Bugbot for commit 05352d4. Bugbot is set up for automated code reviews on this repo. Configure here.

- Add "do" to elixirFormSnippets: expands to do..end block with tab stop
  when snippet support is enabled; falls back to plain keyword with
  Preselect when snippet support is off.
- Add structural snippets with parameter slots:
  defmodule, def, defp, defmacro, defmacrop
- Update if snippet to include else clause.
- Add test and describe snippets for ExUnit.
- Add elixirKeywords list: do and end appear as plain keyword completions
  to prevent VS Code from falling back to word-based suggestions.
- Add form-snippet dedup in addCompletionsFromUsing: use-injected
  functions (e.g. ExUnit.Case.test/1) no longer duplicate with their
  form snippet counterpart.
@JesseHerrick JesseHerrick changed the title feat: add do snippet, structural snippets, and use-injection dedup (#73) Add do snippet, structural snippets, and use-injection dedup (#73) Jun 7, 2026
…no-paren call style

- Add 8 new Elixir form snippets: defstruct, defexception, defprotocol,
  defimpl, defdelegate, defguard, defguardp, defoverridable
- Fix parser bug: defmacro defstruct(fields) (and defexception, defprotocol,
  defimpl) were silently skipped because the tokenizer emits dedicated token
  types (TokDefstruct etc.) but the def* handler only accepted TokIdent.
  Add isValidFuncNameToken() to also accept these four def-related tokens.
- Add noParenFuncs map for ExUnit macros conventionally written without
  parentheses (assert, refute, test, describe, etc.)
- Add doBlockSnippets map for function-specific do/end block templates
  (test, describe, setup, setup_all, assert_raise), scoped to import/use-chain
- Extend applySnippet and buildCallText with noParen parameter for
  no-paren call style (name arg1, arg2 instead of name(arg1, arg2))
- Keep descriptive placeholder hints (e.g. ${1:name}) on all snippets;
  defstruct/defexception use ${1:fields} as a hint, not hardcoded values
- Add 6 new tests: DoBlockSnippets (with/without snippet support),
  NoParenCallStyle (with/without snippet support), DoKeyword,
  UseInjectedSkippedForFormSnippet
- Extend existing tests: 8 new sub-tests in ElixirFormSnippets,
  refactored NoDuplicateWithKernel to loop-driven checks

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cf0b685. Configure here.

Comment thread internal/lsp/server.go
Co-authored-by: Cursor <cursoragent@cursor.com>
@JesseHerrick JesseHerrick merged commit 50387e6 into main Jun 12, 2026
5 checks passed
@JesseHerrick JesseHerrick deleted the fix/do-completion-snippets branch June 12, 2026 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VS Code: Autocomplete for do keyword is defoverridable

2 participants