Asterisk Dialplan Magic
Editing support for Asterisk extensions.conf dialplans.
Features
- Priority numbers in the gutter — resolves and displays the actual priority for every
exten/same line, including n and n(label) tokens.
- Syntax highlighting — contexts,
exten/same/include/ignorepat/switch statements, application calls, and comments, scoped to extensions.conf/extensions_*.conf files.
- Variable colouring —
${VAR} variables and inherited vars get their own colours, with _VAR (inherited one level) and __VAR (inherited by all descendants) each distinguished from a plain variable.
- Goto/Gosub navigation — hover over a
Goto()/Gosub() call to see the resolved priority and line, click through to jump straight there. Matches Asterisk's extension pattern syntax (_X., _9NXXXXXX, etc.), not just literal extensions.
- Application/function hover docs — hover over any other application call (
Set, Dial, Answer, ...) or ${FUNCTION()} call (${STRFTIME()}, ${LEN()}, ...) to see its syntax and a short synopsis, from a bundled curated dataset covering the most common ones.
- Find All References — right-click a priority or label line to find every
Goto/Gosub call that jumps to it, across the workspace.
include => context navigation — Go to Definition on an include => context statement jumps to that context's [context] declaration; Find All References on a [context] declaration lists every context that includes it.
- Completion — applications and
${FUNCTION()} calls from the bundled docs dataset, plus context names, extensions, labels and channel variables in the places they can appear (Goto/Gosub arguments, include =>, inside ${...}). Signature help shows the argument list of whatever you're typing.
- Rename Symbol (F2) — rename a context or a label and every
Goto/Gosub/include pointing at it is updated across the workspace. A label only renames the jumps that actually resolve to it, not every same-named label elsewhere.
- Quick fixes — stub out a missing
Goto/Gosub target, collapse repeated exten => lines into same =>, convert numeric priorities to n (only where that's safe: the priority already follows on from the previous one and nothing jumps to that number), and convert Macro(name,args) to its Gosub(macro-name,s,1(args)) equivalent.
- Diagnostics — flags duplicate priorities within an extension, unresolved
Goto/Gosub targets, and unreachable code after an unconditional Goto/Hangup. Variable-based targets (e.g. Goto(ctx,${VAR},1)) are recognized as call-time-only and not flagged. Also:
- Unreachable contexts — a context nothing includes or jumps to. Entry points named by
context= in pjsip.conf/sip.conf are picked up automatically; anything else goes in asteriskDialplan.entryContexts.
- Ambiguous pattern overlap — two patterns in one context that can both match the same extension where neither is more specific (
_1NX vs _1X5). _9XXX alongside _X. is not flagged: the narrower pattern predictably wins.
- Removed/deprecated applications — checked against
asteriskDialplan.asteriskVersion (default 22), covering the Macro family and everything that went with chan_sip in Asterisk 21.
- Cross-file navigation — Go to Definition on
Dial(PJSIP/alice), Queue(support), VoiceMail(101@default) or Local/1234@from-internal jumps into pjsip.conf, queues.conf, voicemail.conf or the target context.
- Document symbols / outline view — contexts and extensions/labels show up in the editor outline and breadcrumbs for quick navigation.
- Snippets —
exten, same, context, and include tab-triggers for quickly inserting new dialplan lines.
- Code folding — collapse a context or an extension's whole priority chain from the gutter.
- Reference count CodeLens — a "N references" annotation above any priority/label line that's targeted by a
Goto/Gosub elsewhere; click through to see them all.
- Call trace — "Asterisk Dialplan: Trace a Call" walks the priorities a dialled extension would actually execute, following pattern matching,
include fallback and unconditional Goto jumps until the call hangs up, runs out of priorities or loops. Pick any step to jump to it.
- Extension flow diagram — "Asterisk Dialplan: Show Extension Flow Diagram" renders the extension under the cursor as a priority-level Mermaid graph, with
GotoIf true/false branches, Gosub calls, and anything outside the extension as a single terminal node.
- Dialplan flow diagram — "Asterisk Dialplan: Show Flow Diagram" renders a context-level Mermaid graph of the whole workspace:
include => context fallback chaining and cross-context Goto/Gosub calls as edges, with unresolved targets shown as dashed red edges to a "ghost" node. Click any node to jump to that context's definition.
Settings
asteriskDialplan.asteriskVersion (default 22) — which Asterisk release to check applications against.
asteriskDialplan.entryContexts (default []) — contexts calls arrive in from outside the dialplan, so they're never reported as unreachable. default, general, globals and anything named by a context= in the channel driver configs are already covered.
Troubleshooting
Syntax highlighting isn't showing up. This extension recognizes files named extensions.conf or extensions_*.conf automatically. If your dialplan lives under a different filename, add ;asterisk-dialplan as the very first line of the file — it'll be picked up and highlighted regardless of name.
| |