Skip to content

Improvements to complete provider, bump elixir_sense #159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 12 additions & 31 deletions apps/language_server/lib/language_server/providers/completion.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,36 +67,16 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
"ExUnit.Assertions"
])

@ignore_module_attrs [
"@after_compile",
"@before_compile",
"@behaviour",
"@callback",
"@compile",
"@deprecated",
"@dialyzer",
"@doc",
"@enforce_keys",
"@external_resource",
"@file",
"@impl",
"@macrocallback",
"@moduledoc",
"@on_definition",
"@on_load",
"@opaque",
"@optional_callbacks",
"@since",
"@spec",
"@type",
"@typedoc",
"@typep",
"@vsn"
]

@keywords %{
"end" => "end",
"do" => "do\n\t$0\nend"
"do" => "do\n\t$0\nend",
"true" => "true",
"false" => "false",
"nil" => "nil",
"else" => "else\n\t$0",
"rescue" => "rescue\n\t$0",
"catch" => "catch\n\t$0",
"after" => "after\n\t$0"
}

def trigger_characters do
Expand Down Expand Up @@ -124,9 +104,9 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do

scope =
case env.scope do
Elixir -> :file
scope when scope in [Elixir, nil] -> :file
module when is_atom(module) -> :module
_ -> :function
{_, _} -> :function
end

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

if name in @ignore_module_attrs or name == prefix do
if name == prefix do
nil
else
%__MODULE__{
Expand Down Expand Up @@ -486,6 +466,7 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
|> String.replace("$", "\\$")
|> String.replace("}", "\\}")
|> String.split(",")
|> Enum.map(&String.trim/1)
end

defp module_attr_snippets(%{prefix: prefix, scope: :module, def_before: nil}) do
Expand Down
5 changes: 4 additions & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
%{
"dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"},
"elixir_sense": {:git, "https://github.com/elixir-lsp/elixir_sense.git", "9531d0e90652d3baf906ad4553d0d17baf4096f5", []},
"docsh": {:hex, :docsh, "0.7.2", "f893d5317a0e14269dd7fe79cf95fb6b9ba23513da0480ec6e77c73221cae4f2", [:rebar3], [{:providers, "1.8.1", [hex: :providers, repo: "hexpm", optional: false]}], "hexpm", "4e7db461bb07540d2bc3d366b8513f0197712d0495bb85744f367d3815076134"},
"elixir_sense": {:git, "https://github.com/elixir-lsp/elixir_sense.git", "3da49376d06a95d4c140d5c0ab41567c7cb5590f", []},
"erl2ex": {:git, "https://github.com/dazuma/erl2ex.git", "244c2d9ed5805ef4855a491d8616b8842fef7ca4", []},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"forms": {:hex, :forms, "0.0.1", "45f3b10b6f859f95f2c2c1a1de244d63855296d55ed8e93eb0dd116b3e86c4a6", [:rebar3], [], "hexpm", "530f63ed8ed5a171f744fc75bd69cb2e36496899d19dbef48101b4636b795868"},
"getopt": {:hex, :getopt, "1.0.1", "c73a9fa687b217f2ff79f68a3b637711bb1936e712b521d8ce466b29cbf7808a", [:rebar3], [], "hexpm", "53e1ab83b9ceb65c9672d3e7a35b8092e9bdc9b3ee80721471a161c10c59959c"},
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fdf843bca858203ae1de16da2ee206f53416bbda5dc8c9e78f43243de4bc3afe"},
"mix_task_archive_deps": {:git, "https://github.com/JakeBecker/mix_task_archive_deps.git", "50301a4314e3cc1104f77a8208d5b66ee382970b", []},
"providers": {:hex, :providers, "1.8.1", "70b4197869514344a8a60e2b2a4ef41ca03def43cfb1712ecf076a0f3c62f083", [:rebar3], [{:getopt, "1.0.1", [hex: :getopt, repo: "hexpm", optional: false]}], "hexpm", "e45745ade9c476a9a469ea0840e418ab19360dc44f01a233304e118a44486ba0"},
}