Skip to content

Commit

Permalink
Include type docs in completion
Browse files Browse the repository at this point in the history
  • Loading branch information
garazdawi committed Oct 17, 2021
1 parent 15e4086 commit 3bd8d40
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions apps/els_lsp/src/els_completion_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ resolve(#{ <<"kind">> := ?COMPLETION_ITEM_KIND_FUNCTION
, binary_to_atom(Function, utf8)
, Arity),
CompletionItem#{documentation => els_markup_content:new(Entries)};
resolve(#{ <<"kind">> := ?COMPLETION_ITEM_KIND_TYPE_PARAM
, <<"data">> := #{ <<"module">> := Module
, <<"type">> := Type
, <<"arity">> := Arity
}
} = CompletionItem) ->
Entries = els_docs:type_docs('remote'
, binary_to_atom(Module, utf8)
, binary_to_atom(Type, utf8)
, Arity),
CompletionItem#{ documentation => els_markup_content:new(Entries) };
resolve(CompletionItem) ->
CompletionItem.

Expand Down Expand Up @@ -511,6 +522,13 @@ resolve_definition(Uri, #{kind := 'function', id := {F, A}} = POI, ArityOnly) ->
, <<"arity">> => A
},
completion_item(POI, Data, ArityOnly);
resolve_definition(Uri, #{kind := 'type_definition', id := {T, A}} = POI,
ArityOnly) ->
Data = #{ <<"module">> => els_uri:module(Uri)
, <<"type">> => T
, <<"arity">> => A
},
completion_item(POI, Data, ArityOnly);
resolve_definition(_Uri, POI, ArityOnly) ->
completion_item(POI, ArityOnly).

Expand Down

0 comments on commit 3bd8d40

Please sign in to comment.