Add do snippet, structural snippets, and use-injection dedup (#73)#76
Open
JesseHerrick wants to merge 3 commits into
Open
Add do snippet, structural snippets, and use-injection dedup (#73)#76JesseHerrick wants to merge 3 commits into
JesseHerrick wants to merge 3 commits into
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.
| item.InsertTextFormat = protocol.InsertTextFormatSnippet | ||
| item.InsertText = tmpl | ||
| return | ||
| } |
There was a problem hiding this comment.
doBlockSnippets ignore definition kind
Medium Severity
applySnippet selects doBlockSnippets using only the function name, so any in-scope completion named test, describe, setup, setup_all, or assert_raise gets an ExUnit-style do/end insert even when the indexed definition is an ordinary def (or a non-macro export), producing invalid or surprising insert text.
Reviewed by Cursor Bugbot for commit cf0b685. Configure here.
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 insert text and parser token validation for def names; no runtime or security-sensitive paths.
Overview
Improves Dexter LSP completions so Elixir editing in VS Code feels closer to built-in language support: richer snippets, fewer duplicates, and more idiomatic insert text.
Special forms and keywords:
elixirFormSnippetsnow covers structural macros (defmodule,def/defp,defstruct, guards, etc.), adds ado…endsnippet, and extendsifwith anelsebranch.doandendalso appear as plain keyword items (elixirKeywordswith Preselect) so Enter does not swap them for word-based suggestions when snippets are off.Use-chain dedup: When snippet support is on,
addCompletionsFromUsing(and import listing) skips functions whose names already have a global form snippet (e.g. Kernelifvs snippetif).Imported macros:
doBlockSnippets(e.g.test,describe,setup) override generic arg-list snippets;noParenFuncsformats ExUnit-style macros asassert exprinstead ofassert(expr).Parser:
isValidFuncNameTokentreatsdefstruct/defprotocol-style tokens as valid names afterdefmacro, matching Kernel definitions for indexing.Tests cover snippets, dedup,
dokeyword behavior, do-block snippets, and no-paren call style.Reviewed by Cursor Bugbot for commit c66c424. Bugbot is set up for automated code reviews on this repo. Configure here.