erlang_ls
erlang_ls copied to clipboard
cannot code completion(or find definition)
Describe the bug cannot code completion(or find definition) for new function or new macro
To Reproduce new a macro in test.hrl (eg: -define(new_macro, test).), then test.erl use ?new_macro, it cannot code completion and cannot jump to definition.
Expected behavior want code completion and definition
Actual behavior as above
Context
-
erlang_ls
version (tag/sha): erlang-ls v0.0.39 in vsCode - Editor used:
- LSP client used:
ps:erlang_ls.config has include like include_dirs: -"include"
important: when i reopen vscode, then i can code completion and find definition, but new function or macro cannot. unless i reopen vscode again
appreciate to all of you for help!!!
i have same problem on windows, but works fine on wsl
I can confirm this.
This happens in a rebar3 project with the following config (from erlang ls docs):
apps_dirs:
- "_build/default/lib/*"
include_dirs:
- "_build/default/lib/*/include"
- "include"
The app has a simple structure like this, generate by rebar3 new app example
:
.
├── _build
│ └── default
│ └── lib
│ └── example
│ ├── ebin
│ │ ├── example.app
│ │ ├── example_app.beam
│ │ └── example_sup.beam
│ ├── include -> ../../../../include
│ ├── priv -> ../../../../priv
│ └── src -> ../../../../src
├── erlang_ls.config
├── LICENSE
├── README.md
├── rebar.config
├── rebar.lock
└── src
├── example_app.erl
├── example.app.src
└── example_sup.erl
For example adding a new exported function to example_sup
and then completing in example
the new function won't show up in completions.
I can confirm this.
This happens in a rebar3 project with the following config (from erlang ls docs):
apps_dirs: - "_build/default/lib/*" include_dirs: - "_build/default/lib/*/include" - "include"
The app has a simple structure like this, generate by
rebar3 new app example
:. ├── _build │ └── default │ └── lib │ └── example │ ├── ebin │ │ ├── example.app │ │ ├── example_app.beam │ │ └── example_sup.beam │ ├── include -> ../../../../include │ ├── priv -> ../../../../priv │ └── src -> ../../../../src ├── erlang_ls.config ├── LICENSE ├── README.md ├── rebar.config ├── rebar.lock └── src ├── example_app.erl ├── example.app.src └── example_sup.erl
For example adding a new exported function to
example_sup
and then completing inexample
the new function won't show up in completions.
thanks a lot. question above is happen on win10, when i work on wsl, completion works fine. so i think it's maybe bugs on win10
Don't close the issue, please reopen. This is real and happens on Linux too.
My theory is that this is related to the face that rebar3 creates symlinks in _build
to src
directory which makes erlang_ls confused as there are two modules resolving to different Uris (one in src
and one in _build
).
Seems like the src
document is updated when changes to the file happens, but completion will do a lookup of the module name and find the Uri of the _build
file, which has not been re-indexed.
Don't close the issue, please reopen. This is real and happens on Linux too.
My theory is that this is related to the face that rebar3 creates symlinks in
_build
tosrc
directory which makes erlang_ls confused as there are two modules resolving to different Uris (one insrc
and one in_build
).Seems like the
src
document is updated when changes to the file happens, but completion will do a lookup of the module name and find the Uri of the_build
file, which has not been re-indexed.
sounds like that...
I think the solution would either be to not index the _build
symlink documents or make sure that those documents are also updated when a change is registed on the src
document.
I think the solution would either be to not index the
_build
symlink documents or make sure that those documents are also updated when a change is registed on thesrc
document.
yeah, maybe all(exclude deps) should index the src
, and deps could index the _build
, because deps not changes frequently
els_uri.erl
You can try this fix.