Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

Commit eaadcc5

Browse files
committed
fix: add type to workspace symbol
this will make it easier to see if something is a function or macro. still need to add the parameters in there as well
1 parent ea442a2 commit eaadcc5

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

lib/next_ls.ex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,15 @@ defmodule NextLS do
115115

116116
symbols =
117117
for %SymbolTable.Symbol{} = symbol <- SymbolTable.symbols(lsp.assigns.symbol_table), filter.(symbol.name) do
118+
name =
119+
if symbol.type != :defstruct do
120+
"#{symbol.type} #{symbol.name}"
121+
else
122+
"#{symbol.name}"
123+
end
124+
118125
%SymbolInformation{
119-
name: to_string(symbol.name),
126+
name: name,
120127
kind: elixir_kind_to_lsp_kind(symbol.type),
121128
location: %Location{
122129
uri: "file://#{symbol.file}",

test/next_ls_test.exs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ defmodule NextLSTest do
342342
},
343343
"uri" => "file://#{cwd}/lib/bar.ex"
344344
},
345-
"name" => "foo"
345+
"name" => "def foo"
346346
} in symbols
347347

348348
assert %{
@@ -360,7 +360,7 @@ defmodule NextLSTest do
360360
},
361361
"uri" => "file://#{cwd}/lib/bar.ex"
362362
},
363-
"name" => "Bar"
363+
"name" => "defmodule Bar"
364364
} in symbols
365365

366366
assert %{
@@ -396,7 +396,7 @@ defmodule NextLSTest do
396396
},
397397
"uri" => "file://#{cwd}/lib/code_action.ex"
398398
},
399-
"name" => "Foo.CodeAction.NestedMod"
399+
"name" => "defmodule Foo.CodeAction.NestedMod"
400400
} in symbols
401401
end
402402

@@ -438,7 +438,7 @@ defmodule NextLSTest do
438438
},
439439
"uri" => "file://#{cwd}/lib/bar.ex"
440440
},
441-
"name" => "foo"
441+
"name" => "def foo"
442442
},
443443
%{
444444
"kind" => 12,
@@ -455,7 +455,7 @@ defmodule NextLSTest do
455455
},
456456
"uri" => "file://#{cwd}/lib/code_action.ex"
457457
},
458-
"name" => "foo"
458+
"name" => "def foo"
459459
}
460460
] == symbols
461461
end

0 commit comments

Comments
 (0)