Skip to content

Commit 7e46c3e

Browse files
authored
Return struct property typespecs as documentation in completion (#835)
* return struct property typespecs as documentation in completion * remove unnecessary string format
1 parent 0efd958 commit 7e46c3e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

apps/language_server/lib/language_server/providers/completion.ex

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,14 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
508508
end
509509

510510
defp from_completion_item(
511-
%{type: :field, subtype: subtype, name: name, origin: origin, call?: call?},
511+
%{
512+
type: :field,
513+
subtype: subtype,
514+
name: name,
515+
origin: origin,
516+
call?: call?,
517+
type_spec: type_spec
518+
},
512519
_context,
513520
_options
514521
) do
@@ -519,10 +526,18 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
519526
{:struct_field, module_name} -> "#{module_name} struct field"
520527
end
521528

529+
formatted_spec =
530+
if type_spec != "" do
531+
"```\n#{type_spec}\n```\n"
532+
else
533+
""
534+
end
535+
522536
%__MODULE__{
523537
label: to_string(name),
524538
detail: detail,
525539
insert_text: if(call?, do: name, else: "#{name}: "),
540+
documentation: formatted_spec,
526541
priority: 10,
527542
kind: :field,
528543
tags: []

0 commit comments

Comments
 (0)