-
-
Notifications
You must be signed in to change notification settings - Fork 33
Use GenLSP data structures #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
5644547
to
e4cb2d7
Compare
You're a beast |
Don't be sad because they're gone, be happy because they were here
I'm not familiar with the background for this regression test so I'm just making it pass. It is very likely this change doesn't test the same thing it tested before, but I can't tell
range: root.range, | ||
selection_range: root.detail_range |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@doorgan looks like this is still a Forge range, needs to be converted to a GenLSP.Structures.Range
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is converted here:
expert/apps/expert/lib/expert/transport/std_io.ex
Lines 25 to 107 in 1b42e49
def write(io_device, %_{} = payload) do | |
with {:ok, lsp} <- encode(payload), | |
{:ok, json} <- Jason.encode(lsp) do | |
write(io_device, json) | |
end | |
end | |
def write(io_device, %{} = payload) do | |
with {:ok, encoded} <- Jason.encode(payload) do | |
write(io_device, encoded) | |
end | |
end | |
def write(io_device, payload) when is_binary(payload) do | |
message = | |
case io_device do | |
device when device in [:stdio, :standard_io] or is_pid(device) -> | |
{:ok, json_rpc} = JsonRpc.encode(payload) | |
json_rpc | |
_ -> | |
payload | |
end | |
IO.binwrite(io_device, message) | |
end | |
def write(_, nil) do | |
end | |
def write(_, []) do | |
end | |
defp encode(%{id: id, result: result}) do | |
with {:ok, result} <- dump_lsp(result) do | |
{:ok, | |
%{ | |
"jsonrpc" => "2.0", | |
"id" => id, | |
"result" => result | |
}} | |
end | |
end | |
defp encode(%{id: id, error: error}) do | |
with {:ok, error} <- dump_lsp(error) do | |
{:ok, | |
%{ | |
"jsonrpc" => "2.0", | |
"id" => id, | |
"error" => error | |
}} | |
end | |
end | |
defp encode(%_{} = request) do | |
dump_lsp(request) | |
end | |
defp dump_lsp(%module{} = item) do | |
with {:ok, item} <- Convert.to_lsp(item), | |
{:ok, item} <- Schematic.dump(module.schematic(), item) do | |
{:ok, item} | |
end | |
end | |
defp dump_lsp(list) when is_list(list) do | |
dump = | |
Enum.map(list, fn item -> | |
case dump_lsp(item) do | |
{:ok, dumped} -> dumped | |
{:error, reason} -> throw({:error, reason}) | |
end | |
end) | |
{:ok, dump} | |
catch | |
{:error, reason} -> | |
{:error, reason} | |
end | |
defp dump_lsp(other), do: {:ok, other} | |
Conversely, they are converted from genlsp to forge here:
expert/apps/expert/lib/expert.ex
Lines 129 to 130 in 1b42e49
{:ok, request} <- Convert.to_native(request) do | |
# Logger.info("Handling request: #{inspect(request, pretty: true)}") |
I think we'd need to do what I'm doing in std_io
somewhere in expert.ex
when using genlsp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was about to comment back, I realized I deleted the code that did the conversion.
I'll get it converted again
The tests read "on compile" but the test code was not simulating a compilation, causing the diagnostics to not be pruned
21ada8c
to
6813b52
Compare
Been using this branch for a while with no issues, so I'm merging it |
This change replaces the use of
Lexical.Protocol
data structures for theGenLSP
counterparts, and handles conversion between those and the internal data structures for ranges, positions and locations. Since neitherProto
norProtocol
are really needed after this change, I also removed them altogether and consolidated the few modules we do need for them into theForge
application.This PR needs GenLSP support for cancellation before it can be reviewed/merged
Besides cleanups in general and removal of dead code, currently there are a few issues I'm working on:
On neovim, completions for module segments after thefixed.
not always show, but they are recognized once you start typing after the dotOn VSCode, code actions are not being recognized(but they are and work properly on neovim)fixedOn neovim, workspace symbols don't show up but they do show up in VSCodehappens on main tooOther than that, expert using this pr is functional