Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Debugging

Milad edited this page Sep 5, 2017 · 9 revisions

document is work in progress

Debug elixir sense client

Requirements

  • Elixir 1.3 or above
  • Erlang 19 or above
  • Python

Enable debug mode

open elixir_sense_client and enable debug mode. Use the logs when you are creating an issue

diff --git a/elixir_sense_client b/elixir_sense_client
index 3a9d62c..53b3a6a 100755
--- a/elixir_sense_client
+++ b/elixir_sense_client
@@ -3,7 +3,7 @@ from __future__ import print_function
 import os, sys, getopt
 from elixir_sense import ElixirSenseClient

-debug = False
+debug = True

 read_stdin = vars(__builtins__).get('raw_input',input)

If you are on linux, the logs goes to syslog, in Mac it goes to /tmp/log.log

Sample files

Create a file called sample.exs in your mix project and add this content.

Enum.map
CustomModule
CustomModule.foo

Create lib/custom_module.ex with this content in your project

defmodule CustomModule do
  def foo do
    :ok
  end
end

Lookup Elixir's Library

Look up for the file that a module is defined in with:

~/.vim/bundle/alchemist.vim/elixir_sense_client -d./ -c1 -l1 --request=definition < sample.exs
/private/tmp/elixir-20170623-69066-glynnh/elixir-1.4.5/lib/elixir/lib/enum.ex:0

And lookup line of definition of a function with:

~/.vim/bundle/alchemist.vim/elixir_sense_client -d./ -c6 -l1 --request=definition < sample.exs
/private/tmp/elixir-20170623-69066-glynnh/elixir-1.4.5/lib/elixir/lib/enum.ex:0

Look for Docs with :

~/.vim/bundle/alchemist.vim/elixir_sense_client -d./ -c6 -l1 --request=docs < sample.exs
> Enum.map(enumerable, fun)

### Specs

`@spec map(t, (element -> any)) :: list`

Returns a list where each item is the result of invoking
`fun` on each corresponding item of `enumerable`.

For maps, the function expects a key-value tuple.

## Examples

    iex> Enum.map([1, 2, 3], fn(x) -> x * 2 end)
    [2, 4, 6]

    iex> Enum.map([a: 1, b: 2], fn({k, v}) -> {k, -v} end)
    [a: -1, b: -2]

Lookup Project's Library

Now let's see Alchemist.vim can find the file and definition

~/.vim/bundle/alchemist.vim/elixir_sense_client -d./ -c1 -l2 --request=definition < sample.exs
/Users/milad/myapp/lib/custom_module.ex:1

If the result is empty, run mix compile and retry again

And lookup line of definition with DEFLX

~/.vim/bundle/alchemist.vim/elixir_sense_client -d./ -c14 -l3 --request=definition < sample.exs
/Users/milad/dev/myapp/lib/custom_module.ex:2