Skip to content

Commit

Permalink
Initial start for handling mix dep errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jjcarstens committed Nov 15, 2023
1 parent cc0bf62 commit 4e69b87
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/next_ls.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions lib/next_ls/runtime.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 4e69b87

Please sign in to comment.