问题
I tried the Elixir plugin for Jet Brains, and two of them for VS Code, but so far none of them reliably takes me to the definition of functions and modules. Apparently part of the reason is because elixir-lsp cannot handle things inside of scope
blocks (https://github.com/elixir-lsp/elixir-ls#known-issueslimitations).
回答1:
I have a stop-gap solution for this using Universal Ctags.
On Mac:
brew install --HEAD universal-ctags/universal-ctags/universal-ctags
/usr/local/bin/ctags --exclude=node_modules -R .
Add something like this to your ~/.vimrc:
set tags=tags,./tags,../tags,../../tags,../../../tags,../../../../tags,../../../../../tags
Then fire up Vim on some Elixir files and use ctrl-] to jump to definitions, ctrl-O to jump back.
To make life easier, I added this Makefile target:
echo '
.PHONY: tags
tags:
/usr/local/bin/ctags --exclude=node_modules -R .
' >> Makefile
The PHONY line tells Make to always run the command even if there is already a tags file.
VS Code has a plugin called ctagsx that works well with these tag files. I'm using it together with the ElixirLS plugin and that seems to be working so far.
So far I have not found a way to make JetBrains/Intellij IDEs work with these tag files.
来源:https://stackoverflow.com/questions/65781075/how-can-i-get-reliable-jump-to-definition-for-elixir