@@ -11,7 +11,9 @@ import {
11
11
createConnection ,
12
12
Diagnostic ,
13
13
DiagnosticSeverity ,
14
+ DidChangeConfigurationNotification ,
14
15
InitializeParams ,
16
+ InitializeResult ,
15
17
Position ,
16
18
ProposedFeatures ,
17
19
Range ,
@@ -21,8 +23,13 @@ import {
21
23
TextEdit ,
22
24
} from 'vscode-languageserver/node' ;
23
25
import { TextDocument } from 'vscode-languageserver-textdocument' ;
24
- import { configService } from './services/configuration.service' ;
25
- import { validateFilePaths } from './validations/validate' ;
26
+
27
+ import {
28
+ configService ,
29
+ CortexCommandLanguageSupportConfiguration ,
30
+ } from './services/configuration.service' ;
31
+ import { validateFilePaths } from './validations/validateFilePath' ;
32
+ import { fsService } from './services/fileSystem.service' ;
26
33
27
34
const connection = createConnection ( ProposedFeatures . all ) ;
28
35
@@ -33,7 +40,7 @@ connection.console.info(
33
40
const documents : TextDocuments < TextDocument > = new TextDocuments ( TextDocument ) ;
34
41
documents . listen ( connection ) ;
35
42
36
- connection . onInitialize ( ( params : InitializeParams ) => {
43
+ connection . onInitialize ( ( params : InitializeParams ) : InitializeResult => {
37
44
const capabilities = params . capabilities ;
38
45
39
46
// Does the client support the `workspace/configuration` request?
@@ -47,7 +54,9 @@ connection.onInitialize((params: InitializeParams) => {
47
54
configService . hasDiagnosticRelatedInformationCapability =
48
55
! ! capabilities . textDocument ?. publishDiagnostics ?. relatedInformation ;
49
56
50
- return {
57
+ fsService . workspaceFolders = params . workspaceFolders ?? [ ] ;
58
+
59
+ const result : InitializeResult = {
51
60
capabilities : {
52
61
// codeActionProvider: true,
53
62
textDocumentSync : {
@@ -59,6 +68,45 @@ connection.onInitialize((params: InitializeParams) => {
59
68
// },
60
69
} ,
61
70
} ;
71
+
72
+ if ( configService . hasWorkspaceFolderCapability ) {
73
+ result . capabilities . workspace = {
74
+ workspaceFolders : {
75
+ supported : true ,
76
+ } ,
77
+ } ;
78
+ }
79
+
80
+ return result ;
81
+ } ) ;
82
+
83
+ connection . onInitialized ( ( ) => {
84
+ if ( configService . hasConfigurationCapability ) {
85
+ // Register for all configuration changes.
86
+ connection . client . register (
87
+ DidChangeConfigurationNotification . type ,
88
+ undefined
89
+ ) ;
90
+ }
91
+ if ( configService . hasWorkspaceFolderCapability ) {
92
+ connection . workspace . onDidChangeWorkspaceFolders ( ( _event ) => {
93
+ connection . console . log ( 'Workspace folder change event received.' ) ;
94
+ } ) ;
95
+ }
96
+ } ) ;
97
+
98
+ connection . onDidChangeConfiguration ( ( change ) => {
99
+ if ( configService . hasConfigurationCapability ) {
100
+ // Reset all cached document settings
101
+ configService . documentSettings . clear ( ) ;
102
+ } else if ( change . settings [ 'cortexCommandLanguageSupport' ] ) {
103
+ configService . globalSettings = < CortexCommandLanguageSupportConfiguration > (
104
+ change . settings [ 'cortexCommandLanguageSupport' ]
105
+ ) ;
106
+ }
107
+
108
+ // Revalidate all open text documents
109
+ documents . all ( ) . forEach ( validate ) ;
62
110
} ) ;
63
111
64
112
function validate ( document : TextDocument ) : void {
0 commit comments