File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,11 @@ export function activate(context: vscode.ExtensionContext) {
114
114
) ,
115
115
vscode . languages . registerCompletionItemProvider (
116
116
LANGUAGES ,
117
+ vscode . languages . registerCompletionItemProvider (
118
+ BLADE_LANGUAGES ,
119
+ livewireComponentCompletion ,
120
+ ":" ,
121
+ ) ,
117
122
vscode . languages . registerCompletionItemProvider (
118
123
BLADE_LANGUAGES ,
119
124
new BladeCompletion ( ) ,
Original file line number Diff line number Diff line change @@ -38,3 +38,29 @@ export const linkProvider: LinkProvider = (doc: vscode.TextDocument) => {
38
38
39
39
return Promise . resolve ( links ) ;
40
40
} ;
41
+
42
+ export const completionProvider : vscode . CompletionItemProvider = {
43
+ provideCompletionItems (
44
+ doc : vscode . TextDocument ,
45
+ pos : vscode . Position ,
46
+ ) : vscode . ProviderResult < vscode . CompletionItem [ ] > {
47
+ const componentPrefix = "<livewire:" ;
48
+ const pathPrefix = "livewire." ;
49
+ const line = doc . lineAt ( pos . line ) . text ;
50
+ const linePrefix = line . substring (
51
+ pos . character - componentPrefix . length ,
52
+ pos . character ,
53
+ ) ;
54
+
55
+ if ( linePrefix !== componentPrefix ) {
56
+ return undefined ;
57
+ }
58
+
59
+ return getViews ( )
60
+ . items . filter ( ( view ) => view . key . startsWith ( pathPrefix ) )
61
+ . map (
62
+ ( view ) =>
63
+ new vscode . CompletionItem ( view . key . replace ( pathPrefix , "" ) ) ,
64
+ ) ;
65
+ } ,
66
+ } ;
You can’t perform that action at this time.
0 commit comments