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

Fix highlight for atoms containing @ character #512

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions spec/syntax/atom_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,31 @@ def project do
end
EOF
end

it 'detects atoms containing @ in it' do
expect(<<~EOF).to include_elixir_syntax('elixirAtom', '@somewhere')
:atom@somewhere
EOF
expect(<<~EOF).to include_elixir_syntax('elixirAtom', '@somewhere')
[atom@somewhere: nil]
EOF
end

it 'detects atoms containing Unicode letters in it' do
expect(<<~EOF).to include_elixir_syntax('elixirAtom', 'ó')
:atóm
EOF
end

it 'does not incorrectly detects spaces as part of the atom' do
input = <<~EOF
{:power_assert, "~> 0.2.0", only: :test}
EOF
expect(input).to include_elixir_syntax('elixirAtom', 'power_assert')
expect(input).to include_elixir_syntax('elixirAtom', 'only')
expect(input).to include_elixir_syntax('elixirAtom', 'test')
expect(input).not_to include_elixir_syntax('elixirAtom', '0.2.0')
expect(input).not_to include_elixir_syntax('elixirAtom', '{')
expect(input).not_to include_elixir_syntax('elixirAtom', '}')
end
end
4 changes: 2 additions & 2 deletions syntax/elixir.vim
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ syn match elixirOperator '\\\\\|::\|\*\|/\|\~\~\~\|@'

syn match elixirAlias '\([a-z]\)\@<![A-Z]\w*\%(\.[A-Z]\w*\)*'

syn match elixirAtom '\(:\)\@<!:\%([a-zA-Z_]\w*\%([?!]\|=[>=]\@!\)\?\|<>\|===\?\|>=\?\|<=\?\)'
syn match elixirAtom '\(:\)\@<!:\%(\%(\w\|@\|[^\d0-\d127]\)\+\%(=[>=]\@!\)\?\|<>\|===\?\|>=\?\|<=\?\)'
syn match elixirAtom '\(:\)\@<!:\%(<=>\|&&\?\|%\(()\|\[\]\|{}\)\|++\?\|--\?\|||\?\|!\|//\|[%&`/|]\)'
syn match elixirAtom "\%([a-zA-Z_]\w*[?!]\?\):\(:\)\@!"
syn match elixirAtom "\%(\w\|@\|[^\d0-\d127]\)\+:\(:\)\@!"

syn keyword elixirBoolean true false nil

Expand Down