From a9a61f1b372d1aa81d5bcb3220838103ca1b70de Mon Sep 17 00:00:00 2001 From: Mitchell Hanberg Date: Tue, 27 Jun 2023 00:27:39 -0400 Subject: [PATCH] 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 --- lib/next_ls.ex | 9 ++++++++- test/next_ls_test.exs | 10 +++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/next_ls.ex b/lib/next_ls.ex index f4552b47..bcde85c6 100644 --- a/lib/next_ls.ex +++ b/lib/next_ls.ex @@ -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}", diff --git a/test/next_ls_test.exs b/test/next_ls_test.exs index e41c7c65..5a311797 100644 --- a/test/next_ls_test.exs +++ b/test/next_ls_test.exs @@ -342,7 +342,7 @@ defmodule NextLSTest do }, "uri" => "file://#{cwd}/lib/bar.ex" }, - "name" => "foo" + "name" => "def foo" } in symbols assert %{ @@ -360,7 +360,7 @@ defmodule NextLSTest do }, "uri" => "file://#{cwd}/lib/bar.ex" }, - "name" => "Bar" + "name" => "defmodule Bar" } in symbols assert %{ @@ -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 @@ -438,7 +438,7 @@ defmodule NextLSTest do }, "uri" => "file://#{cwd}/lib/bar.ex" }, - "name" => "foo" + "name" => "def foo" }, %{ "kind" => 12, @@ -455,7 +455,7 @@ defmodule NextLSTest do }, "uri" => "file://#{cwd}/lib/code_action.ex" }, - "name" => "foo" + "name" => "def foo" } ] == symbols end