Skip to content

Commit

Permalink
Added config item 'erls_dirs' to add code not in 'src' to the scope (#…
Browse files Browse the repository at this point in the history
…1457)

Thanks for your contribution @shuying2244 !
  • Loading branch information
shuying2244 authored Dec 21, 2023
1 parent 0f4eb7b commit 438fb53
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/els_core/src/els_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ initialize(RootUri, Capabilities, InitOptions, ErrorReporting) ->

-spec do_initialize(uri(), map(), map(), {undefined | path(), map()}) -> ok.
do_initialize(RootUri, Capabilities, InitOptions, {ConfigPath, Config}) ->
put(erls_dirs, maps:get("erls_dirs", Config, [])),
RootPath = els_utils:to_list(els_uri:path(RootUri)),
OtpPath = maps:get("otp_path", Config, code:root_dir()),
?LOG_INFO("OTP Path: ~p", [OtpPath]),
Expand Down Expand Up @@ -446,6 +447,7 @@ project_paths(RootPath, Dirs, Recursive) ->
[RootPath, Dir, "src"],
[RootPath, Dir, "test"],
[RootPath, Dir, "include"]
| [[RootPath, Dir, Src] || Src <- erlang:get(erls_dirs)]
],
Recursive
)
Expand Down
6 changes: 6 additions & 0 deletions erlang_ls.config.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ apps_dirs:
deps_dirs:
- "_build/default/lib/*"
- "_build/test/lib/*"

%% If your code exists in directories other than "src", add them through this configuration
erls_dirs:
- "common"
- "game"

include_dirs:
- "apps"
- "apps/*/include"
Expand Down

0 comments on commit 438fb53

Please sign in to comment.