Skip to content

Commit 0514619

Browse files
committed
Syntax: improve elixirExUnitMacro
Assumption: ExUnit macros are always followed by space. Technically, a macro's argument can be put into parentheses, but that happens only seldomly. It's more likely that a function gets named after an ExUnit macro. Fixes #418
1 parent 8f22686 commit 0514619

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Diff for: spec/syntax/exunit_spec.rb

+11
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,15 @@ module MyTest do
171171
end
172172
EOF
173173
end
174+
175+
it 'does not highlight keys named after macros' do
176+
expect('test: foo').not_to include_elixir_syntax('elixirExUnitMacro', 'test')
177+
end
178+
179+
it 'does not highlight functions named after macros' do
180+
# Tradeoff: Technically, a macro's argument can be put into parentheses, but
181+
# that happens only seldomly. It's more likely that a function gets named
182+
# after an ExUnit macro.
183+
expect('setup(foo)').not_to include_elixir_syntax('elixirExUnitMacro', 'setup')
184+
end
174185
end

Diff for: syntax/elixir.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ syn match elixirExceptionDeclaration "[^[:space:];#<]\+" contained con
160160
syn match elixirCallbackDeclaration "[^[:space:];#<,()\[\]]\+" contained contains=elixirFunctionDeclaration skipwhite skipnl
161161

162162
" ExUnit
163-
syn match elixirExUnitMacro "\(^\s*\)\@<=\<\(test\|describe\|setup\|setup_all\|on_exit\|doctest\)\>"
163+
syn match elixirExUnitMacro "\(^\s*\)\@<=\<\(test\|describe\|setup\|setup_all\|on_exit\|doctest\)\> "
164164
syn match elixirExUnitAssert "\(^\s*\)\@<=\<\(assert\|assert_in_delta\|assert_raise\|assert_receive\|assert_received\|catch_error\)\>"
165165
syn match elixirExUnitAssert "\(^\s*\)\@<=\<\(catch_exit\|catch_throw\|flunk\|refute\|refute_in_delta\|refute_receive\|refute_received\)\>"
166166

0 commit comments

Comments
 (0)