Add do snippet, structural snippets, and use-injection dedup (#73)#76
Merged
Conversation
- 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.
superhawk610
approved these changes
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
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.
Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #73
when snippet support is enabled; falls back to plain keyword with
Preselect when snippet support is off.
defmodule, def, defp, defmacro, defmacrop
to prevent VS Code from falling back to word-based suggestions.
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,ifwithelse, standalonedo…end). Plaindo/endkeyword items (withPreselect) avoid VS Code word-based replacements when snippets are off or for simple keyword insert.Use/import dedup: Kernel and
addCompletionsFromUsingskip functions whose names match a form snippet so you get one keyword-style completion instead of a macro call duplicate.Call-style completions:
noParenFuncsemits space-separated args for ExUnit-style macros;doBlockSnippets(macros only viakind) produce full blocks fortest,describe,setup, etc.applySnippetnow takeskindto choose those templates.Parser:
isValidFuncNameTokentreats tokens likedefstructas function names afterdefmacro, 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.