Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

Commit d67e42e

Browse files
committed
refactor: update genlsp
1 parent 44f64fd commit d67e42e

File tree

13 files changed

+324
-295
lines changed

13 files changed

+324
-295
lines changed

lib/next_ls.ex

Lines changed: 246 additions & 244 deletions
Large diffs are not rendered by default.

lib/next_ls/commands/alias.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ defmodule NextLS.Commands.Alias do
1818

1919
defp opts do
2020
map(%{
21-
position: Position.schematic(),
21+
position: Position.schema(),
2222
uri: str(),
2323
text: list(str())
2424
})

lib/next_ls/commands/pipe.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ defmodule NextLS.Commands.Pipe do
1212

1313
defp opts do
1414
map(%{
15-
position: Position.schematic(),
15+
position: Position.schema(),
1616
uri: str(),
1717
text: list(str())
1818
})

lib/next_ls/extensions/credo_extension.ex

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,26 @@ defmodule NextLS.CredoExtension do
8888

8989
task =
9090
Task.Supervisor.async_nolink(state.task_supervisor, fn ->
91-
case Runtime.call(runtime, {:_next_ls_private_credo, :issues, [state.settings.cli_options, path]}) do
92-
{:ok, issues} -> issues
93-
_error -> []
94-
end
91+
{time, result} =
92+
:timer.tc(
93+
fn ->
94+
case Runtime.call(
95+
runtime,
96+
{:_next_ls_private_credo, :issues, [state.settings.cli_options, path]}
97+
) do
98+
{:ok, issues} -> issues
99+
_error -> []
100+
end
101+
end,
102+
:millisecond
103+
)
104+
105+
NextLS.Logger.info(
106+
state.logger,
107+
"[extension] Credo finished running in #{time}ms"
108+
)
109+
110+
result
95111
end)
96112

97113
{state, Map.put(refs, task.ref, namespace)}
@@ -142,6 +158,17 @@ defmodule NextLS.CredoExtension do
142158
{:noreply, put_in(state.refresh_refs, refs)}
143159
end
144160

161+
def handle_info({ref, issues}, %{refresh_refs: _refs} = state) do
162+
Process.demonitor(ref, [:flush])
163+
164+
NextLS.Logger.info(
165+
state.logger,
166+
"[extension] Credo received response from untracked ref: #{inspect(ref)} with payload: #{inspect(issues)}"
167+
)
168+
169+
{:noreply, state}
170+
end
171+
145172
def handle_info({:DOWN, ref, :process, _pid, _reason}, %{refresh_refs: refs} = state) when is_map_key(refs, ref) do
146173
{_, refs} = Map.pop(refs, ref)
147174

lib/next_ls/lsp_supervisor.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,14 @@ defmodule NextLS.LSPSupervisor do
8989
{DynamicSupervisor, name: NextLS.DynamicSupervisor},
9090
{Task.Supervisor, name: NextLS.TaskSupervisor},
9191
{Task.Supervisor, name: :runtime_task_supervisor},
92+
{GenLSP.Assigns, [name: NextLS.Assigns]},
9293
{GenLSP.Buffer, [name: NextLS.Buffer] ++ buffer_opts},
9394
{NextLS.DiagnosticCache, name: :diagnostic_cache},
9495
{Registry, name: NextLS.Registry, keys: :duplicate},
9596
{NextLS,
9697
auto_update: auto_update,
9798
buffer: NextLS.Buffer,
99+
assigns: NextLS.Assigns,
98100
cache: :diagnostic_cache,
99101
task_supervisor: NextLS.TaskSupervisor,
100102
runtime_task_supervisor: :runtime_task_supervisor,

lib/next_ls/progress.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
defmodule NextLS.Progress do
22
@moduledoc false
33

4+
import GenLSP.LSP
5+
46
alias GenLSP.Notifications.DollarProgress
57
alias GenLSP.Structures.ProgressParams
68

79
def start(lsp, token, msg) do
810
Task.start(fn ->
9-
if lsp.assigns.client_capabilities.window.work_done_progress do
11+
if assigns(lsp).client_capabilities.window.work_done_progress do
1012
GenLSP.request(lsp, %GenLSP.Requests.WindowWorkDoneProgressCreate{
1113
id: System.unique_integer([:positive]),
1214
params: %GenLSP.Structures.WorkDoneProgressCreateParams{

lib/next_ls/runtime.ex

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -321,37 +321,41 @@ defmodule NextLS.Runtime do
321321
{:reply, {:error, :not_ready}, state}
322322
end
323323

324-
def handle_call({:call, {m, f, a}, ctx}, _from, %{node: node} = state) do
325-
token = OpenTelemetry.Ctx.attach(ctx)
324+
def handle_call({:call, {m, f, a}, _ctx}, from, %{node: node} = state) do
325+
Task.start_link(fn ->
326+
reply = :rpc.call(node, m, f, a)
327+
GenServer.reply(from, {:ok, reply})
328+
end)
326329

327-
try do
328-
Tracer.with_span :"runtime.call", %{attributes: %{mfa: inspect({m, f, a})}} do
329-
reply = :rpc.call(node, m, f, a)
330-
{:reply, {:ok, reply}, state}
331-
end
332-
after
333-
OpenTelemetry.Ctx.detach(token)
334-
end
330+
{:noreply, state}
335331
end
336332

337-
def handle_call({:expand, ast, file}, _from, %{node: node} = state) do
338-
NextLS.Logger.info(state.logger, "expanding on the runtime node")
339-
reply = :rpc.call(node, :_next_ls_private_spitfire_env, :expand, [ast, file])
340-
{:reply, {:ok, reply}, state}
333+
def handle_call({:expand, ast, file}, from, %{node: node} = state) do
334+
Task.start_link(fn ->
335+
NextLS.Logger.info(state.logger, "expanding on the runtime node")
336+
reply = :rpc.call(node, :_next_ls_private_spitfire_env, :expand, [ast, file])
337+
GenServer.reply(from, {:ok, reply})
338+
end)
339+
340+
{:noreply, state}
341341
end
342342

343-
def handle_call({:compile, opts}, _from, %{node: node} = state) do
343+
def handle_call({:compile, opts}, from, %{node: node} = state) do
344344
opts =
345345
opts
346346
|> Keyword.put_new(:working_dir, state.working_dir)
347347
|> Keyword.put_new(:registry, state.registry)
348348
|> Keyword.put(:from, self())
349349

350-
with {:badrpc, error} <- :rpc.call(node, :_next_ls_private_compiler_worker, :enqueue_compiler, [opts]) do
351-
NextLS.Logger.error(state.logger, "Bad RPC call to node #{node}: #{inspect(error)}")
352-
end
350+
Task.start_link(fn ->
351+
with {:badrpc, error} <- :rpc.call(node, :_next_ls_private_compiler_worker, :enqueue_compiler, [opts]) do
352+
NextLS.Logger.error(state.logger, "Bad RPC call to node #{node}: #{inspect(error)}")
353+
end
353354

354-
{:reply, :ok, state}
355+
GenServer.reply(from, :ok)
356+
end)
357+
358+
{:noreply, state}
355359
end
356360

357361
@impl GenServer

mix.exs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
defmodule NextLS.MixProject do
22
use Mix.Project
33

4-
@version "0.23.3" # x-release-please-version
4+
# x-release-please-version
5+
@version "0.23.3"
56

67
def project do
78
[
@@ -63,8 +64,9 @@ defmodule NextLS.MixProject do
6364
defp deps do
6465
[
6566
{:exqlite, "~> 0.13.14"},
66-
{:gen_lsp, "~> 0.10"},
67+
{:gen_lsp, "~> 0.11"},
6768
# {:gen_lsp, path: "../gen_lsp"},
69+
# {:gen_lsp, github: "elixir-tools/gen_lsp", branch: "async"},
6870
{:req, "~> 0.3"},
6971
{:schematic, "~> 0.2"},
7072
{:spitfire, github: "elixir-tools/spitfire"},

mix.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
"exqlite": {:hex, :exqlite, "0.13.15", "a32c0763915e2b0d7ced9dd8638802d38e9569053f3b28b815bd0faef1cbe6d9", [:make, :mix], [{:cc_precompiler, "~> 0.1", [hex: :cc_precompiler, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "4afcc870a33b57781a1e57cd4294eef68815059d26b774c7cd075536b21434b7"},
2121
"file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"},
2222
"finch": {:hex, :finch, "0.18.0", "944ac7d34d0bd2ac8998f79f7a811b21d87d911e77a786bc5810adb75632ada4", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.3", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 0.2.6 or ~> 1.0", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "69f5045b042e531e53edc2574f15e25e735b522c37e2ddb766e15b979e03aa65"},
23-
"gen_lsp": {:hex, :gen_lsp, "0.10.0", "f6da076b5ccedf937d17aa9743635a2c3d0f31265c853e58b02ab84d71852270", [: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", "768f8f7b5c5e218fb36dcebd30dcd6275b61ca77052c98c3c4c0375158392c4a"},
23+
"gen_lsp": {:hex, :gen_lsp, "0.11.0", "9eda4d2fcaff94d9b3062e322fcf524c176db1502f584a3cff6135088b46084b", [: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", "d67c20650a5290a02f7bac53083ac4487d3c6b461f35a8b14c5d2d7638c20d26"},
2424
"gproc": {:hex, :gproc, "0.9.1", "f1df0364423539cf0b80e8201c8b1839e229e5f9b3ccb944c5834626998f5b8c", [:rebar3], [], "hexpm", "905088e32e72127ed9466f0bac0d8e65704ca5e73ee5a62cb073c3117916d507"},
2525
"grpcbox": {:hex, :grpcbox, "0.17.1", "6e040ab3ef16fe699ffb513b0ef8e2e896da7b18931a1ef817143037c454bcce", [:rebar3], [{:acceptor_pool, "~> 1.0.0", [hex: :acceptor_pool, repo: "hexpm", optional: false]}, {:chatterbox, "~> 0.15.1", [hex: :ts_chatterbox, repo: "hexpm", optional: false]}, {:ctx, "~> 0.6.0", [hex: :ctx, repo: "hexpm", optional: false]}, {:gproc, "~> 0.9.1", [hex: :gproc, repo: "hexpm", optional: false]}], "hexpm", "4a3b5d7111daabc569dc9cbd9b202a3237d81c80bf97212fbc676832cb0ceb17"},
2626
"hpack": {:hex, :hpack_erl, "0.3.0", "2461899cc4ab6a0ef8e970c1661c5fc6a52d3c25580bc6dd204f84ce94669926", [:rebar3], [], "hexpm", "d6137d7079169d8c485c6962dfe261af5b9ef60fbc557344511c1e65e3d95fb0"},
2727
"hpax": {:hex, :hpax, "0.1.2", "09a75600d9d8bbd064cdd741f21fc06fc1f4cf3d0fcc335e5aa19be1a7235c84", [:mix], [], "hexpm", "2c87843d5a23f5f16748ebe77969880e29809580efdaccd615cd3bed628a8c13"},
28-
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
28+
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
2929
"makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"},
3030
"makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"},
3131
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
@@ -50,7 +50,7 @@
5050
"spitfire": {:git, "https://github.com/elixir-tools/spitfire.git", "178b00becd55b33e080f23c9ed0d1126d57574be", []},
5151
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"},
5252
"styler": {:hex, :styler, "1.0.0-rc.0", "977c702b91b11e86ae1995f0f699a372a43e8df175f4878d7e9cc1678d0d7513", [:mix], [], "hexpm", "031624294295d47af7859ef43595092f33b861f0a88e44fae6366a54f1736a1a"},
53-
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
53+
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
5454
"telemetry_registry": {:hex, :telemetry_registry, "0.3.1", "14a3319a7d9027bdbff7ebcacf1a438f5f5c903057b93aee484cca26f05bdcba", [:mix, :rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "6d0ca77b691cf854ed074b459a93b87f4c7f5512f8f7743c635ca83da81f939e"},
5555
"tls_certificate_check": {:hex, :tls_certificate_check, "1.20.0", "1ac0c53f95e201feb8d398ef9d764ae74175231289d89f166ba88a7f50cd8e73", [:rebar3], [{:ssl_verify_fun, "~> 1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "ab57b74b1a63dc5775650699a3ec032ec0065005eff1f020818742b7312a8426"},
5656
"typed_struct": {:hex, :typed_struct, "0.3.0", "939789e3c1dca39d7170c87f729127469d1315dcf99fee8e152bb774b17e7ff7", [:mix], [], "hexpm", "c50bd5c3a61fe4e198a8504f939be3d3c85903b382bde4865579bc23111d1b6d"},

test/next_ls/completions_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ defmodule NextLS.CompletionsTest do
214214
}
215215

216216
assert_result 2, [
217-
%{"data" => nil, "documentation" => "", "insertText" => "one", "kind" => 5, "label" => "one"},
218217
%{"data" => nil, "documentation" => "", "insertText" => "two", "kind" => 5, "label" => "two"},
219-
%{"data" => nil, "documentation" => "", "insertText" => "three", "kind" => 5, "label" => "three"}
218+
%{"data" => nil, "documentation" => "", "insertText" => "three", "kind" => 5, "label" => "three"},
219+
%{"data" => nil, "documentation" => "", "insertText" => "one", "kind" => 5, "label" => "one"}
220220
]
221221
end
222222

0 commit comments

Comments
 (0)