Skip to content

Commit e1ce165

Browse files
authored
fix: use dynamic registrations and start project node asynchronously (#30)
1 parent 43d406f commit e1ce165

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

apps/expert/lib/expert.ex

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ defmodule Expert do
1818
GenLSP.Notifications.TextDocumentDidOpen,
1919
GenLSP.Notifications.TextDocumentDidSave,
2020
GenLSP.Notifications.Exit,
21-
GenLSP.Notifications.Initialized,
2221
GenLSP.Requests.Shutdown
2322
]
2423

@@ -47,13 +46,6 @@ defmodule Expert do
4746

4847
case State.initialize(state, request) do
4948
{:ok, response, state} ->
50-
# TODO: this should be gated behind the dynamic registration in the initialization params
51-
registrations = registrations()
52-
53-
if nil != GenLSP.request(lsp, registrations) do
54-
Logger.error("Failed to register capability")
55-
end
56-
5749
lsp = assign(lsp, state: state)
5850
{:ok, response} = Expert.Protocol.Convert.to_lsp(response)
5951

@@ -119,6 +111,16 @@ defmodule Expert do
119111
end
120112
end
121113

114+
def handle_notification(%GenLSP.Notifications.Initialized{}, lsp) do
115+
registrations = registrations()
116+
117+
if nil != GenLSP.request(lsp, registrations) do
118+
Logger.error("Failed to register capability")
119+
end
120+
121+
{:noreply, lsp}
122+
end
123+
122124
def handle_notification(%mod{} = notification, lsp) when mod in @server_specific_messages do
123125
with {:ok, notification} <- Convert.to_native(notification),
124126
{:ok, state} <- apply_to_state(assigns(lsp).state, notification) do

apps/expert/lib/expert/state.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ defmodule Expert.State do
5454

5555
response = initialize_result()
5656

57-
Project.Supervisor.start(config.project)
57+
Task.start_link(fn -> Project.Supervisor.start(config.project) end)
58+
5859
{:ok, response, new_state}
5960
end
6061

0 commit comments

Comments
 (0)