@@ -35,6 +35,7 @@ defmodule ElixirLS.LanguageServer.Server do
35
35
use Protocol
36
36
37
37
defstruct [
38
+ :server_instance_id ,
38
39
:build_ref ,
39
40
:dialyzer_sup ,
40
41
:client_capabilities ,
@@ -346,6 +347,9 @@ defmodule ElixirLS.LanguageServer.Server do
346
347
defp handle_request ( initialize_req ( _id , root_uri , client_capabilities ) , state ) do
347
348
show_version_warnings ( )
348
349
350
+ server_instance_id =
351
+ :crypto . strong_rand_bytes ( 32 ) |> Base . url_encode64 ( ) |> binary_part ( 0 , 32 )
352
+
349
353
state =
350
354
case root_uri do
351
355
"file://" <> _ ->
@@ -357,7 +361,11 @@ defmodule ElixirLS.LanguageServer.Server do
357
361
state
358
362
end
359
363
360
- state = % { state | client_capabilities: client_capabilities }
364
+ state = % {
365
+ state
366
+ | client_capabilities: client_capabilities ,
367
+ server_instance_id: server_instance_id
368
+ }
361
369
362
370
# If we don't receive workspace/didChangeConfiguration for 5 seconds, use default settings
363
371
Process . send_after ( self ( ) , :default_config , 5000 )
@@ -374,7 +382,7 @@ defmodule ElixirLS.LanguageServer.Server do
374
382
Process . send_after ( self ( ) , :send_file_watchers , 100 )
375
383
end
376
384
377
- { :ok , % { "capabilities" => server_capabilities ( ) } , state }
385
+ { :ok , % { "capabilities" => server_capabilities ( server_instance_id ) } , state }
378
386
end
379
387
380
388
defp handle_request ( request ( _id , "shutdown" , _params ) , state ) do
@@ -519,7 +527,9 @@ defmodule ElixirLS.LanguageServer.Server do
519
527
520
528
defp handle_request ( code_lens_req ( _id , uri ) , state ) do
521
529
if dialyzer_enabled? ( state ) and state . settings [ "suggestSpecs" ] != false do
522
- { :async , fn -> CodeLens . code_lens ( uri , state . source_files [ uri ] . text ) end , state }
530
+ { :async ,
531
+ fn -> CodeLens . code_lens ( state . server_instance_id , uri , state . source_files [ uri ] . text ) end ,
532
+ state }
523
533
else
524
534
{ :ok , nil , state }
525
535
end
@@ -556,7 +566,7 @@ defmodule ElixirLS.LanguageServer.Server do
556
566
end )
557
567
end
558
568
559
- defp server_capabilities do
569
+ defp server_capabilities ( server_instance_id ) do
560
570
% {
561
571
"macroExpansion" => true ,
562
572
"textDocumentSync" => % {
@@ -574,7 +584,7 @@ defmodule ElixirLS.LanguageServer.Server do
574
584
"workspaceSymbolProvider" => true ,
575
585
"documentOnTypeFormattingProvider" => % { "firstTriggerCharacter" => "\n " } ,
576
586
"codeLensProvider" => % { "resolveProvider" => false } ,
577
- "executeCommandProvider" => % { "commands" => [ "spec" ] } ,
587
+ "executeCommandProvider" => % { "commands" => [ "spec: #{ server_instance_id } " ] } ,
578
588
"workspace" => % {
579
589
"workspaceFolders" => % { "supported" => true , "changeNotifications" => true }
580
590
}
0 commit comments