Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions lib/next_ls/lsp_supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ defmodule NextLS.LSPSupervisor do

@env Mix.env()

defmodule OptionsError do
@moduledoc false
defexception [:message]

@impl true
def exception(options) do
msg = """
Unknown Options: #{Enum.map_join(options, " ", fn {k, v} -> "#{k} #{v}" end)}

Valid options:

--stdio Starts the server using stdio
--port port-number Starts the server using TCP on the given port
"""

%OptionsError{message: msg}
end
end

def start_link(init_arg) do
Supervisor.start_link(__MODULE__, init_arg, name: __MODULE__)
end
Expand All @@ -14,8 +33,8 @@ defmodule NextLS.LSPSupervisor do
if @env == :test do
:ignore
else
{opts, _} =
OptionParser.parse!(System.argv(),
{opts, _, invalid} =
OptionParser.parse(System.argv(),
strict: [stdio: :boolean, port: :integer]
)

Expand All @@ -29,7 +48,7 @@ defmodule NextLS.LSPSupervisor do
[communication: {GenLSP.Communication.TCP, [port: opts[:port]]}]

true ->
raise "Unknown option"
raise OptionsError, invalid
end

children = [
Expand Down