Giter VIP home page Giter VIP logo

Comments (17)

slashmili avatar slashmili commented on June 14, 2024 1

Hmm It might be because the Hello.UserSocket is not compiled (https://github.com/slashmili/alchemist.vim/wiki#important-notes)

Can you try to run mix compile and try the autocomplete again?

That's known issue(not an issue really) because auto complete uses alchemist-server and if there is no beam file for Hello.UserSocket, it can't find source file for module Hello.UserSocket

from alchemist.vim.

troq avatar troq commented on June 14, 2024

It still doesn't work after mix compile. I was running it with mix
phoenix.server before so I don't think that'd be the issue. Is there a
debug command I can run to give more info?

On Wednesday, August 24, 2016, Milad [email protected] wrote:

Hmm It might be because the Hello.UserSocket is not compiled (
https://github.com/slashmili/alchemist.vim/wiki#important-notes)

Can you try to run mix compile and try the autocomplete again?

That's known issue(not an issue really) because auto complete uses
alchemist-server and if there is no beam file for Hello.UserSocket, it
can't find source file for module Hello.UserSocket


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#54 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB-JyEcACH76qP3spWtA5RgdHYhmJWGvks5qjDR6gaJpZM4Jr696
.

from alchemist.vim.

slashmili avatar slashmili commented on June 14, 2024

you can enable debug variable in ~/.vim/bundle/alchemist.vim/alchemist_client, the logs go to syslog. try to trigger jump to definition and see what command is executed in syslog, for ex:

Aug 25 10:41:03 Milads-MacBook-Pro alchemist_client[5167]: DEFLX { "Hello.UserSocket", [ context: Elixir, imports: [Hello.EndPoint], aliases: []] }

You will see DEFLX and DEFL in the log. DEFLX is sent by vim plugin to the client and DEFL is what actually is sent to alchemist-server. DEFLX has some extra functionality like finding the line of the code that a module or a function is defined.

then you can run alchemist client directly and execute the command directly:

~/.vim/bundle/alchemist.vim/alchemist_client -d ~/mix/project/path
DEFLX { "Hello.UserSocket", [ context: Elixir, imports: [Hello.EndPoint], aliases: []] }

If it didn't return the file name, check alchemist-server directly,

$ cd ~/mix/project/path
elixir ~/.dotfiles/.vim/bundle/alchemist.vim/alchemist-server/run.exs --env=dev
DEFL { "Hello.UserSocket,nil", [ context: Elixir, imports: [Hello.EndPoint], aliases: []] }
~/mix/project/path/channels/user_socjet.ex
END-OF-DEFL

After running alchemist server, it's waiting for a command to be entered in STDIN . Past the DEFL command and enter. If IEx is able to find the source file would return the path.

Let me know if you get file path back from alchemist-server.

from alchemist.vim.

troq avatar troq commented on June 14, 2024

Running the command in alchemist client didn't work but alchemist-server worked. Here's what I ran (both commands were copied directly from syslog):

image

from alchemist.vim.

slashmili avatar slashmili commented on June 14, 2024

That is indeed strange.

Both of them works for me:

~/d/t/hello $ ~/.vim/bundle/alchemist.vim/alchemist_client -d ./
DEFLX { "Hello.UserSocket", [ context: Elixir, imports: [Hello.Endpoint], aliases: []] }
/Users/milad/dev/tmp/hello/web/channels/user_socket.ex:1
END-OF-DEFLX                                                                                                             
~/d/t/hello $ elixir ~/.dotfiles/.vim/bundle/alchemist.vim/alchemist-server/run.exs --env=dev
DEFL { "Hello.UserSocket,nil", [ context: Elixir, imports: [Hello.Endpoint], aliases: []] }
/Users/milad/dev/tmp/hello/web/channels/user_socket.ex
END-OF-DEFL

Is it possible for you to do more debugging in alchemist.vim/alchemist.py at _send_deflx function? At line 173, it gets the result back from alchemist-server and I want to see if it returns it correctly. looks like at 177 the client doesn't get back any file name as result and return(which apparently it shouldn't)

from alchemist.vim.

hykw avatar hykw commented on June 14, 2024

So am I. I also cannot jumping with E426: tag not found: ***MODULENAME*** error.

from alchemist.vim.

slashmili avatar slashmili commented on June 14, 2024

@hykw can you also try the same steps as @troq? Also please mention elixir version that you are running on your machine

from alchemist.vim.

hykw avatar hykw commented on June 14, 2024

I followed the steps, and found out that at least aliases doesn't work correctly.

Notice: I replaced the module name in the following snippets with Sample and TestModule, so it differs with the actual module name I pushed thru STDIN.

$ elixir alchemist-server/run.exs --env=dev
DEFL { "Sample.TestModule,nil", [ context: Elixir, imports: [Sample.TestModule], aliases: [{Sample, Sample.}]] }

15:22:12.411 [error] GenServer #PID<0.117.0> terminating
** (SyntaxError) nofile:1: syntax error before: '}'
    (elixir) src/elixir.erl:184: :elixir.eval/3
    (elixir) lib/code.ex:168: Code.eval_string/3
    alchemist-server/lib/api/defl.exs:83: Alchemist.API.Defl.normalize/1
    alchemist-server/lib/api/defl.exs:13: Alchemist.API.Defl.request/1
    alchemist-server/lib/helpers/process_commands.exs:20: Alchemist.Helpers.ProcessCommands.process/2
    alchemist-server/lib/server/io.exs:21: Alchemist.Server.IO.handle_info/2
    (stdlib) gen_server.erl:615: :gen_server.try_dispatch/4
Last message: :timeout
State: "dev"
** (EXIT from #PID<0.47.0>) an exception was raised:
    ** (SyntaxError) nofile:1: syntax error before: '}'
        (elixir) src/elixir.erl:184: :elixir.eval/3
        (elixir) lib/code.ex:168: Code.eval_string/3
        alchemist-server/lib/api/defl.exs:83: Alchemist.API.Defl.normalize/1
        alchemist-server/lib/api/defl.exs:13: Alchemist.API.Defl.request/1
        alchemist-server/lib/helpers/process_commands.exs:20: Alchemist.Helpers.ProcessCommands.process/2
        alchemist-server/lib/server/io.exs:21: Alchemist.Server.IO.handle_info/2
        (stdlib) gen_server.erl:615: :gen_server.try_dispatch/4

It works to be cut in aliases, but it cannot find the file.

$ elixir alchemist-server/run.exs --env=dev
DEFL { "Sample.TestModule,nil", [ context: Elixir, imports: [Sample.TestModule], aliases: []] }

END-OF-DEFL

Also I found that it correctly finds and jumps to the definitions, when called in routes.ex. In the snippets, Guardian.Plug.VerifySession, Guardian.Plug.LoadResource and Sample.Plug.ConnAssigns are found-able.

pipeline :browser_session do
  plug Guardian.Plug.VerifySession
  plug Guardian.Plug.LoadResource

  plug Sample.Plug.ConnAssigns
end

from alchemist.vim.

slashmili avatar slashmili commented on June 14, 2024

Hey @hykw thanks for the details. I'll come back to you later :)

from alchemist.vim.

slashmili avatar slashmili commented on June 14, 2024

@hykw So there are few points:

  1. Autocomplete works after your files are compiled and judging by the name of module, you'r trying to jump to a Test file which is exs which doesn't compile...
  2. The sample that you provided has a wrong alchemist-server protocol which could be easily fixed by the plugin. I believe you had an unfinished line like:
defmodule  Foo
alias Sample.

and before completing the syntax you tried to run ExDef (or maybe you have auto save on or ...). As I mentioned I'll send a patch to not include unfinished like this into alias list

Let me know if my assumptions are correct

from alchemist.vim.

hykw avatar hykw commented on June 14, 2024

I've prepared a sample project, which reproduces the issue. Doesn't it occure in your environment?
https://github.com/hykw/alchemist-vim_exdef_test

The issue occures in my environment with the following steps:

$ cd src
$ mix phoenix.new

Confirmed the beam files are in _build/dev/lib/sample/ebin/ (I've checked in the files into GitHub, just in case)

$ vi web/router.ex
  • Line 2
    • cursor is on e as in Sample.web(pic1)
    • :ExDef works. jumped to web/web.ex(pic2)
  • Line 19
    • on t as in PageController(pic3)
    • :ExDef fails(pic4)

c.f.
/var/log/message is following.

Sep 11 14:20:43 myserver alchemist_client: Load server settings from: /tmp/alchemist_server/zShomezShitoshi-hayakawazSazSalchemist-vim_exdef_testzSsrc
Sep 11 14:20:43 myserver alchemist_client: response for PING: PONG\nEND-OF-PING\n
Sep 11 14:20:43 myserver alchemist_client: DEFLX { "PageController", [ context: Elixir, imports: [Sample.Router], aliases: []] }
Sep 11 14:20:43 myserver alchemist_client: DEFL { "PageController,nil", [ context: Elixir, imports: [Sample.Router], aliases: []] }
Sep 11 14:20:43 myserver alchemist_client: response for DEFL: \nEND-OF-DEFL\n
  • pic1
    pic1
  • pic2
    pic2
  • pic3
    pic3
  • pic4
    pic4

from alchemist.vim.

slashmili avatar slashmili commented on June 14, 2024

@hykw thanks a lot for spending time on debugging the issue.

This case is a bit different! which I didn't cover :(

The reason that you can use PageController in the code is because scope is a macro that knows PageController is under Sample module but it's a bit hard to know that in this plugin.

from alchemist.vim.

hykw avatar hykw commented on June 14, 2024

I've found the correct/wrong case. It fails if alias is set in a module. It doesn't matter called with absoletely(Foo.Bar.foo()) or relatively(Bar.foo()).

Sample code:
https://github.com/hykw/alchemist-vim_exdef_test/blob/master/src/web/controllers/page_controller.ex

The difference beetween Sample.WrongCase and Sample.CorrectCase are alias. It doesn't work in Sample.WrongCase but it does work in Sample.CorrectCase!

from alchemist.vim.

slashmili avatar slashmili commented on June 14, 2024

Correct it doesn't work in Sample.WrongCase module because of multi line alias (issue #46) which I didn't manage to fix it yet :( try to put the alias in Sample.WrongCase in one line and it should work

from alchemist.vim.

hykw avatar hykw commented on June 14, 2024

Oops, as you mentioned it worked with one line alias.

alias Sample.Module1

def index(conn, _) do
  foo = Sample.Module1.foo
end

from alchemist.vim.

troq avatar troq commented on June 14, 2024

@slashmili sorry for being MIA (busy month!). For some reason, ExDef is working as expected now. I'm guessing the bug was caused by an issue with my system state rather than alchemist itself. I'll close the issue for now and reopen if it reoccurs in the future.

from alchemist.vim.

slashmili avatar slashmili commented on June 14, 2024

Great 👍

Sorry I couldn't help much

from alchemist.vim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.