Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added char lists syntax highlighting #544

Merged
merged 5 commits into from
Jun 15, 2021

Conversation

lucassperez
Copy link
Contributor

@lucassperez lucassperez commented Apr 29, 2021

I believe that strings and charlists deserve different highlighting group, since those are very different data types.
Even if it is defaulted to regular vim string, it would make a little easier for us to customize our own colors.

The motivation behind this is that I ran into a bug when I was pattern matching the wrong value because I didn't notice I wrote single quoted "strings" instead of double quoted strings by mistake, and different colors for them would have saved me some minutes and a couple of head scratches.

I made this change today and I'm not sure they are 100% safe and did not break anything. I do not excel in those syntax groups of vim, but it seems to be working.
Comments and changes to my piece of code are more than welcome, and if this change is not what we want/need, then we can close this pull request.

Thanks for reading and providing us with this good content! (:

fixes #545

@jbodah
Copy link
Collaborator

jbodah commented May 1, 2021

I think this is a good idea. The only thing I'm not sure of here is whether or not this will affect indent rules which ignore special characters (e.g. do/end) which are strings:

if syng !~ '\%(String\|Comment\)'

@lucassperez
Copy link
Contributor Author

I'm sorry, I'm not sure what is the rule we are talking about here, but I tried to type these snippets in my vim:

defmodule Hi do
  |
defmodule Hi do
  def hello do
    "Hello"
    |
defmodule Hi do
  def hello do
    "Hello"
  end
  |

The | symbols are the position of the cursor after I pressed enter in each of those situations. It seems normal so far?

One maybe questionable decision is using Identifier here, since it is the same group of things such as self, @doc and module attributes in general:

hi def link elixirCharList Identifier

hi def link elixirCharListDelimiter Identifier

If we change it to String would this solve your concern? Strings and char lists would have the same color by default, but at least it would be easy for each person to customize their own.

@jbodah
Copy link
Collaborator

jbodah commented Jun 12, 2021

I pushed up a fix for the indent code

I think we should link elixirCharListDelimiter to Delimiter and elixirCharList to String (so they are highlighted like strings by default); WDYT?

@lucassperez
Copy link
Contributor Author

lucassperez commented Jun 15, 2021

I think it is a very good ideia. I agree that linking them to String by default seems like the most reasonable idea, and it still makes it very easy to customize into any other color if someone wants to.

The bug fix is also great 👏

@jbodah jbodah merged commit e7caa59 into elixir-editors:master Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Charlists syntax highlighting
2 participants