diff --git a/apps/expert/lib/expert.ex b/apps/expert/lib/expert.ex index ab033f4a..55d58e8c 100644 --- a/apps/expert/lib/expert.ex +++ b/apps/expert/lib/expert.ex @@ -18,7 +18,6 @@ defmodule Expert do GenLSP.Notifications.TextDocumentDidOpen, GenLSP.Notifications.TextDocumentDidSave, GenLSP.Notifications.Exit, - GenLSP.Notifications.Initialized, GenLSP.Requests.Shutdown ] @@ -47,13 +46,6 @@ defmodule Expert do case State.initialize(state, request) do {:ok, response, state} -> - # TODO: this should be gated behind the dynamic registration in the initialization params - registrations = registrations() - - if nil != GenLSP.request(lsp, registrations) do - Logger.error("Failed to register capability") - end - lsp = assign(lsp, state: state) {:ok, response} = Forge.Protocol.Convert.to_lsp(response) @@ -119,6 +111,16 @@ defmodule Expert do end end + def handle_notification(%GenLSP.Notifications.Initialized{}, lsp) do + registrations = registrations() + + if nil != GenLSP.request(lsp, registrations) do + Logger.error("Failed to register capability") + end + + {:noreply, lsp} + end + def handle_notification(%mod{} = notification, lsp) when mod in @server_specific_messages do with {:ok, notification} <- Convert.to_native(notification), {:ok, state} <- apply_to_state(assigns(lsp).state, notification) do diff --git a/apps/expert/lib/expert/state.ex b/apps/expert/lib/expert/state.ex index c17a54b8..b9bd5f23 100644 --- a/apps/expert/lib/expert/state.ex +++ b/apps/expert/lib/expert/state.ex @@ -54,7 +54,8 @@ defmodule Expert.State do response = initialize_result() - Project.Supervisor.start(config.project) + Task.start_link(fn -> Project.Supervisor.start(config.project) end) + {:ok, response, new_state} end