Skip to content

Commit 0c54fd5

Browse files
authored
Merge pull request #159 from lukaszsamson/ls-attribute-completions
Improvements to complete provider, bump elixir_sense
2 parents 94e19b3 + 947810a commit 0c54fd5

File tree

2 files changed

+16
-32
lines changed

2 files changed

+16
-32
lines changed

apps/language_server/lib/language_server/providers/completion.ex

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -67,36 +67,16 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
6767
"ExUnit.Assertions"
6868
])
6969

70-
@ignore_module_attrs [
71-
"@after_compile",
72-
"@before_compile",
73-
"@behaviour",
74-
"@callback",
75-
"@compile",
76-
"@deprecated",
77-
"@dialyzer",
78-
"@doc",
79-
"@enforce_keys",
80-
"@external_resource",
81-
"@file",
82-
"@impl",
83-
"@macrocallback",
84-
"@moduledoc",
85-
"@on_definition",
86-
"@on_load",
87-
"@opaque",
88-
"@optional_callbacks",
89-
"@since",
90-
"@spec",
91-
"@type",
92-
"@typedoc",
93-
"@typep",
94-
"@vsn"
95-
]
96-
9770
@keywords %{
9871
"end" => "end",
99-
"do" => "do\n\t$0\nend"
72+
"do" => "do\n\t$0\nend",
73+
"true" => "true",
74+
"false" => "false",
75+
"nil" => "nil",
76+
"else" => "else\n\t$0",
77+
"rescue" => "rescue\n\t$0",
78+
"catch" => "catch\n\t$0",
79+
"after" => "after\n\t$0"
10080
}
10181

10282
def trigger_characters do
@@ -124,9 +104,9 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
124104

125105
scope =
126106
case env.scope do
127-
Elixir -> :file
107+
scope when scope in [Elixir, nil] -> :file
128108
module when is_atom(module) -> :module
129-
_ -> :function
109+
{_, _} -> :function
130110
end
131111

132112
def_before =
@@ -181,7 +161,7 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
181161
name_only = String.trim_leading(name, "@")
182162
insert_text = if String.starts_with?(prefix, "@"), do: name_only, else: name
183163

184-
if name in @ignore_module_attrs or name == prefix do
164+
if name == prefix do
185165
nil
186166
else
187167
%__MODULE__{
@@ -486,6 +466,7 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
486466
|> String.replace("$", "\\$")
487467
|> String.replace("}", "\\}")
488468
|> String.split(",")
469+
|> Enum.map(&String.trim/1)
489470
end
490471

491472
defp module_attr_snippets(%{prefix: prefix, scope: :module, def_before: nil}) do

mix.lock

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
%{
22
"dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"},
3-
"elixir_sense": {:git, "https://github.com/elixir-lsp/elixir_sense.git", "9531d0e90652d3baf906ad4553d0d17baf4096f5", []},
3+
"docsh": {:hex, :docsh, "0.7.2", "f893d5317a0e14269dd7fe79cf95fb6b9ba23513da0480ec6e77c73221cae4f2", [:rebar3], [{:providers, "1.8.1", [hex: :providers, repo: "hexpm", optional: false]}], "hexpm", "4e7db461bb07540d2bc3d366b8513f0197712d0495bb85744f367d3815076134"},
4+
"elixir_sense": {:git, "https://github.com/elixir-lsp/elixir_sense.git", "3da49376d06a95d4c140d5c0ab41567c7cb5590f", []},
45
"erl2ex": {:git, "https://github.com/dazuma/erl2ex.git", "244c2d9ed5805ef4855a491d8616b8842fef7ca4", []},
56
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
67
"forms": {:hex, :forms, "0.0.1", "45f3b10b6f859f95f2c2c1a1de244d63855296d55ed8e93eb0dd116b3e86c4a6", [:rebar3], [], "hexpm", "530f63ed8ed5a171f744fc75bd69cb2e36496899d19dbef48101b4636b795868"},
8+
"getopt": {:hex, :getopt, "1.0.1", "c73a9fa687b217f2ff79f68a3b637711bb1936e712b521d8ce466b29cbf7808a", [:rebar3], [], "hexpm", "53e1ab83b9ceb65c9672d3e7a35b8092e9bdc9b3ee80721471a161c10c59959c"},
79
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fdf843bca858203ae1de16da2ee206f53416bbda5dc8c9e78f43243de4bc3afe"},
810
"mix_task_archive_deps": {:git, "https://github.com/JakeBecker/mix_task_archive_deps.git", "50301a4314e3cc1104f77a8208d5b66ee382970b", []},
11+
"providers": {:hex, :providers, "1.8.1", "70b4197869514344a8a60e2b2a4ef41ca03def43cfb1712ecf076a0f3c62f083", [:rebar3], [{:getopt, "1.0.1", [hex: :getopt, repo: "hexpm", optional: false]}], "hexpm", "e45745ade9c476a9a469ea0840e418ab19360dc44f01a233304e118a44486ba0"},
912
}

0 commit comments

Comments
 (0)