File tree Expand file tree Collapse file tree 1 file changed +26
-2
lines changed
apps/language_server/lib/language_server/providers Expand file tree Collapse file tree 1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -161,11 +161,35 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
161
161
|> Enum . map ( & from_completion_item ( & 1 , context , options ) )
162
162
|> maybe_add_do ( context )
163
163
|> maybe_add_end ( context )
164
+ |> Enum . reject ( & is_nil / 1 )
165
+ |> sort_items ( )
166
+
167
+ # add trigger signatures to arity 0 if there are higher arity completions that would trigger
168
+ commands = items
169
+ |> Enum . filter ( & & 1 . kind in [ :function ] )
170
+ |> Enum . group_by ( & { & 1 . kind , & 1 . label } )
171
+ |> Map . new ( fn { key , values } ->
172
+ command = Enum . find_value ( values , & & 1 . command )
173
+ { key , command }
174
+ end )
175
+
176
+ items = items
177
+ |> Enum . map ( fn
178
+ % { command: nil } = item ->
179
+ command = commands [ { item . kind , item . label } ]
180
+ if command do
181
+ % { item |
182
+ command: command ,
183
+ insert_text: "#{ item . label } ($1)$0"
184
+ }
185
+ else
186
+ item
187
+ end
188
+ item -> item
189
+ end )
164
190
165
191
items_json =
166
192
items
167
- |> Enum . reject ( & is_nil / 1 )
168
- |> sort_items ( )
169
193
|> items_to_json ( options )
170
194
171
195
{ :ok , % { "isIncomplete" => is_incomplete ( items_json ) , "items" => items_json } }
You can’t perform that action at this time.
0 commit comments