From 958c6ecbe6b0273bf90cdd0cea1a8f3aae4c244a Mon Sep 17 00:00:00 2001 From: William Sanches Date: Tue, 3 Sep 2019 16:55:45 -0300 Subject: [PATCH] fixup! Fix highlight for atoms containing @ character --- spec/syntax/atom_spec.rb | 27 +++++++++++++++++++++++++++ syntax/elixir.vim | 4 ++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/spec/syntax/atom_spec.rb b/spec/syntax/atom_spec.rb index a659f9b8..1462d0bd 100644 --- a/spec/syntax/atom_spec.rb +++ b/spec/syntax/atom_spec.rb @@ -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 diff --git a/syntax/elixir.vim b/syntax/elixir.vim index 934eddb1..3a6838ed 100644 --- a/syntax/elixir.vim +++ b/syntax/elixir.vim @@ -41,9 +41,9 @@ syn match elixirOperator '\\\\\|::\|\*\|/\|\~\~\~\|@' syn match elixirAlias '\([a-z]\)\@=]\@!\)\?\|<>\|===\?\|>=\?\|<=\?\)' +syn match elixirAtom '\(:\)\@=]\@!\)\?\|<>\|===\?\|>=\?\|<=\?\)' syn match elixirAtom '\(:\)\@\|&&\?\|%\(()\|\[\]\|{}\)\|++\?\|--\?\|||\?\|!\|//\|[%&`/|]\)' -syn match elixirAtom "\%([a-zA-Z_]\w*[?!]\?\):\(:\)\@!" +syn match elixirAtom "\%(\w\|@\|[^\d0-\d127]\)\+:\(:\)\@!" syn keyword elixirBoolean true false nil