Skip to content

Commit 2fc8454

Browse files
committed
example branch that implements the proposed handle_continue for gen_lsp
1 parent ed03d80 commit 2fc8454

File tree

8 files changed

+25
-20
lines changed

8 files changed

+25
-20
lines changed

apps/engine/mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ defmodule Engine.MixProject do
5151
{:elixir_sense,
5252
github: "elixir-lsp/elixir_sense", ref: "e3ddc403554050221a2fd19a10a896fa7525bc02"},
5353
{:forge, path: "../forge"},
54-
{:gen_lsp, "~> 0.11"},
54+
{:gen_lsp, github: "Moosieus/gen_lsp", branch: "moo/handle-continue"},
5555
{:patch, "~> 0.15", only: [:dev, :test], runtime: false},
5656
{:path_glob, "~> 0.2"},
5757
{:phoenix_live_view, "~> 1.0", only: [:test], runtime: false},

apps/engine/mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"elixir_sense": {:git, "https://github.com/elixir-lsp/elixir_sense.git", "e3ddc403554050221a2fd19a10a896fa7525bc02", [ref: "e3ddc403554050221a2fd19a10a896fa7525bc02"]},
1010
"erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"},
1111
"file_system": {:hex, :file_system, "1.1.0", "08d232062284546c6c34426997dd7ef6ec9f8bbd090eb91780283c9016840e8f", [:mix], [], "hexpm", "bfcf81244f416871f2a2e15c1b515287faa5db9c6bcf290222206d120b3d43f6"},
12-
"gen_lsp": {:hex, :gen_lsp, "0.11.2", "bbed3bcc9388b64f1581f0d5b75d28d291eb8379438738afd12924ab630547a4", [:mix], [{:jason, "~> 1.3", [hex: :jason, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.5 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:schematic, "~> 0.2.1", [hex: :schematic, repo: "hexpm", optional: false]}, {:typed_struct, "~> 0.3.0", [hex: :typed_struct, repo: "hexpm", optional: false]}], "hexpm", "7a5ccf2403d368a82ffa968ec3993f30d41f4bc2837c69c068ed08c598340a4d"},
12+
"gen_lsp": {:git, "https://github.com/Moosieus/gen_lsp.git", "ab57bd8ff028a9e04ef0c241d4acc73d1f8cd796", [branch: "moo/handle-continue"]},
1313
"hpax": {:hex, :hpax, "1.0.3", "ed67ef51ad4df91e75cc6a1494f851850c0bd98ebc0be6e81b026e765ee535aa", [:mix], [], "hexpm", "8eab6e1cfa8d5918c2ce4ba43588e894af35dbd8e91e6e55c817bca5847df34a"},
1414
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
1515
"mime": {:hex, :mime, "2.0.6", "8f18486773d9b15f95f4f4f1e39b710045fa1de891fada4516559967276e4dc2", [:mix], [], "hexpm", "c9945363a6b26d747389aac3643f8e0e09d30499a138ad64fe8fd1d13d9b153e"},

apps/expert/lib/expert.ex

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,19 @@ defmodule Expert do
4646
)
4747
end
4848

49+
@impl GenLSP
4950
def init(lsp, _args) do
5051
:persistent_term.put(:expert_lsp, lsp)
5152
{:ok, assign(lsp, state: State.new())}
5253
end
5354

55+
@impl GenLSP
5456
def handle_request(%GenLSP.Requests.Initialize{} = request, lsp) do
5557
state = assigns(lsp).state
5658

5759
with {:ok, response, state} <- State.initialize(state, request),
5860
{:ok, response} <- Expert.Protocol.Convert.to_lsp(response) do
59-
Task.Supervisor.start_child(:expert_task_queue, fn ->
60-
# dirty sleep to allow initialize response to return before progress reports
61-
Process.sleep(50)
62-
config = state.configuration
63-
64-
log_info(lsp, "Starting project")
65-
66-
start_result = Project.Supervisor.start(config.project)
67-
68-
send(Expert, {:engine_initialized, start_result})
69-
end)
70-
71-
{:reply, response, assign(lsp, state: state)}
61+
{:reply, response, assign(lsp, state: state), {:continue, :start_project}}
7262
else
7363
{:error, :already_initialized} ->
7464
response = %GenLSP.ErrorResponse{
@@ -147,6 +137,21 @@ defmodule Expert do
147137
end
148138
end
149139

140+
@impl GenLSP
141+
def handle_continue(:start_project, lsp) do
142+
state = assigns(lsp).state
143+
config = state.configuration
144+
145+
log_info(lsp, "Starting project")
146+
147+
start_result = Project.Supervisor.start(config.project)
148+
149+
send(Expert, {:engine_initialized, start_result})
150+
151+
{:noreply, lsp}
152+
end
153+
154+
@impl GenLSP
150155
def handle_notification(%GenLSP.Notifications.Initialized{}, lsp) do
151156
registrations = registrations()
152157

apps/expert/mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ defmodule Expert.MixProject do
8686
# assume a roundtrip to a project node is made.
8787
{:engine, path: "../engine", only: [:test]},
8888
{:forge, path: "../forge"},
89-
{:gen_lsp, "~> 0.11"},
89+
{:gen_lsp, github: "Moosieus/gen_lsp", branch: "moo/handle-continue"},
9090
{:jason, "~> 1.4"},
9191
{:logger_file_backend, "~> 0.0", only: [:dev, :prod]},
9292
{:patch, "~> 0.15", runtime: false, only: [:dev, :test]},

apps/expert/mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"},
99
"file_system": {:hex, :file_system, "1.1.0", "08d232062284546c6c34426997dd7ef6ec9f8bbd090eb91780283c9016840e8f", [:mix], [], "hexpm", "bfcf81244f416871f2a2e15c1b515287faa5db9c6bcf290222206d120b3d43f6"},
1010
"finch": {:hex, :finch, "0.20.0", "5330aefb6b010f424dcbbc4615d914e9e3deae40095e73ab0c1bb0968933cadf", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.6.2 or ~> 1.7", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 1.1", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2658131a74d051aabfcba936093c903b8e89da9a1b63e430bee62045fa9b2ee2"},
11-
"gen_lsp": {:hex, :gen_lsp, "0.11.2", "bbed3bcc9388b64f1581f0d5b75d28d291eb8379438738afd12924ab630547a4", [:mix], [{:jason, "~> 1.3", [hex: :jason, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.5 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:schematic, "~> 0.2.1", [hex: :schematic, repo: "hexpm", optional: false]}, {:typed_struct, "~> 0.3.0", [hex: :typed_struct, repo: "hexpm", optional: false]}], "hexpm", "7a5ccf2403d368a82ffa968ec3993f30d41f4bc2837c69c068ed08c598340a4d"},
11+
"gen_lsp": {:git, "https://github.com/Moosieus/gen_lsp.git", "ab57bd8ff028a9e04ef0c241d4acc73d1f8cd796", [branch: "moo/handle-continue"]},
1212
"hpax": {:hex, :hpax, "1.0.3", "ed67ef51ad4df91e75cc6a1494f851850c0bd98ebc0be6e81b026e765ee535aa", [:mix], [], "hexpm", "8eab6e1cfa8d5918c2ce4ba43588e894af35dbd8e91e6e55c817bca5847df34a"},
1313
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
1414
"logger_file_backend": {:hex, :logger_file_backend, "0.0.14", "774bb661f1c3fed51b624d2859180c01e386eb1273dc22de4f4a155ef749a602", [:mix], [], "hexpm", "071354a18196468f3904ef09413af20971d55164267427f6257b52cfba03f9e6"},

apps/expert_credo/mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"},
88
"ex_doc": {:hex, :ex_doc, "0.37.2", "2a3aa7014094f0e4e286a82aa5194a34dd17057160988b8509b15aa6c292720c", [:mix], [{:earmark_parser, "~> 1.4.42", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "4dfa56075ce4887e4e8b1dcc121cd5fcb0f02b00391fd367ff5336d98fa49049"},
99
"file_system": {:hex, :file_system, "1.1.0", "08d232062284546c6c34426997dd7ef6ec9f8bbd090eb91780283c9016840e8f", [:mix], [], "hexpm", "bfcf81244f416871f2a2e15c1b515287faa5db9c6bcf290222206d120b3d43f6"},
10-
"gen_lsp": {:hex, :gen_lsp, "0.11.2", "bbed3bcc9388b64f1581f0d5b75d28d291eb8379438738afd12924ab630547a4", [:mix], [{:jason, "~> 1.3", [hex: :jason, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.5 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:schematic, "~> 0.2.1", [hex: :schematic, repo: "hexpm", optional: false]}, {:typed_struct, "~> 0.3.0", [hex: :typed_struct, repo: "hexpm", optional: false]}], "hexpm", "7a5ccf2403d368a82ffa968ec3993f30d41f4bc2837c69c068ed08c598340a4d"},
10+
"gen_lsp": {:git, "https://github.com/Moosieus/gen_lsp.git", "ab57bd8ff028a9e04ef0c241d4acc73d1f8cd796", [branch: "moo/handle-continue"]},
1111
"hpax": {:hex, :hpax, "1.0.3", "ed67ef51ad4df91e75cc6a1494f851850c0bd98ebc0be6e81b026e765ee535aa", [:mix], [], "hexpm", "8eab6e1cfa8d5918c2ce4ba43588e894af35dbd8e91e6e55c817bca5847df34a"},
1212
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
1313
"makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"},

apps/forge/mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ defmodule Forge.MixProject do
3939
Mix.Credo.dependency(),
4040
Mix.Dialyzer.dependency(),
4141
{:deps_nix, "~> 2.4", only: :dev},
42-
{:gen_lsp, "~> 0.11"},
42+
{:gen_lsp, github: "Moosieus/gen_lsp", branch: "moo/handle-continue"},
4343
{:snowflake, "~> 1.0"},
4444
{:sourceror, "~> 1.9"},
4545
{:stream_data, "~> 1.1", only: [:test], runtime: false},

apps/forge/mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dialyxir": {:hex, :dialyxir, "1.4.5", "ca1571ac18e0f88d4ab245f0b60fa31ff1b12cbae2b11bd25d207f865e8ae78a", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b0fb08bb8107c750db5c0b324fa2df5ceaa0f9307690ee3c1f6ba5b9eb5d35c3"},
88
"erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"},
99
"file_system": {:hex, :file_system, "1.1.0", "08d232062284546c6c34426997dd7ef6ec9f8bbd090eb91780283c9016840e8f", [:mix], [], "hexpm", "bfcf81244f416871f2a2e15c1b515287faa5db9c6bcf290222206d120b3d43f6"},
10-
"gen_lsp": {:hex, :gen_lsp, "0.11.2", "bbed3bcc9388b64f1581f0d5b75d28d291eb8379438738afd12924ab630547a4", [:mix], [{:jason, "~> 1.3", [hex: :jason, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.5 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:schematic, "~> 0.2.1", [hex: :schematic, repo: "hexpm", optional: false]}, {:typed_struct, "~> 0.3.0", [hex: :typed_struct, repo: "hexpm", optional: false]}], "hexpm", "7a5ccf2403d368a82ffa968ec3993f30d41f4bc2837c69c068ed08c598340a4d"},
10+
"gen_lsp": {:git, "https://github.com/Moosieus/gen_lsp.git", "ab57bd8ff028a9e04ef0c241d4acc73d1f8cd796", [branch: "moo/handle-continue"]},
1111
"hpax": {:hex, :hpax, "1.0.3", "ed67ef51ad4df91e75cc6a1494f851850c0bd98ebc0be6e81b026e765ee535aa", [:mix], [], "hexpm", "8eab6e1cfa8d5918c2ce4ba43588e894af35dbd8e91e6e55c817bca5847df34a"},
1212
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
1313
"mint": {:hex, :mint, "1.7.1", "113fdb2b2f3b59e47c7955971854641c61f378549d73e829e1768de90fc1abf1", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1 or ~> 0.2.0 or ~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "fceba0a4d0f24301ddee3024ae116df1c3f4bb7a563a731f45fdfeb9d39a231b"},

0 commit comments

Comments
 (0)