1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
Before:
let b:project = {
\ 'initialized': 0,
\ 'init_request_id': 3,
\ 'message_queue': [],
\ 'capabilities_queue': [],
\}
let b:conn = {
\ 'projects': {
\ '/foo/bar': b:project,
\ },
\ 'capabilities': {
\ 'hover': 0,
\ 'references': 0,
\ 'completion': 0,
\ 'completion_trigger_characters': [],
\ 'definition': 0,
\ },
\}
After:
unlet! b:project
unlet! b:conn
Execute(publishDiagnostics messages with files inside project directories should initialize projects):
" This is for some other file, ignore this one.
call ale#lsp#HandleOtherInitializeResponses(b:conn, {
\ 'method': 'textDocument/publishDiagnostics',
\ 'params': {'uri': 'file:///xyz/bar/baz.txt'},
\})
AssertEqual
\ {
\ 'initialized': 0,
\ 'init_request_id': 3,
\ 'message_queue': [],
\ 'capabilities_queue': [],
\ },
\ b:project
call ale#lsp#HandleOtherInitializeResponses(b:conn, {
\ 'method': 'textDocument/publishDiagnostics',
\ 'params': {'uri': 'file:///foo/bar/baz.txt'},
\})
AssertEqual
\ {
\ 'initialized': 1,
\ 'init_request_id': 3,
\ 'message_queue': [],
\ 'capabilities_queue': [],
\ },
\ b:project
Execute(Messages with no method and capabilities should initialize projects):
call ale#lsp#HandleOtherInitializeResponses(b:conn, {
\ 'result': {'capabilities': {}},
\})
AssertEqual
\ {
\ 'initialized': 1,
\ 'init_request_id': 3,
\ 'message_queue': [],
\ 'capabilities_queue': [],
\ },
\ b:project
Execute(Other messages should not initialize projects):
call ale#lsp#HandleOtherInitializeResponses(b:conn, {'method': 'lolwat'})
AssertEqual 0, b:project.initialized
call ale#lsp#HandleOtherInitializeResponses(b:conn, {'result': {'x': {}}})
AssertEqual 0, b:project.initialized
Execute(Capabilities should bet set up correctly):
call ale#lsp#HandleOtherInitializeResponses(b:conn, {
\ 'jsonrpc': '2.0',
\ 'id': 1,
\ 'result': {
\ 'capabilities': {
\ 'renameProvider': v:true,
\ 'executeCommandProvider': {
\ 'commands': [],
\ },
\ 'hoverProvider': v:true,
\ 'documentSymbolProvider': v:true,
\ 'documentRangeFormattingProvider': v:true,
\ 'codeLensProvider': {
\ 'resolveProvider': v:false
\ },
\ 'referencesProvider': v:true,
\ 'textDocumentSync': 2,
\ 'documentFormattingProvider': v:true,
\ 'codeActionProvider': v:true,
\ 'signatureHelpProvider': {
\ 'triggerCharacters': ['(', ','],
\ },
\ 'completionProvider': {
\ 'triggerCharacters': ['.'],
\ 'resolveProvider': v:false
\ },
\ 'definitionProvider': v:true,
\ 'experimental': {},
\ 'documentHighlightProvider': v:true
\ },
\ },
\})
AssertEqual
\ {
\ 'capabilities': {
\ 'completion_trigger_characters': ['.'],
\ 'completion': 1,
\ 'references': 1,
\ 'hover': 1,
\ 'definition': 1,
\ },
\ 'message_queue': [],
\ 'projects': {
\ '/foo/bar': {
\ 'initialized': 1,
\ 'message_queue': [],
\ 'capabilities_queue': [],
\ 'init_request_id': 3,
\ },
\ },
\ },
\ b:conn
Execute(Disabled capabilities should be recognised correctly):
call ale#lsp#HandleOtherInitializeResponses(b:conn, {
\ 'jsonrpc': '2.0',
\ 'id': 1,
\ 'result': {
\ 'capabilities': {
\ 'renameProvider': v:true,
\ 'executeCommandProvider': {
\ 'commands': [],
\ },
\ 'hoverProvider': v:false,
\ 'documentSymbolProvider': v:true,
\ 'documentRangeFormattingProvider': v:true,
\ 'codeLensProvider': {
\ 'resolveProvider': v:false
\ },
\ 'referencesProvider': v:false,
\ 'textDocumentSync': 2,
\ 'documentFormattingProvider': v:true,
\ 'codeActionProvider': v:true,
\ 'signatureHelpProvider': {
\ 'triggerCharacters': ['(', ','],
\ },
\ 'definitionProvider': v:false,
\ 'experimental': {},
\ 'documentHighlightProvider': v:true
\ },
\ },
\})
AssertEqual
\ {
\ 'capabilities': {
\ 'completion_trigger_characters': [],
\ 'completion': 0,
\ 'references': 0,
\ 'hover': 0,
\ 'definition': 0,
\ },
\ 'message_queue': [],
\ 'projects': {
\ '/foo/bar': {
\ 'initialized': 1,
\ 'message_queue': [],
\ 'capabilities_queue': [],
\ 'init_request_id': 3,
\ },
\ },
\ },
\ b:conn
Execute(Results that are not dictionaries should be handled correctly):
call ale#lsp#HandleOtherInitializeResponses(b:conn, {
\ 'jsonrpc': '2.0',
\ 'id': 1,
\ 'result': v:null,
\})
|