Skip to content
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

fix: add type to workspace symbol #67

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion lib/next_ls.ex
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,15 @@ defmodule NextLS do

symbols =
for %SymbolTable.Symbol{} = symbol <- SymbolTable.symbols(lsp.assigns.symbol_table), filter.(symbol.name) do
name =
if symbol.type != :defstruct do
"#{symbol.type} #{symbol.name}"
else
"#{symbol.name}"
end

%SymbolInformation{
name: to_string(symbol.name),
name: name,
kind: elixir_kind_to_lsp_kind(symbol.type),
location: %Location{
uri: "file://#{symbol.file}",
Expand Down
10 changes: 5 additions & 5 deletions test/next_ls_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ defmodule NextLSTest do
},
"uri" => "file://#{cwd}/lib/bar.ex"
},
"name" => "foo"
"name" => "def foo"
} in symbols

assert %{
Expand All @@ -360,7 +360,7 @@ defmodule NextLSTest do
},
"uri" => "file://#{cwd}/lib/bar.ex"
},
"name" => "Bar"
"name" => "defmodule Bar"
} in symbols

assert %{
Expand Down Expand Up @@ -396,7 +396,7 @@ defmodule NextLSTest do
},
"uri" => "file://#{cwd}/lib/code_action.ex"
},
"name" => "Foo.CodeAction.NestedMod"
"name" => "defmodule Foo.CodeAction.NestedMod"
} in symbols
end

Expand Down Expand Up @@ -438,7 +438,7 @@ defmodule NextLSTest do
},
"uri" => "file://#{cwd}/lib/bar.ex"
},
"name" => "foo"
"name" => "def foo"
},
%{
"kind" => 12,
Expand All @@ -455,7 +455,7 @@ defmodule NextLSTest do
},
"uri" => "file://#{cwd}/lib/code_action.ex"
},
"name" => "foo"
"name" => "def foo"
}
] == symbols
end
Expand Down