@@ -10,18 +10,20 @@ import (
10
10
"go.bug.st/lsp/jsonrpc"
11
11
)
12
12
13
+ // IDELSPServer is an IDE lsp server
13
14
type IDELSPServer struct {
14
15
conn * lsp.Server
15
16
ls * INOLanguageServer
16
17
}
17
18
19
+ // NewIDELSPServer creates and return a new server
18
20
func NewIDELSPServer (logger jsonrpc.FunctionLogger , in io.Reader , out io.Writer , ls * INOLanguageServer ) * IDELSPServer {
19
21
server := & IDELSPServer {
20
22
ls : ls ,
21
23
}
22
24
server .conn = lsp .NewServer (in , out , server )
23
25
server .conn .RegisterCustomNotification ("ino/didCompleteBuild" , server .ArduinoBuildCompleted )
24
- server .conn .SetLogger (& LSPLogger {
26
+ server .conn .SetLogger (& PLogger {
25
27
IncomingPrefix : "IDE --> LS" ,
26
28
OutgoingPrefix : "IDE <-- LS" ,
27
29
HiColor : color .HiGreenString ,
@@ -31,204 +33,254 @@ func NewIDELSPServer(logger jsonrpc.FunctionLogger, in io.Reader, out io.Writer,
31
33
return server
32
34
}
33
35
36
+ // Run runs the server connection
34
37
func (server * IDELSPServer ) Run () {
35
38
server .conn .Run ()
36
39
}
37
40
41
+ // Initialize sends an initilize request
38
42
func (server * IDELSPServer ) Initialize (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.InitializeParams ) (* lsp.InitializeResult , * jsonrpc.ResponseError ) {
39
43
return server .ls .InitializeReqFromIDE (ctx , logger , params )
40
44
}
41
45
46
+ // Shutdown sends a shutdown request
42
47
func (server * IDELSPServer ) Shutdown (ctx context.Context , logger jsonrpc.FunctionLogger ) * jsonrpc.ResponseError {
43
48
return server .ls .ShutdownReqFromIDE (ctx , logger )
44
49
}
45
50
51
+ // WorkspaceSymbol is not implemented
46
52
func (server * IDELSPServer ) WorkspaceSymbol (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.WorkspaceSymbolParams ) ([]lsp.SymbolInformation , * jsonrpc.ResponseError ) {
47
53
panic ("unimplemented" )
48
54
}
49
55
56
+ // WorkspaceExecuteCommand is not implemented
50
57
func (server * IDELSPServer ) WorkspaceExecuteCommand (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.ExecuteCommandParams ) (json.RawMessage , * jsonrpc.ResponseError ) {
51
58
panic ("unimplemented" )
52
59
}
53
60
61
+ // WorkspaceWillCreateFiles is not implemented
54
62
func (server * IDELSPServer ) WorkspaceWillCreateFiles (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.CreateFilesParams ) (* lsp.WorkspaceEdit , * jsonrpc.ResponseError ) {
55
63
panic ("unimplemented" )
56
64
}
57
65
66
+ // WorkspaceWillRenameFiles is not implemented
58
67
func (server * IDELSPServer ) WorkspaceWillRenameFiles (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.RenameFilesParams ) (* lsp.WorkspaceEdit , * jsonrpc.ResponseError ) {
59
68
panic ("unimplemented" )
60
69
}
61
70
71
+ // WorkspaceWillDeleteFiles is not implemented
62
72
func (server * IDELSPServer ) WorkspaceWillDeleteFiles (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.DeleteFilesParams ) (* lsp.WorkspaceEdit , * jsonrpc.ResponseError ) {
63
73
panic ("unimplemented" )
64
74
}
65
75
76
+ // TextDocumentWillSaveWaitUntil is not implemented
66
77
func (server * IDELSPServer ) TextDocumentWillSaveWaitUntil (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.WillSaveTextDocumentParams ) ([]lsp.TextEdit , * jsonrpc.ResponseError ) {
67
78
panic ("unimplemented" )
68
79
}
69
80
81
+ // TextDocumentCompletion is not implemented
70
82
func (server * IDELSPServer ) TextDocumentCompletion (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.CompletionParams ) (* lsp.CompletionList , * jsonrpc.ResponseError ) {
71
83
return server .ls .TextDocumentCompletionReqFromIDE (ctx , logger , params )
72
84
}
73
85
86
+ // CompletionItemResolve is not implemented
74
87
func (server * IDELSPServer ) CompletionItemResolve (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.CompletionItem ) (* lsp.CompletionItem , * jsonrpc.ResponseError ) {
75
88
panic ("unimplemented" )
76
89
}
77
90
91
+ // TextDocumentHover sends a request to hover a text document
78
92
func (server * IDELSPServer ) TextDocumentHover (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.HoverParams ) (* lsp.Hover , * jsonrpc.ResponseError ) {
79
93
return server .ls .TextDocumentHoverReqFromIDE (ctx , logger , params )
80
94
}
81
95
96
+ // TextDocumentSignatureHelp requests help for text document signature
82
97
func (server * IDELSPServer ) TextDocumentSignatureHelp (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.SignatureHelpParams ) (* lsp.SignatureHelp , * jsonrpc.ResponseError ) {
83
98
return server .ls .TextDocumentSignatureHelpReqFromIDE (ctx , logger , params )
84
99
}
85
100
101
+ // TextDocumentDeclaration is not implemented
86
102
func (server * IDELSPServer ) TextDocumentDeclaration (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.DeclarationParams ) ([]lsp.Location , []lsp.LocationLink , * jsonrpc.ResponseError ) {
87
103
panic ("unimplemented" )
88
104
}
89
105
106
+ // TextDocumentDefinition sends a request to define a text document
90
107
func (server * IDELSPServer ) TextDocumentDefinition (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.DefinitionParams ) ([]lsp.Location , []lsp.LocationLink , * jsonrpc.ResponseError ) {
91
108
return server .ls .TextDocumentDefinitionReqFromIDE (ctx , logger , params )
92
109
}
93
110
111
+ // TextDocumentTypeDefinition sends a request to define a type for the text document
94
112
func (server * IDELSPServer ) TextDocumentTypeDefinition (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.TypeDefinitionParams ) ([]lsp.Location , []lsp.LocationLink , * jsonrpc.ResponseError ) {
95
113
return server .ls .TextDocumentTypeDefinitionReqFromIDE (ctx , logger , params )
96
114
}
97
115
116
+ // TextDocumentImplementation sends a request to implement a text document
98
117
func (server * IDELSPServer ) TextDocumentImplementation (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.ImplementationParams ) ([]lsp.Location , []lsp.LocationLink , * jsonrpc.ResponseError ) {
99
118
return server .ls .TextDocumentImplementationReqFromIDE (ctx , logger , params )
100
119
}
101
120
121
+ // TextDocumentReferences is not implemented
102
122
func (server * IDELSPServer ) TextDocumentReferences (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.ReferenceParams ) ([]lsp.Location , * jsonrpc.ResponseError ) {
103
123
panic ("unimplemented" )
104
124
}
105
125
126
+ // TextDocumentDocumentHighlight sends a request to highlight a text document
106
127
func (server * IDELSPServer ) TextDocumentDocumentHighlight (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.DocumentHighlightParams ) ([]lsp.DocumentHighlight , * jsonrpc.ResponseError ) {
107
128
return server .ls .TextDocumentDocumentHighlightReqFromIDE (ctx , logger , params )
108
129
}
109
130
131
+ // TextDocumentDocumentSymbol sends a request for text document symbol
110
132
func (server * IDELSPServer ) TextDocumentDocumentSymbol (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.DocumentSymbolParams ) ([]lsp.DocumentSymbol , []lsp.SymbolInformation , * jsonrpc.ResponseError ) {
111
133
return server .ls .TextDocumentDocumentSymbolReqFromIDE (ctx , logger , params )
112
134
}
113
135
136
+ // TextDocumentCodeAction sends a request for text document code action
114
137
func (server * IDELSPServer ) TextDocumentCodeAction (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.CodeActionParams ) ([]lsp.CommandOrCodeAction , * jsonrpc.ResponseError ) {
115
138
return server .ls .TextDocumentCodeActionReqFromIDE (ctx , logger , params )
116
139
}
117
140
141
+ // CodeActionResolve is not implemented
118
142
func (server * IDELSPServer ) CodeActionResolve (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.CodeAction ) (* lsp.CodeAction , * jsonrpc.ResponseError ) {
119
143
panic ("unimplemented" )
120
144
}
121
145
146
+ // TextDocumentCodeLens is not implemented
122
147
func (server * IDELSPServer ) TextDocumentCodeLens (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.CodeLensParams ) ([]lsp.CodeLens , * jsonrpc.ResponseError ) {
123
148
panic ("unimplemented" )
124
149
}
125
150
151
+ // CodeLensResolve is not implemented
126
152
func (server * IDELSPServer ) CodeLensResolve (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.CodeLens ) (* lsp.CodeLens , * jsonrpc.ResponseError ) {
127
153
panic ("unimplemented" )
128
154
}
129
155
156
+ // TextDocumentDocumentLink is not implemented
130
157
func (server * IDELSPServer ) TextDocumentDocumentLink (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.DocumentLinkParams ) ([]lsp.DocumentLink , * jsonrpc.ResponseError ) {
131
158
panic ("unimplemented" )
132
159
}
133
160
161
+ // DocumentLinkResolve is not implemented
134
162
func (server * IDELSPServer ) DocumentLinkResolve (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.DocumentLink ) (* lsp.DocumentLink , * jsonrpc.ResponseError ) {
135
163
panic ("unimplemented" )
136
164
}
137
165
166
+ // TextDocumentDocumentColor is not implemented
138
167
func (server * IDELSPServer ) TextDocumentDocumentColor (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.DocumentColorParams ) ([]lsp.ColorInformation , * jsonrpc.ResponseError ) {
139
168
panic ("unimplemented" )
140
169
}
141
170
171
+ // TextDocumentColorPresentation is not implemented
142
172
func (server * IDELSPServer ) TextDocumentColorPresentation (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.ColorPresentationParams ) ([]lsp.ColorPresentation , * jsonrpc.ResponseError ) {
143
173
panic ("unimplemented" )
144
174
}
145
175
176
+ // TextDocumentFormatting sends a request to format a text document
146
177
func (server * IDELSPServer ) TextDocumentFormatting (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.DocumentFormattingParams ) ([]lsp.TextEdit , * jsonrpc.ResponseError ) {
147
178
return server .ls .TextDocumentFormattingReqFromIDE (ctx , logger , params )
148
179
}
149
180
181
+ // TextDocumentRangeFormatting sends a request to format the range a text document
150
182
func (server * IDELSPServer ) TextDocumentRangeFormatting (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.DocumentRangeFormattingParams ) ([]lsp.TextEdit , * jsonrpc.ResponseError ) {
151
183
return server .ls .TextDocumentRangeFormattingReqFromIDE (ctx , logger , params )
152
184
}
153
185
186
+ // TextDocumentOnTypeFormatting is not implemented
154
187
func (server * IDELSPServer ) TextDocumentOnTypeFormatting (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.DocumentOnTypeFormattingParams ) ([]lsp.TextEdit , * jsonrpc.ResponseError ) {
155
188
panic ("unimplemented" )
156
189
}
157
190
191
+ // TextDocumentRename sends a request to rename a text document
158
192
func (server * IDELSPServer ) TextDocumentRename (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.RenameParams ) (* lsp.WorkspaceEdit , * jsonrpc.ResponseError ) {
159
193
return server .ls .TextDocumentRenameReqFromIDE (ctx , logger , params )
160
194
}
161
195
196
+ // TextDocumentFoldingRange is not implemented
162
197
func (server * IDELSPServer ) TextDocumentFoldingRange (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.FoldingRangeParams ) ([]lsp.FoldingRange , * jsonrpc.ResponseError ) {
163
198
panic ("unimplemented" )
164
199
}
165
200
201
+ // TextDocumentSelectionRange is not implemented
166
202
func (server * IDELSPServer ) TextDocumentSelectionRange (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.SelectionRangeParams ) ([]lsp.SelectionRange , * jsonrpc.ResponseError ) {
167
203
panic ("unimplemented" )
168
204
}
169
205
206
+ // TextDocumentPrepareCallHierarchy is not implemented
170
207
func (server * IDELSPServer ) TextDocumentPrepareCallHierarchy (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.CallHierarchyPrepareParams ) ([]lsp.CallHierarchyItem , * jsonrpc.ResponseError ) {
171
208
panic ("unimplemented" )
172
209
}
173
210
211
+ // CallHierarchyIncomingCalls is not implemented
174
212
func (server * IDELSPServer ) CallHierarchyIncomingCalls (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.CallHierarchyIncomingCallsParams ) ([]lsp.CallHierarchyIncomingCall , * jsonrpc.ResponseError ) {
175
213
panic ("unimplemented" )
176
214
}
177
215
216
+ // CallHierarchyOutgoingCalls is not implemented
178
217
func (server * IDELSPServer ) CallHierarchyOutgoingCalls (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.CallHierarchyOutgoingCallsParams ) ([]lsp.CallHierarchyOutgoingCall , * jsonrpc.ResponseError ) {
179
218
panic ("unimplemented" )
180
219
}
181
220
221
+ // TextDocumentSemanticTokensFull is not implemented
182
222
func (server * IDELSPServer ) TextDocumentSemanticTokensFull (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.SemanticTokensParams ) (* lsp.SemanticTokens , * jsonrpc.ResponseError ) {
183
223
panic ("unimplemented" )
184
224
}
185
225
226
+ // TextDocumentSemanticTokensFullDelta is not implemented
186
227
func (server * IDELSPServer ) TextDocumentSemanticTokensFullDelta (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.SemanticTokensDeltaParams ) (* lsp.SemanticTokens , * lsp.SemanticTokensDelta , * jsonrpc.ResponseError ) {
187
228
panic ("unimplemented" )
188
229
}
189
230
231
+ // TextDocumentSemanticTokensRange is not implemented
190
232
func (server * IDELSPServer ) TextDocumentSemanticTokensRange (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.SemanticTokensRangeParams ) (* lsp.SemanticTokens , * jsonrpc.ResponseError ) {
191
233
panic ("unimplemented" )
192
234
}
193
235
236
+ // WorkspaceSemanticTokensRefresh is not implemented
194
237
func (server * IDELSPServer ) WorkspaceSemanticTokensRefresh (ctx context.Context , logger jsonrpc.FunctionLogger ) * jsonrpc.ResponseError {
195
238
panic ("unimplemented" )
196
239
}
197
240
241
+ // TextDocumentLinkedEditingRange is not implemented
198
242
func (server * IDELSPServer ) TextDocumentLinkedEditingRange (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.LinkedEditingRangeParams ) (* lsp.LinkedEditingRanges , * jsonrpc.ResponseError ) {
199
243
panic ("unimplemented" )
200
244
}
201
245
246
+ // TextDocumentMoniker is not implemented
202
247
func (server * IDELSPServer ) TextDocumentMoniker (ctx context.Context , logger jsonrpc.FunctionLogger , params * lsp.MonikerParams ) ([]lsp.Moniker , * jsonrpc.ResponseError ) {
203
248
panic ("unimplemented" )
204
249
}
205
250
206
251
// Notifications ->
207
252
253
+ // Progress is not implemented
208
254
func (server * IDELSPServer ) Progress (logger jsonrpc.FunctionLogger , params * lsp.ProgressParams ) {
209
255
panic ("unimplemented" )
210
256
}
211
257
258
+ // Initialized sends an initialized notification
212
259
func (server * IDELSPServer ) Initialized (logger jsonrpc.FunctionLogger , params * lsp.InitializedParams ) {
213
260
server .ls .InitializedNotifFromIDE (logger , params )
214
261
}
215
262
263
+ // Exit sends an exit notification
216
264
func (server * IDELSPServer ) Exit (logger jsonrpc.FunctionLogger ) {
217
265
server .ls .ExitNotifFromIDE (logger )
218
266
}
219
267
268
+ // SetTrace sends a set trace notification
220
269
func (server * IDELSPServer ) SetTrace (logger jsonrpc.FunctionLogger , params * lsp.SetTraceParams ) {
221
270
server .ls .SetTraceNotifFromIDE (logger , params )
222
271
}
223
272
273
+ // WindowWorkDoneProgressCancel is not implemented
224
274
func (server * IDELSPServer ) WindowWorkDoneProgressCancel (logger jsonrpc.FunctionLogger , params * lsp.WorkDoneProgressCancelParams ) {
225
275
panic ("unimplemented" )
226
276
}
227
277
278
+ // WorkspaceDidChangeWorkspaceFolders is not implemented
228
279
func (server * IDELSPServer ) WorkspaceDidChangeWorkspaceFolders (logger jsonrpc.FunctionLogger , params * lsp.DidChangeWorkspaceFoldersParams ) {
229
280
panic ("unimplemented" )
230
281
}
231
282
283
+ // WorkspaceDidChangeConfiguration purpose is explained below
232
284
func (server * IDELSPServer ) WorkspaceDidChangeConfiguration (logger jsonrpc.FunctionLogger , params * lsp.DidChangeConfigurationParams ) {
233
285
// At least one LSP client, Eglot, sends this by default when
234
286
// first connecting, even if the otions are empty.
@@ -240,45 +292,54 @@ func (server *IDELSPServer) WorkspaceDidChangeConfiguration(logger jsonrpc.Funct
240
292
241
293
}
242
294
295
+ // WorkspaceDidChangeWatchedFiles is not implemented
243
296
func (server * IDELSPServer ) WorkspaceDidChangeWatchedFiles (logger jsonrpc.FunctionLogger , params * lsp.DidChangeWatchedFilesParams ) {
244
297
panic ("unimplemented" )
245
298
}
246
299
300
+ // WorkspaceDidCreateFiles is not implemented
247
301
func (server * IDELSPServer ) WorkspaceDidCreateFiles (logger jsonrpc.FunctionLogger , params * lsp.CreateFilesParams ) {
248
302
panic ("unimplemented" )
249
303
}
250
304
305
+ // WorkspaceDidRenameFiles is not implemented
251
306
func (server * IDELSPServer ) WorkspaceDidRenameFiles (logger jsonrpc.FunctionLogger , params * lsp.RenameFilesParams ) {
252
307
panic ("unimplemented" )
253
308
}
254
309
310
+ // WorkspaceDidDeleteFiles is not implemented
255
311
func (server * IDELSPServer ) WorkspaceDidDeleteFiles (logger jsonrpc.FunctionLogger , params * lsp.DeleteFilesParams ) {
256
312
panic ("unimplemented" )
257
313
}
258
314
315
+ // TextDocumentDidOpen sends a notification the a text document is open
259
316
func (server * IDELSPServer ) TextDocumentDidOpen (logger jsonrpc.FunctionLogger , params * lsp.DidOpenTextDocumentParams ) {
260
317
server .ls .TextDocumentDidOpenNotifFromIDE (logger , params )
261
318
}
262
319
320
+ // TextDocumentDidChange sends a notification the a text document has changed
263
321
func (server * IDELSPServer ) TextDocumentDidChange (logger jsonrpc.FunctionLogger , params * lsp.DidChangeTextDocumentParams ) {
264
322
server .ls .TextDocumentDidChangeNotifFromIDE (logger , params )
265
323
}
266
324
325
+ // TextDocumentWillSave is not implemented
267
326
func (server * IDELSPServer ) TextDocumentWillSave (logger jsonrpc.FunctionLogger , params * lsp.WillSaveTextDocumentParams ) {
268
327
panic ("unimplemented" )
269
328
}
270
329
330
+ // TextDocumentDidSave sends a notification the a text document has been saved
271
331
func (server * IDELSPServer ) TextDocumentDidSave (logger jsonrpc.FunctionLogger , params * lsp.DidSaveTextDocumentParams ) {
272
332
server .ls .TextDocumentDidSaveNotifFromIDE (logger , params )
273
333
}
274
334
335
+ // TextDocumentDidClose sends a notification the a text document has been closed
275
336
func (server * IDELSPServer ) TextDocumentDidClose (logger jsonrpc.FunctionLogger , params * lsp.DidCloseTextDocumentParams ) {
276
337
server .ls .TextDocumentDidCloseNotifFromIDE (logger , params )
277
338
}
278
339
279
340
// DidCompleteBuildParams is a custom notification from the Arduino IDE, sent
280
341
type DidCompleteBuildParams struct {
281
- BuildOutputUri * lsp.DocumentURI `json:"buildOutputUri"`
342
+ BuildOutputURI * lsp.DocumentURI `json:"buildOutputUri"`
282
343
}
283
344
284
345
func (server * IDELSPServer ) ArduinoBuildCompleted (logger jsonrpc.FunctionLogger , raw json.RawMessage ) {
0 commit comments