@@ -65,7 +65,8 @@ defmodule NextLS.Autocomplete do
65
65
expand_dot_call ( path , List . to_atom ( hint ) , runtime , env )
66
66
67
67
: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 )
69
70
70
71
{ :local_or_var , local_or_var } ->
71
72
hint = List . to_string ( local_or_var )
@@ -93,7 +94,8 @@ defmodule NextLS.Autocomplete do
93
94
expand_local ( List . to_string ( operator ) , true , runtime , env )
94
95
95
96
{ :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 )
97
99
98
100
{ :operator_call , _operator } ->
99
101
expand_local_or_var ( "" , "" , runtime , env )
@@ -244,7 +246,15 @@ defmodule NextLS.Autocomplete do
244
246
## Expand local or var
245
247
246
248
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
248
258
end
249
259
250
260
defp expand_local ( hint , exact? , runtime , env ) do
@@ -419,7 +429,9 @@ defmodule NextLS.Autocomplete do
419
429
alias = value_from_alias ( aliases , env ) ,
420
430
true <-
421
431
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
423
435
{ :struct , alias , pairs }
424
436
else
425
437
_ -> nil
0 commit comments