@@ -4,6 +4,7 @@ const validateDocument = require('./validators/validate-document')
4
4
const goToAction = require ( './go-to-definitions/go-to-action' )
5
5
const goToPolicy = require ( './go-to-definitions/go-to-policy' )
6
6
const goToView = require ( './go-to-definitions/go-to-view' )
7
+ const sailsCompletions = require ( './completions/sails-completions' )
7
8
8
9
const connection = lsp . createConnection ( lsp . ProposedFeatures . all )
9
10
const documents = new lsp . TextDocuments ( TextDocument )
@@ -12,11 +13,10 @@ connection.onInitialize((params) => {
12
13
return {
13
14
capabilities : {
14
15
textDocumentSync : lsp . TextDocumentSyncKind . Incremental ,
15
- definitionProvider : true
16
- // completionProvider: {
17
- // resolveProvider: true,
18
- // triggerCharacters: ['"', "'", '.']
19
- // }
16
+ definitionProvider : true ,
17
+ completionProvider : {
18
+ triggerCharacters : [ '"' , "'" , '.' ]
19
+ }
20
20
}
21
21
}
22
22
} )
@@ -48,6 +48,24 @@ connection.onDefinition(async (params) => {
48
48
return definitions . length > 0 ? definitions : null
49
49
} )
50
50
51
+ connection . onCompletion ( async ( params ) => {
52
+ const document = documents . get ( params . textDocument . uri )
53
+ if ( ! document ) {
54
+ return null
55
+ }
56
+
57
+ const completions = await sailsCompletions ( document , params . position )
58
+
59
+ if ( completions ) {
60
+ return {
61
+ isIncomplete : false ,
62
+ items : completions
63
+ }
64
+ }
65
+
66
+ return null
67
+ } )
68
+
51
69
documents . listen ( connection )
52
70
connection . listen ( )
53
71
0 commit comments