From 4e69b87d2565814aa4e110e0395e3fabf188e143 Mon Sep 17 00:00:00 2001 From: Jon Carstens Date: Wed, 15 Nov 2023 06:20:23 -0700 Subject: [PATCH] Initial start for handling mix dep errors --- lib/next_ls.ex | 16 ++++++++++++++++ lib/next_ls/runtime.ex | 9 +++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/next_ls.ex b/lib/next_ls.ex index 7ba9440d..c4a82d2a 100644 --- a/lib/next_ls.ex +++ b/lib/next_ls.ex @@ -675,6 +675,22 @@ defmodule NextLS do send(parent, msg) else Progress.stop(lsp, token) + + if status == {:error, :deps}, + do: + GenLSP.request(lsp, %GenLSP.Requests.WindowShowMessageRequest{ + id: System.unique_integer([:positive]), + params: %GenLSP.Structures.ShowMessageRequestParams{ + type: GenLSP.Enumerations.MessageType.error(), + message: + "The NextLS runtime failed with errors on dependencies. Would you like to re-fetch them?", + actions: [ + %GenLSP.Structures.MessageActionItem{title: "yes"}, + %GenLSP.Structures.MessageActionItem{title: "no"} + ] + } + }) + GenLSP.error(lsp, "[NextLS] Runtime for folder #{name} failed to initialize") end end, diff --git a/lib/next_ls/runtime.ex b/lib/next_ls/runtime.ex index 6196c250..710dc69b 100644 --- a/lib/next_ls/runtime.ex +++ b/lib/next_ls/runtime.ex @@ -311,6 +311,15 @@ defmodule NextLS.Runtime do {:stop, {:shutdown, :nodedown}, state} end + def handle_info( + {port, {:data, "** (Mix) Can't continue due to errors on dependencies" <> _ = data}}, + %{port: port} = state + ) do + NextLS.Logger.log(state.logger, data) + state.on_initialized.({:error, :deps}) + {:noreply, state} + end + def handle_info({port, {:data, data}}, %{port: port} = state) do NextLS.Logger.log(state.logger, data) {:noreply, state}