erlang-ls / erlang_ls

The Erlang Language Server
https://erlang-ls.github.io/
Apache License 2.0
632 stars 137 forks source link

Can't autocomplete other module in a single folder "project" #1567

Open DN4Davi opened 1 month ago

DN4Davi commented 1 month ago

I have a folder with two files:

%% x.erl
-module(x).
-export([a/2]).

a(X, Y) -> X + Y.
%% y.erl
-module(y).
-export([b/0]).

b() -> 
%% where i want to call `x:a(1,2),`
ok.

but i don't receive any completion from erlang_ls about the x module in the y module. Why it occurs? How to configue erlang_ls.config to solve it?

plux commented 1 month ago

This should work, how does your project structure looks like and how does your erlang_ls.config look like?

plux commented 1 month ago

I think I understand now. Just two files in the project root? I guess we don't support that, but expect source files to be under src/.

I think your use-case is valid, so will try to fix it :)

DN4Davi commented 1 month ago

I think I understand now. Just two files in the project root? I guess we don't support that, but expect source files to be under src/.

Yes, is it but even when I put them into the 'src/' dir doesn't works (but if i add a rebar.config sample filie to the root in this case, it seems to work).

I think your use-case is valid, so will try to fix it :)

Thanks! 🙏

DN4Davi commented 1 month ago

I found the real problem to the case of the files in the "src/" dir. It isn't a bug in erlang_ls itself, but with the way nvim-lspconfig defines the root dir to the LSP (https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md#erlangls).