@@ -79,8 +79,9 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
7979
8080 def trigger_characters do
8181 # VS Code's 24x7 autocompletion triggers automatically on alphanumeric characters. We add these
82- # for "SomeModule." calls, @module_attrs, function capture, variable pinning, erlang module calls
83- [ "." , "@" , "&" , "%" , "^" , ":" , "!" ]
82+ # for "SomeModule." calls, @module_attrs, function capture, variable pinning, erlang module calls,
83+ # bitstring options and sigils
84+ [ "." , "@" , "&" , "%" , "^" , ":" , "!" , "-" , "~" ]
8485 end
8586
8687 def completion ( text , line , character , options ) do
@@ -452,6 +453,30 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
452453 }
453454 end
454455
456+ defp from_completion_item (
457+ % { type: :bitstring_option , name: name } ,
458+ _context ,
459+ options
460+ ) do
461+ insert_text =
462+ case name do
463+ name when name in [ "size" , "unit" ] ->
464+ function_snippet ( name , [ "integer" ] , 1 , options |> Keyword . merge ( with_parens?: true ) )
465+
466+ other ->
467+ other
468+ end
469+
470+ % __MODULE__ {
471+ label: name ,
472+ detail: "bitstring option" ,
473+ insert_text: insert_text ,
474+ priority: 10 ,
475+ kind: :type_parameter ,
476+ tags: [ ]
477+ }
478+ end
479+
455480 defp from_completion_item (
456481 % { type: :type_spec , metadata: metadata } = suggestion ,
457482 _context ,
@@ -771,10 +796,9 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
771796
772797 { label , insert_text } =
773798 cond do
774- match? ( "sigil_" <> _ , name ) ->
775- "sigil_" <> sigil_name = name
776- text = "~#{ sigil_name } "
777- { text , text }
799+ match? ( "~" <> _ , name ) ->
800+ "~" <> sigil_name = name
801+ { name , sigil_name }
778802
779803 use_name_only? ( origin , name ) or String . starts_with? ( text_after_cursor , "(" ) ->
780804 { name , name }
0 commit comments