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