elixir-editors / elixir-tmbundle

A TextMate and Sublime Text Bundle for the Elixir programming language
https://elixir-lang.org/
Other
263 stars 61 forks source link

Highlight unused and wildcard variables (but not unimported functions) #145

Closed maxmellen closed 6 years ago

maxmellen commented 6 years ago

Hi there 👋

Issue

This PR aims to add special highlighting to unused / wildcard variables to the TmBundle while addressing the issues in https://github.com/elixir-editors/elixir-tmbundle/pull/143#issuecomment-366473871.

Before applying this PR

screen shot 2018-02-18 at 11 53 51

After applying #143 (shown to make raised issues apparent)

screen shot 2018-02-18 at 11 54 37

After applying this PR

screen shot 2018-02-18 at 11 53 27

Code used in the screenshots

def foo(a, _b, _) do
  {:ok, _response} = fetch_stuff()
  [_, _, the_third, _, _] = list_of_five
end

defmodule Example do
  def _wont_be_imported do
    :oops
  end

  def _will_be_imported? do
    false
  end
end

import Example
_wont_be_imported()
_will_be_imported?()

String.__info__(:functions)

Best 🤗

josevalim commented 6 years ago

:heart: :green_heart: :blue_heart: :yellow_heart: :purple_heart:

tompave commented 6 years ago

I think that this still requires some work @maxmellen and @josevalim.

For example:

screen shot 2018-02-18 at 12 43 51

It's unfortunate that the same syntax token (leading underscore) is used for different concepts, but the result is that distinguishing between them with simple regular expressions is difficult and error prone. At the cost of being annoying: can we roll this back again, please?

If not I can just edit my colour scheme to treat this token as normal code or fork this repo. I just think that as it is it's objectively less than ideal.