Skip to content

Commit

Permalink
fix: add type to workspace symbol (#67)
Browse files Browse the repository at this point in the history
this will make it easier to see if something is a function or macro.

still need to add the parameters in there as well
  • Loading branch information
mhanberg committed Jun 27, 2023
1 parent 202a906 commit 905ff62
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
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

0 comments on commit 905ff62

Please sign in to comment.