slashmili/alchemist.vim

Feature Request: Let alchemist.vim call elixir_sense's "Referrers" code

Closed this issue · 6 comments

One of the main things I miss from vim-go when working with my Elixir projects is the ability to run a command that will give me a list of references to the item under my cursor. For instance:

  • Show me all callers of function foo/2
  • Show me all uses of variable bar
  • Show me all references to struct Baz.Bat

I'm not positive that all of these are possible via elixir_sense, but it seems they might be based on my brief exploration of the repo.

Would it be difficult to integrate this into Alchemist.vim?

When I integrated elixir_sense, it didn't have this functionality. However I just checked elixir_sense and it does have a way to find references in the code.

How did vim-go show the result? Does it show it in a Quickfix window?

Sorry for the delay, was out of the loop for a little bit. :-)

vim-go gives a Location List window. I can happily share some screenshots if you'd like!

@slashmili Either a QuickFix or a location list would be fine, I think. Can location lists reference other files?

Thanks,

I played around with references but was not able to use it effectively. I saw there is some updates in elixir_sense upstream, I'll try it out again.

I experimented with references feature of ElixirSense

ElixirSense uses Mix Tasks, which works when you run ElixirSense using mix(I still need to figure out how) but in this project we are starting the server using elixir run.exs ... which causes this error

** (exit) exited in: GenServer.call(Mix.ProjectStack, {:get, #Function<11.36738168/1 in Mix.ProjectStack.peek/0>}, 30000)
    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
    (elixir) lib/gen_server.ex:999: GenServer.call/3
    lib/mix/project.ex:196: Mix.Project.config/0
    lib/mix/project.ex:521: Mix.Project.manifest_path/0
    lib/mix/tasks/xref.ex:760: Mix.Tasks.Xref.manifests/1
    lib/mix/tasks/xref.ex:220: Mix.Tasks.Xref.calls/1

One option could be to start the mix application manually

Application.ensure_all_started(:mix)

I'm still experimenting with that, I'll update the ticket when I have more information

Any update on this?