Skip to content

Commit

Permalink
Completion without snippets (#1170)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirikid committed Jan 30, 2022
1 parent db82b7c commit 0fa9df8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
5 changes: 4 additions & 1 deletion apps/els_core/src/els_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,10 @@ request_params({completionitem_resolve, CompletionItem}) ->
request_params({initialize, {RootUri, InitOptions}}) ->
ContentFormat = [ ?MARKDOWN , ?PLAINTEXT ],
TextDocument = #{ <<"completion">> =>
#{ <<"contextSupport">> => 'true' }
#{ <<"contextSupport">> => 'true'
, <<"completionItem">> =>
#{ <<"snippetSupport">> => 'true' }
}
, <<"hover">> =>
#{ <<"contentFormat">> => ContentFormat }
},
Expand Down
22 changes: 19 additions & 3 deletions apps/els_lsp/src/els_completion_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -734,12 +734,28 @@ snippet_macro(Name, none) ->

-spec snippet_args(binary(), [{integer(), string()}]) -> binary().
snippet_args(Name, Args0) ->
Args = [ ["${", integer_to_list(N), ":", A, "}"]
|| {N, A} <- Args0
],
Args =
case snippet_support() of
false ->
[A || {_N, A} <- Args0];
true ->
[["${", integer_to_list(N), ":", A, "}"] || {N, A} <- Args0]
end,
Snippet = [Name, "(", string:join(Args, ", "), ")"],
els_utils:to_binary(Snippet).

-spec snippet_support() -> boolean().
snippet_support() ->
case els_config:get(capabilities) of
#{<<"textDocument">> :=
#{<<"completion">> :=
#{<<"completionItem">> :=
#{<<"snippetSupport">> := SnippetSupport}}}} ->
SnippetSupport;
_ ->
false
end.

-spec is_in(els_dt_document:item(), line(), column(), [poi_kind()]) ->
boolean().
is_in(Document, Line, Column, POIKinds) ->
Expand Down

0 comments on commit 0fa9df8

Please sign in to comment.