Skip to content

Commit

Permalink
[erlang-ls#990] Show warning to the user in case of missing config file
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoaloi committed Jul 7, 2021
1 parent 6b7c313 commit 67827d4
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion apps/els_core/src/els_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ possible_config_paths(Path) ->
].

-spec consult_config([path()]) -> {undefined|path(), map()}.
consult_config([]) -> {undefined, #{}};
consult_config([]) ->
?LOG_INFO("No config file found."),
report_missing_config(),
{undefined, #{}};
consult_config([Path | Paths]) ->
?LOG_INFO("Reading config file. path=~p", [Path]),
Options = [{map_node_format, map}],
Expand All @@ -225,6 +228,18 @@ consult_config([Path | Paths]) ->
consult_config(Paths)
end.

-spec report_missing_config() -> ok.
report_missing_config() ->
Msg =
io_lib:format("The current project is missing an erlang_ls.config file. "
"Need help configuring Erlang LS for your project? "
"Visit: https://erlang-ls.github.io/configuration/", []),
els_server:send_notification(<<"window/showMessage">>,
#{ type => ?MESSAGE_TYPE_WARNING,
message => els_utils:to_binary(Msg)
}),
ok.

-spec include_paths(path(), string(), boolean()) -> [string()].
include_paths(RootPath, IncludeDirs, Recursive) ->
Paths = [ els_utils:resolve_paths([[RootPath, Dir]], RootPath, Recursive)
Expand Down

0 comments on commit 67827d4

Please sign in to comment.