Skip to content

Commit 52cbead

Browse files
committed
feat(language-server): add Sails completion
1 parent b39e8ba commit 52cbead

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

packages/language-server/index.js

+23-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const validateDocument = require('./validators/validate-document')
44
const goToAction = require('./go-to-definitions/go-to-action')
55
const goToPolicy = require('./go-to-definitions/go-to-policy')
66
const goToView = require('./go-to-definitions/go-to-view')
7+
const sailsCompletions = require('./completions/sails-completions')
78

89
const connection = lsp.createConnection(lsp.ProposedFeatures.all)
910
const documents = new lsp.TextDocuments(TextDocument)
@@ -12,11 +13,10 @@ connection.onInitialize((params) => {
1213
return {
1314
capabilities: {
1415
textDocumentSync: lsp.TextDocumentSyncKind.Incremental,
15-
definitionProvider: true
16-
// completionProvider: {
17-
// resolveProvider: true,
18-
// triggerCharacters: ['"', "'", '.']
19-
// }
16+
definitionProvider: true,
17+
completionProvider: {
18+
triggerCharacters: ['"', "'", '.']
19+
}
2020
}
2121
}
2222
})
@@ -48,6 +48,24 @@ connection.onDefinition(async (params) => {
4848
return definitions.length > 0 ? definitions : null
4949
})
5050

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+
5169
documents.listen(connection)
5270
connection.listen()
5371

0 commit comments

Comments
 (0)