@@ -65,7 +65,8 @@ defmodule NextLS.Autocomplete do
6565 expand_dot_call ( path , List . to_atom ( hint ) , runtime , env )
6666
6767 :expr ->
68- expand_container_context ( code , :expr , "" , runtime , env ) || expand_local_or_var ( code , "" , runtime , env )
68+ expand_container_context ( code , :expr , "" , runtime , env ) ||
69+ expand_local_or_var ( code , "" , runtime , env )
6970
7071 { :local_or_var , local_or_var } ->
7172 hint = List . to_string ( local_or_var )
@@ -93,7 +94,8 @@ defmodule NextLS.Autocomplete do
9394 expand_local ( List . to_string ( operator ) , true , runtime , env )
9495
9596 { :operator_call , operator } when operator in ~w( |) c ->
96- expand_container_context ( code , :expr , "" , runtime , env ) || expand_local_or_var ( "" , "" , runtime , env )
97+ expand_container_context ( code , :expr , "" , runtime , env ) ||
98+ expand_local_or_var ( "" , "" , runtime , env )
9799
98100 { :operator_call , _operator } ->
99101 expand_local_or_var ( "" , "" , runtime , env )
@@ -244,7 +246,15 @@ defmodule NextLS.Autocomplete do
244246 ## Expand local or var
245247
246248 defp expand_local_or_var ( code , hint , runtime , env ) do
247- format_expansion ( match_var ( code , hint , runtime , env ) ++ match_local ( hint , false , runtime , env ) )
249+ format_expansion (
250+ match_keywords ( hint ) ++ match_var ( code , hint , runtime , env ) ++ match_local ( hint , false , runtime , env )
251+ )
252+ end
253+
254+ defp match_keywords ( hint ) do
255+ for % { name: name } = kw <- [ % { kind: :reserved , name: "do" } ] , String . starts_with? ( name , hint ) do
256+ kw
257+ end
248258 end
249259
250260 defp expand_local ( hint , exact? , runtime , env ) do
@@ -419,7 +429,9 @@ defmodule NextLS.Autocomplete do
419429 alias = value_from_alias ( aliases , env ) ,
420430 true <-
421431 Keyword . keyword? ( pairs ) and ensure_loaded? ( alias , runtime ) and
422- NextLS.Runtime . execute! ( runtime , do: Kernel . function_exported? ( alias , :__struct__ , 1 ) ) do
432+ NextLS.Runtime . execute! ( runtime ,
433+ do: Kernel . function_exported? ( alias , :__struct__ , 1 )
434+ ) do
423435 { :struct , alias , pairs }
424436 else
425437 _ -> nil
0 commit comments