vscode-elixir icon indicating copy to clipboard operation
vscode-elixir copied to clipboard

[WIP] #21: highlight code blocks

Open timmhirsens opened this issue 7 years ago • 3 comments

Beginning working on highlighting code blocks.

This will close #21

There are some 'edge' cases that currently are unsupported:

  def call(%Plug.Conn{} = conn, []),
    do: conn # <- do: on next line after def
  def clear_session(conn) do
    put_session(conn, fn(_existing) -> Map.new end) # end on same line as fn ->
  end
def code(integer_or_atom) # function declaration w/o body
  def call(conn, level) do
    Logger.log level, fn ->
      [conn.method, ?\s, conn.request_path]
    end

    start = current_time()

    Conn.register_before_send(conn, fn conn ->
      Logger.log level, fn ->
        stop = current_time()
        diff = time_diff(start, stop)

        [connection_type(conn), ?\s, Integer.to_string(conn.status),
         " in ", formatted_diff(diff)]
      end
      conn
    end) # <- 'end' with trailing ')'
  end

In my simple phoenix application it does work pretty well at the moment. But I think before releasing this, those edge cases should be handled.

timmhirsens avatar Dec 08 '16 09:12 timmhirsens

@fr1zle Hi, are you still interested in this feature? I could solve these edge cases for you.

konradkalita avatar Jul 29 '17 23:07 konradkalita

Sure, feel free to pickup from here or open up a new PR

timmhirsens avatar Jul 30 '17 08:07 timmhirsens

I digged into it and I conclude that to do it well I need an elixir parser or at least a lexer. Unfortunately number of constructs like many kind of strings, comments, sigils, atoms which I should exclude to find proper keyword is to big. Do you know if I can get a parse tree/ast with position annotations from Elixir Sense?

konradkalita avatar Jul 31 '17 17:07 konradkalita