@@ -153,16 +153,16 @@ func NewINOLanguageServer(stdin io.Reader, stdout io.Writer, config *Config) *IN
153
153
return ls
154
154
}
155
155
156
- func (ls * INOLanguageServer ) InitializeReqFromIDE (ctx context.Context , logger jsonrpc.FunctionLogger , inoParams * lsp.InitializeParams ) (* lsp.InitializeResult , * jsonrpc.ResponseError ) {
156
+ func (ls * INOLanguageServer ) InitializeReqFromIDE (ctx context.Context , logger jsonrpc.FunctionLogger , ideParams * lsp.InitializeParams ) (* lsp.InitializeResult , * jsonrpc.ResponseError ) {
157
157
go func () {
158
158
defer streams .CatchAndLogPanic ()
159
159
// Unlock goroutines waiting for clangd
160
160
defer ls .clangdStarted .Broadcast ()
161
161
162
162
logger := NewLSPFunctionLogger (color .HiCyanString , "INIT --- " )
163
- logger .Logf ("initializing workbench: %s" , inoParams .RootURI )
163
+ logger .Logf ("initializing workbench: %s" , ideParams .RootURI )
164
164
165
- ls .sketchRoot = inoParams .RootURI .AsPath ()
165
+ ls .sketchRoot = ideParams .RootURI .AsPath ()
166
166
ls .sketchName = ls .sketchRoot .Base ()
167
167
ls .buildSketchCpp = ls .buildSketchRoot .Join (ls .sketchName + ".ino.cpp" )
168
168
@@ -178,8 +178,8 @@ func (ls *INOLanguageServer) InitializeReqFromIDE(ctx context.Context, logger js
178
178
logger .Logf ("ERROR: updating compile_commands: %s" , err )
179
179
}
180
180
181
- if cppContent , err := ls .buildSketchCpp .ReadFile (); err == nil {
182
- ls .sketchMapper = sourcemapper .CreateInoMapper (cppContent )
181
+ if inoCppContent , err := ls .buildSketchCpp .ReadFile (); err == nil {
182
+ ls .sketchMapper = sourcemapper .CreateInoMapper (inoCppContent )
183
183
ls .sketchMapper .CppText .Version = 1
184
184
} else {
185
185
logger .Logf ("error starting clang: reading generated cpp file from sketch: %s" , err )
@@ -205,17 +205,17 @@ func (ls *INOLanguageServer) InitializeReqFromIDE(ctx context.Context, logger js
205
205
// Send initialization command to clangd (1 sec. timeout)
206
206
ctx , cancel := context .WithTimeout (context .Background (), time .Second )
207
207
defer cancel ()
208
- cppInitializeParams := * inoParams
209
- cppInitializeParams .RootPath = ls .buildSketchRoot .String ()
210
- cppInitializeParams .RootURI = lsp .NewDocumentURIFromPath (ls .buildSketchRoot )
211
- if initRes , clangErr , err := ls .Clangd .conn .Initialize (ctx , & cppInitializeParams ); err != nil {
208
+ clangInitializeParams := * ideParams
209
+ clangInitializeParams .RootPath = ls .buildSketchRoot .String ()
210
+ clangInitializeParams .RootURI = lsp .NewDocumentURIFromPath (ls .buildSketchRoot )
211
+ if clangInitializeResult , clangErr , err := ls .Clangd .conn .Initialize (ctx , & clangInitializeParams ); err != nil {
212
212
logger .Logf ("error initilizing clangd: %v" , err )
213
213
return
214
214
} else if clangErr != nil {
215
215
logger .Logf ("error initilizing clangd: %v" , clangErr .AsError ())
216
216
return
217
217
} else {
218
- logger .Logf ("clangd successfully started: %s" , string (lsp .EncodeMessage (initRes )))
218
+ logger .Logf ("clangd successfully started: %s" , string (lsp .EncodeMessage (clangInitializeResult )))
219
219
}
220
220
221
221
if err := ls .Clangd .conn .Initialized (& lsp.InitializedParams {}); err != nil {
@@ -297,7 +297,7 @@ func (ls *INOLanguageServer) InitializeReqFromIDE(ctx context.Context, logger js
297
297
}
298
298
299
299
func (ls * INOLanguageServer ) ShutdownReqFromIDE (ctx context.Context , logger jsonrpc.FunctionLogger ) * jsonrpc.ResponseError {
300
- ls .Clangd .conn .Shutdown (context .Background ())
300
+ _ , _ = ls .Clangd .conn .Shutdown (context .Background ())
301
301
return nil
302
302
}
303
303
0 commit comments