Skip to content

Commit

Permalink
feat: add support for new tags
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Sep 21, 2024
1 parent 90ee5da commit e7fd42c
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/regexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const edgeRegex = /(@include|@!?component)\(['"]([^'"]+)['"]/g
* Find all components as tags inside an Edge template
*/
export const edgeComponentsAsTagsRegex =
/^[ \t]*(@!?(?!include|includeIf|set|can|unless|svg|let|eval|inject|!component|if|elseif|else|vite|entryPointScripts|entryPointStyles|each|assign|debugger|component|slot|newError)(.+?))\(.*/gm
/^[ \t]*(@!?(?!include|includeIf|set|can|unless|svg|let|eval|inject|stack|dd|dump|pushTo|pushOnceTo|!component|if|elseif|else|vite|entryPointScripts|entryPointStyles|each|assign|debugger|component|slot|newError)(.+?))\(.*/gm

/**
* Find all the views that are being used inside a TS/Js file
Expand Down
55 changes: 55 additions & 0 deletions src/vscode/builtin_tags_completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,56 @@ setItem.documentation = new MarkdownString(
setItem.tags = [CompletionItemTag.Deprecated]
setItem.detail = 'Deprecated in Edge 6'

/**
* `@stack`
*/
const stackItem = new CompletionItem('stack', CompletionItemKind.Keyword)
stackItem.insertText = new SnippetString('stack(${1:placeholder})')
stackItem.documentation = new MarkdownString(
'Define a stack placeholder\n\nhttps://edgejs.dev/docs/stacks'
)
stackItem.detail = 'Stack placeholder'

/**
* `@dd`
*/
const ddItem = new CompletionItem('dd', CompletionItemKind.Keyword)
ddItem.insertText = new SnippetString('dd(${1:value})')
ddItem.documentation = new MarkdownString(
'Dump value using dumper and die\n\nhttps://edgejs.dev/docs/stacks'
)
ddItem.detail = 'Dump die'

/**
* `@dump`
*/
const dumpItem = new CompletionItem('dump', CompletionItemKind.Keyword)
dumpItem.insertText = new SnippetString('dump(${1:value})')
dumpItem.documentation = new MarkdownString(
'Dump value using dumper\n\nhttps://edgejs.dev/docs/stacks'
)
dumpItem.detail = 'Dump'

/**
* `@pushOnceTo`
*/
const pushOnceItem = new CompletionItem('pushOnceTo', CompletionItemKind.Keyword)
pushOnceItem.insertText = new SnippetString('pushOnceTo(${1:stackName})\n\t$0\n@end')
pushOnceItem.documentation = new MarkdownString(
'Push item inside a named stack\n\nhttps://edgejs.dev/docs/stacks'
)
pushOnceItem.detail = 'Push once to stack'

/**
* `@pushTo`
*/
const pushItem = new CompletionItem('pushTo', CompletionItemKind.Keyword)
pushItem.insertText = new SnippetString('pushTo(${1:stackName})\n\t$0\n@end')
pushItem.documentation = new MarkdownString(
'Push item inside a named stack\n\nhttps://edgejs.dev/docs/stacks'
)
pushItem.detail = 'Push to stack'

export const builtinTags = [
ifItem,
elseIfItem,
Expand All @@ -220,6 +270,11 @@ export const builtinTags = [
sectionItem,
layoutItem,
setItem,
stackItem,
ddItem,
dumpItem,
pushItem,
pushOnceItem,
]

export const builtinSelfClosingTags = [selfClosingComponentItem]

0 comments on commit e7fd42c

Please sign in to comment.