How can I get reliable jump-to-definition for Elixir?

折月煮酒 提交于 2021-02-10 16:14:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!