@@ -21,7 +21,7 @@ defmodule Lexical.Server.Configuration do
21
21
def new ( root_uri , % ClientCapabilities { } = client_capabilities ) do
22
22
support = Support . new ( client_capabilities )
23
23
project = Project . new ( root_uri )
24
- % __MODULE__ { support: support , project: project }
24
+ % __MODULE__ { support: support , project: project } |> tap ( & set / 1 )
25
25
end
26
26
27
27
@ spec default ( t | nil ) ::
@@ -53,20 +53,11 @@ defmodule Lexical.Server.Configuration do
53
53
end
54
54
55
55
defp apply_config_change ( % __MODULE__ { } = old_config , % { } = settings ) do
56
- with { :ok , new_config } <- maybe_set_env_vars ( old_config , settings ) ,
57
- { :ok , new_config } <- maybe_enable_dialyzer ( new_config , settings ) do
56
+ with { :ok , new_config } <- maybe_enable_dialyzer ( old_config , settings ) do
58
57
maybe_add_watched_extensions ( new_config , settings )
59
58
end
60
59
end
61
60
62
- defp maybe_set_env_vars ( % __MODULE__ { } = old_config , settings ) do
63
- env_vars = Map . get ( settings , "envVariables" )
64
-
65
- with { :ok , new_project } <- Project . set_env_vars ( old_config . project , env_vars ) do
66
- { :ok , % __MODULE__ { old_config | project: new_project } }
67
- end
68
- end
69
-
70
61
defp maybe_enable_dialyzer ( % __MODULE__ { } = old_config , settings ) do
71
62
enabled? =
72
63
case Dialyzer . check_support ( ) do
@@ -110,4 +101,18 @@ defmodule Lexical.Server.Configuration do
110
101
defp maybe_add_watched_extensions ( % __MODULE__ { } = old_config , _ ) do
111
102
{ :ok , old_config }
112
103
end
104
+
105
+ @ supports_keys ~w( work_done_progress?) a
106
+
107
+ def supports? ( key ) when key in @ supports_keys do
108
+ get_in ( get ( ) , [ Access . key ( :support ) , Access . key ( key ) ] ) || false
109
+ end
110
+
111
+ def get do
112
+ :persistent_term . get ( __MODULE__ , % __MODULE__ { } )
113
+ end
114
+
115
+ defp set ( % __MODULE__ { } = config ) do
116
+ :persistent_term . put ( __MODULE__ , config )
117
+ end
113
118
end
0 commit comments