import * as vscode from 'vscode'; export const init_blade_language_config = () => { // HTML empty elements that don't require closing tags const EMPTY_ELEMENTS: string[] = [ 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr', ]; // Configure Blade language indentation and auto-closing behavior vscode.languages.setLanguageConfiguration('blade', { indentationRules: { increaseIndentPattern: /<(?!\?|(?:area|base|br|col|frame|hr|html|img|input|link|meta|param)\b|[^>]*\/>)([-_\.A-Za-z0-9]+)(?=\s|>)\b[^>]*>(?!.*<\/\1>)|)|\{[^}"']*$/, decreaseIndentPattern: /^\s*(<\/(?!html)[-_\.A-Za-z0-9]+\b[^>]*>|-->|\})/, }, wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g, onEnterRules: [ { // When pressing Enter between opening and closing tags, auto-indent beforeText: new RegExp( `<(?!(?:${EMPTY_ELEMENTS.join( '|' )}))([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i' ), afterText: /^<\/([_:\w][_:\w-.\d]*)\s*>$/i, action: { indentAction: vscode.IndentAction.IndentOutdent }, }, { // When pressing Enter after opening tag, auto-indent beforeText: new RegExp( `<(?!(?:${EMPTY_ELEMENTS.join( '|' )}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i' ), action: { indentAction: vscode.IndentAction.Indent }, }, ], }); };