Skip to content

Commit

Permalink
Add support for completing '<<' to '>>'
Browse files Browse the repository at this point in the history
  • Loading branch information
plux committed Oct 15, 2024
1 parent b8724fb commit 0b158b8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions apps/els_lsp/src/els_completion_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ find_completions(
{ItemFormat, _POIKind} =
completion_context(Document, Line, Column, Tokens),
complete_type_definition(Document, Name, ItemFormat);
%% Check for "<<"
[{'<<', _} | _] ->
complete_binary_literal();
%% Check for "::"
[{'::', _} | _] = Tokens ->
{ItemFormat, _POIKind} =
Expand Down Expand Up @@ -413,6 +416,22 @@ find_completions(
find_completions(_Prefix, _TriggerKind, _Opts) ->
[].

-spec complete_binary_literal() -> completion_item().
complete_binary_literal() ->
case snippet_support() of
true ->
[
#{
label => <<">>">>,
kind => ?COMPLETION_ITEM_KIND_KEYWORD,
insertTextFormat => ?INSERT_TEXT_FORMAT_SNIPPET,
insertText => <<"${1:}>>">>
}
];
false ->
[]
end.

-spec list_comprehension_completion_item(els_dt_document:item(), line(), column()) ->
completion_item().
list_comprehension_completion_item(#{text := Text}, Line, Column) ->
Expand Down

0 comments on commit 0b158b8

Please sign in to comment.