diff --git a/Gemfile b/Gemfile index 414fd03..bded44b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,3 @@ source 'https://rubygems.org' -gem 'vimrunner', '0.3.0' -gem 'rake', '10.0.4' -gem 'rspec', '~> 2.13.0' - +gem 'vimrunner', '0.3.4' +gem 'rake', '~> 11.0' diff --git a/Gemfile.lock b/Gemfile.lock index ea5528e..fcedbb7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,20 +1,15 @@ GEM remote: https://rubygems.org/ specs: - diff-lcs (1.1.3) - rake (0.9.2.2) - rspec (2.9.0) - rspec-core (~> 2.9.0) - rspec-expectations (~> 2.9.0) - rspec-mocks (~> 2.9.0) - rspec-core (2.9.0) - rspec-expectations (2.9.1) - diff-lcs (~> 1.1.3) - rspec-mocks (2.9.0) + rake (11.3.0) + vimrunner (0.3.4) PLATFORMS ruby DEPENDENCIES - rake - rspec + rake (~> 11.0) + vimrunner (= 0.3.4) + +BUNDLED WITH + 1.16.1 diff --git a/Rakefile b/Rakefile index 7c84562..f461fa7 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,12 @@ -require 'rspec/core/rake_task' +require 'rake/testtask' -RSpec::Core::RakeTask.new - -task :test => :spec task :default => :spec +task :test => :spec + +Rake::TestTask.new(:spec) do |t| + t.libs.push "lib" + t.test_files = Dir.glob('spec/*_spec.rb') + t.verbose = true + t.warning = true +end + diff --git a/spec/fixtures/misc/jump_to_matching_curly.scala b/spec/fixtures/misc/jump_to_matching_curly.scala new file mode 100644 index 0000000..531e72b --- /dev/null +++ b/spec/fixtures/misc/jump_to_matching_curly.scala @@ -0,0 +1,4 @@ +object Main { + foo('}') + foo('{') +} diff --git a/spec/fixtures/misc/jump_to_matching_paren.scala b/spec/fixtures/misc/jump_to_matching_paren.scala new file mode 100644 index 0000000..84e5df9 --- /dev/null +++ b/spec/fixtures/misc/jump_to_matching_paren.scala @@ -0,0 +1,4 @@ +object Main { + foo(')') + foo('(') +} diff --git a/spec/fixtures/multiple_newlines.expected.scala b/spec/fixtures/sort_imports/multiple_newlines.expected.scala similarity index 100% rename from spec/fixtures/multiple_newlines.expected.scala rename to spec/fixtures/sort_imports/multiple_newlines.expected.scala diff --git a/spec/fixtures/multiple_newlines.scala b/spec/fixtures/sort_imports/multiple_newlines.scala similarity index 100% rename from spec/fixtures/multiple_newlines.scala rename to spec/fixtures/sort_imports/multiple_newlines.scala diff --git a/spec/fixtures/no_newline.expected.scala b/spec/fixtures/sort_imports/no_newline.expected.scala similarity index 100% rename from spec/fixtures/no_newline.expected.scala rename to spec/fixtures/sort_imports/no_newline.expected.scala diff --git a/spec/fixtures/no_newline.scala b/spec/fixtures/sort_imports/no_newline.scala similarity index 100% rename from spec/fixtures/no_newline.scala rename to spec/fixtures/sort_imports/no_newline.scala diff --git a/spec/fixtures/no_newline_after.expected.scala b/spec/fixtures/sort_imports/no_newline_after.expected.scala similarity index 100% rename from spec/fixtures/no_newline_after.expected.scala rename to spec/fixtures/sort_imports/no_newline_after.expected.scala diff --git a/spec/fixtures/no_newline_after.scala b/spec/fixtures/sort_imports/no_newline_after.scala similarity index 100% rename from spec/fixtures/no_newline_after.scala rename to spec/fixtures/sort_imports/no_newline_after.scala diff --git a/spec/fixtures/no_package.expected.scala b/spec/fixtures/sort_imports/no_package.expected.scala similarity index 100% rename from spec/fixtures/no_package.expected.scala rename to spec/fixtures/sort_imports/no_package.expected.scala diff --git a/spec/fixtures/no_package.scala b/spec/fixtures/sort_imports/no_package.scala similarity index 100% rename from spec/fixtures/no_package.scala rename to spec/fixtures/sort_imports/no_package.scala diff --git a/spec/fixtures/vanilla.expected.scala b/spec/fixtures/sort_imports/vanilla.expected.scala similarity index 100% rename from spec/fixtures/vanilla.expected.scala rename to spec/fixtures/sort_imports/vanilla.expected.scala diff --git a/spec/fixtures/vanilla.scala b/spec/fixtures/sort_imports/vanilla.scala similarity index 100% rename from spec/fixtures/vanilla.scala rename to spec/fixtures/sort_imports/vanilla.scala diff --git a/spec/go_to_matching_spec.rb b/spec/go_to_matching_spec.rb new file mode 100644 index 0000000..df8724f --- /dev/null +++ b/spec/go_to_matching_spec.rb @@ -0,0 +1,64 @@ +require_relative './spec_helper' + +# This test simulates what happens in plugin/matchparen.vim, to ensure syntax/scala.vim +# uses style names that use the correct magic words. + +describe 'default matching behavior' do + it 'jumps over parentheses in single-quotes' do + with_fixture('misc/jump_to_matching_paren.scala') do |file| + start_vim do |vim| + vim.edit file.path + vim.command 'set ft=scala' + vim.normal '2gg' + vim.normal '6|' + line_num, col_num = searchpairpos(vim, '(', '', ')', 'nW') + + line_num.must_equal '2' + col_num.must_equal '10' + + vim.normal '3gg' + vim.normal '10|' + line_num, col_num = searchpairpos(vim, '(', '', ')', 'bnW') + + line_num.must_equal '3' + col_num.must_equal '6' + end + end + end + + it 'jumps over curly braces in single-quotes' do + with_fixture('misc/jump_to_matching_curly.scala') do |file| + start_vim do |vim| + vim.edit file.path + vim.command 'set ft=scala' + vim.normal '1gg' + vim.normal '13|' + line_num, col_num = searchpairpos(vim, '{', '', '}', 'nW') + + line_num.must_equal '4' + col_num.must_equal '1' + + vim.normal '4gg' + vim.normal '1|' + line_num, col_num = searchpairpos(vim, '{', '', '}', 'bnW') + + line_num.must_equal '1' + col_num.must_equal '13' + end + end + end +end + +def read_pair(str) + str.match(/\[(\d+), (\d+)\]/)[1, 2] +end + +def searchpairpos(vim, head, middle, tail, flags) + # distilled from vim80/plugin/matchparen.vim. + expr = <<-EXPR + searchpairpos('#{head}', '#{middle}', '#{tail}', '#{flags}', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\\\|character\\\\|singlequote\\\\|escape\\\\|comment"') + EXPR + + read_pair vim.echo expr +end + diff --git a/spec/import_sorting_spec.rb b/spec/import_sorting_spec.rb index 0560059..eb32042 100644 --- a/spec/import_sorting_spec.rb +++ b/spec/import_sorting_spec.rb @@ -1,16 +1,23 @@ -require "spec_helper" +require_relative './spec_helper' -describe ":SortScalaImports" do - - describe "Sorting across groups" do - ["vanilla", "no_newline", "no_newline_after", "no_package", - "multiple_newlines"].each do |name| - it "should sort vanilla file" do - actual = sort_fixture_across_groups name - expected = expected(name) - actual.should eq(expected) - end +describe :SortScalaImports do + each_fixture('sort_imports') do |fixture| + it %'will sort imports in file #{fixture}' do + actual = sort_fixture_across_groups(fixture) + actual.must_equal expected(fixture) end end +end +def sort_fixture_across_groups(fixture_name) + with_fixture(fixture_name) do |temp_file| + # A global variable changes in each session, + # so start a new vim each time. + start_vim do |vim| + vim.edit temp_file.path + vim.command 'let g:scala_sort_across_groups=1' + vim.command 'SortScalaImports' + vim.write + end + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b997877..14168e3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,44 +1,74 @@ require 'vimrunner' require 'tempfile' +require 'minitest' +require 'minitest/spec' +require 'minitest/autorun' -PWD = File.expand_path File.dirname(__FILE__) +PWD = File.expand_path('..', __FILE__) -RSpec.configure do |config| +def start_vim_without_plugins + Vimrunner.start do |vim| + vim.command 'filetype on' + vim.command 'set verbose=2' - config.before(:suite) do - VIM = Vimrunner.start - VIM.add_plugin(File.expand_path('../..', __FILE__), 'plugin/scala.vim') - end + # Prepend our local path to ensure the built-in scala code is not used. + vim.prepend_runtimepath(File.expand_path('../..', __FILE__)) + # puts 'vimrunner runtimepath:', vim.echo('&runtimepath') + + plugin_loader = lambda do + vim.command 'runtime! ftdetect/scala.vim' + vim.command 'runtime! ftplugin/scala.vim' + vim.command 'runtime! ftplugin/scala/tagbar.vim' + vim.command 'runtime! indent/scala.vim' + vim.command 'runtime! plugin/scala.vim' + vim.command 'runtime! syntax/scala.vim' + vim.command 'runtime! compiler/scala.vim' + vim.command 'runtime! after/syntax/scala.vim' + end - config.after(:suite) do - VIM.kill + yield vim, plugin_loader end end -def sort_fixture_across_groups(name) - fixture_path = "#{PWD}/fixtures/#{name}.scala" +def start_vim + start_vim_without_plugins do |vim, plugin_loader| + plugin_loader.call + yield vim + end +end - temp_file = Tempfile.new('vim-scala-') - temp_file.write File.read(fixture_path) - temp_file.rewind +def with_temp_file(source_filename) + temp_file = Tempfile.new('vim-scala-testing-') + begin + temp_file.write File.read(source_filename) + temp_file.rewind - VIM.edit temp_file.path + yield temp_file - VIM.command "let g:scala_sort_across_groups=1" - VIM.command "SortScalaImports" - VIM.write + temp_file.rewind + temp_file.read + ensure + temp_file.close + temp_file.unlink + end +end - temp_file.rewind - output = temp_file.read +def with_fixture(fixture_name, &block) + with_temp_file fixture_path(fixture_name), &block +end - temp_file.close - temp_file.unlink +def each_fixture(dir) + Dir.each_child(File.join(PWD, 'fixtures', dir)) do |child| + next if child.end_with? '.expected.scala' + yield File.join(dir, child) + end +end - output +def fixture_path(filename) + %'#{PWD}/fixtures/#{filename}' end -def expected(name) - path = "#{PWD}/fixtures/#{name}.expected.scala" - File.read(path) +def expected(filename) + File.read fixture_path filename.gsub(/scala$/, 'expected.scala') end diff --git a/spec/syntax_spec.rb b/spec/syntax_spec.rb new file mode 100644 index 0000000..e5fb619 --- /dev/null +++ b/spec/syntax_spec.rb @@ -0,0 +1,30 @@ +require_relative './spec_helper' + +describe 'syntax/scala.vim' do + it 'allows the user to override scala-specific links' do + start_vim_without_plugins do |vim, plugin_loader| + # Set our custom value, then load the plugins. + # This simulates vim loading .vimrc then later loading the filetype plugin. + vim.command 'hi! CustomUserValue ctermfg=Red guifg=Red' + vim.command 'hi! link scalaKeyword CustomUserValue' + plugin_loader.call + + # 'verbose hi scalaKeyword' returns 'scalaKeyword xxx links to NNN' + # That NNN should still be our custom value. + keyword_linked_to = vim.command('verbose hi scalaKeyword').split[4] + keyword_linked_to.must_equal "CustomUserValue" + end + end + + it 'allows the user to override scala-specific colors' do + start_vim_without_plugins do |vim, plugin_loader| + # Set our custom value, then load the plugins. + # This simulates vim loading .vimrc then later loading the filetype plugin. + vim.command 'hi! scalaKeyword ctermfg=123 guifg=123' + plugin_loader.call + + keyword_fg_color = vim.echo('synIDattr(synIDtrans(hlID("scalaKeyword")), "fg")') + keyword_fg_color.must_equal '123' + end + end +end diff --git a/syntax/scala.vim b/syntax/scala.vim index 2e1ec7f..161ba3f 100644 --- a/syntax/scala.vim +++ b/syntax/scala.vim @@ -43,53 +43,53 @@ syn keyword scalaKeyword class trait object extends with nextgroup=scalaInstance syn keyword scalaKeyword case nextgroup=scalaKeyword,scalaCaseFollowing skipwhite syn keyword scalaKeyword val nextgroup=scalaNameDefinition,scalaQuasiQuotes skipwhite syn keyword scalaKeyword def var nextgroup=scalaNameDefinition skipwhite -hi link scalaKeyword Keyword +hi def link scalaKeyword Keyword exe 'syn region scalaBlock start=/{/ end=/}/ contains=' . s:ContainedGroup() . ' fold' syn keyword scalaAkkaSpecialWord when goto using startWith initialize onTransition stay become unbecome -hi link scalaAkkaSpecialWord PreProc +hi def link scalaAkkaSpecialWord PreProc syn keyword scalatestSpecialWord shouldBe syn match scalatestShouldDSLA /^\s\+\zsit should/ syn match scalatestShouldDSLB /\/ -hi link scalatestSpecialWord PreProc -hi link scalatestShouldDSLA PreProc -hi link scalatestShouldDSLB PreProc +hi def link scalatestSpecialWord PreProc +hi def link scalatestShouldDSLA PreProc +hi def link scalatestShouldDSLB PreProc syn match scalaSymbol /'[_A-Za-z0-9$]\+/ -hi link scalaSymbol Number +hi def link scalaSymbol Number -syn match scalaChar /'.'/ -syn match scalaChar /'\\[\\"'ntbrf]'/ contains=scalaEscapedChar -syn match scalaChar /'\\u[A-Fa-f0-9]\{4}'/ contains=scalaUnicodeChar -syn match scalaEscapedChar /\\[\\"'ntbrf]/ -syn match scalaUnicodeChar /\\u[A-Fa-f0-9]\{4}/ -hi link scalaChar Character -hi link scalaEscapedChar Function -hi link scalaUnicodeChar Special +syn match scalaCharacter /'.'/ +syn match scalaCharacter /'\\[\\"'ntbrf]'/ contains=scalaEscapedCharacter +syn match scalaCharacter /'\\u[A-Fa-f0-9]\{4}'/ contains=scalaUnicodeCharacter +syn match scalaEscapedCharacter /\\[\\"'ntbrf]/ +syn match scalaUnicodeCharacter /\\u[A-Fa-f0-9]\{4}/ +hi def link scalaCharacter Character +hi def link scalaEscapedCharacter Function +hi def link scalaUnicodeCharacter Special syn match scalaOperator "||" syn match scalaOperator "&&" -hi link scalaOperator Special +hi def link scalaOperator Special syn match scalaNameDefinition /\<[_A-Za-z0-9$]\+\>/ contained nextgroup=scalaPostNameDefinition,scalaVariableDeclarationList syn match scalaNameDefinition /`[^`]\+`/ contained nextgroup=scalaPostNameDefinition syn match scalaVariableDeclarationList /\s*,\s*/ contained nextgroup=scalaNameDefinition syn match scalaPostNameDefinition /\_s*:\_s*/ contained nextgroup=scalaTypeDeclaration -hi link scalaNameDefinition Function +hi def link scalaNameDefinition Function syn match scalaInstanceDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaInstanceHash syn match scalaInstanceDeclaration /`[^`]\+`/ contained syn match scalaInstanceHash /#/ contained nextgroup=scalaInstanceDeclaration -hi link scalaInstanceDeclaration Special -hi link scalaInstanceHash Type +hi def link scalaInstanceDeclaration Special +hi def link scalaInstanceHash Type syn match scalaUnimplemented /???/ -hi link scalaUnimplemented ERROR +hi def link scalaUnimplemented ERROR syn match scalaCapitalWord /\<[A-Z][A-Za-z0-9$]*\>/ -hi link scalaCapitalWord Special +hi def link scalaCapitalWord Special " Handle type declarations specially syn region scalaTypeStatement matchgroup=Keyword start=/\]/ contained nextgroup=scalaTypeTypePostDe syn match scalaTypeTypeExtension /)\?\_s*\zs\%(⇒\|=>\|<:\|:>\|=:=\|::\|#\)/ contained contains=scalaTypeOperator nextgroup=scalaTypeTypeDeclaration skipwhite syn match scalaTypeTypePostDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaTypeTypePostExtension skipwhite syn match scalaTypeTypePostExtension /\%(⇒\|=>\|<:\|:>\|=:=\|::\)/ contained contains=scalaTypeOperator nextgroup=scalaTypeTypePostDeclaration skipwhite -hi link scalaTypeTypeDeclaration Type -hi link scalaTypeTypeExtension Keyword -hi link scalaTypeTypePostDeclaration Special -hi link scalaTypeTypePostExtension Keyword +hi def link scalaTypeTypeDeclaration Type +hi def link scalaTypeTypeExtension Keyword +hi def link scalaTypeTypePostDeclaration Special +hi def link scalaTypeTypePostExtension Keyword syn match scalaTypeDeclaration /(/ contained nextgroup=scalaTypeExtension contains=scalaRoundBrackets skipwhite syn match scalaTypeDeclaration /\%(⇒\|=>\)\ze/ contained nextgroup=scalaTypeDeclaration contains=scalaTypeExtension skipwhite syn match scalaTypeDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaTypeExtension skipwhite syn match scalaTypeExtension /)\?\_s*\zs\%(⇒\|=>\|<:\|:>\|=:=\|::\|#\)/ contained contains=scalaTypeOperator nextgroup=scalaTypeDeclaration skipwhite -hi link scalaTypeDeclaration Type -hi link scalaTypeExtension Keyword -hi link scalaTypePostExtension Keyword +hi def link scalaTypeDeclaration Type +hi def link scalaTypeExtension Keyword +hi def link scalaTypePostExtension Keyword syn match scalaTypeAnnotation /\%([_a-zA-Z0-9$\s]:\_s*\)\ze[_=(\.A-Za-z0-9$]\+/ skipwhite nextgroup=scalaTypeDeclaration contains=scalaRoundBrackets syn match scalaTypeAnnotation /)\_s*:\_s*\ze[_=(\.A-Za-z0-9$]\+/ skipwhite nextgroup=scalaTypeDeclaration -hi link scalaTypeAnnotation Normal +hi def link scalaTypeAnnotation Normal syn match scalaCaseFollowing /\<[_\.A-Za-z0-9$]\+\>/ contained contains=scalaCapitalWord syn match scalaCaseFollowing /`[^`]\+`/ contained contains=scalaCapitalWord -hi link scalaCaseFollowing Special +hi def link scalaCaseFollowing Special syn keyword scalaKeywordModifier abstract override final lazy implicit private protected sealed null super syn keyword scalaSpecialFunction implicitly require -hi link scalaKeywordModifier Function -hi link scalaSpecialFunction Function +hi def link scalaKeywordModifier Function +hi def link scalaSpecialFunction Function syn keyword scalaSpecial this true false ne eq syn keyword scalaSpecial new nextgroup=scalaInstanceDeclaration skipwhite syn match scalaSpecial "\%(=>\|⇒\|<-\|←\|->\|→\)" syn match scalaSpecial /`[^`]\+`/ " Backtick literals -hi link scalaSpecial PreProc +hi def link scalaSpecial PreProc syn keyword scalaExternal package import -hi link scalaExternal Include +hi def link scalaExternal Include syn match scalaStringEmbeddedQuote /\\"/ contained -syn region scalaString start=/"/ end=/"/ contains=scalaStringEmbeddedQuote,scalaEscapedChar,scalaUnicodeChar -hi link scalaString String -hi link scalaStringEmbeddedQuote String +syn region scalaString start=/"/ end=/"/ contains=scalaStringEmbeddedQuote,scalaEscapedCharacter,scalaUnicodeCharacter +hi def link scalaString String +hi def link scalaStringEmbeddedQuote String -syn region scalaIString matchgroup=scalaInterpolationBrackets start=/\<[a-zA-Z][a-zA-Z0-9_]*"/ skip=/\\"/ end=/"/ contains=scalaInterpolation,scalaInterpolationB,scalaEscapedChar,scalaUnicodeChar -syn region scalaTripleIString matchgroup=scalaInterpolationBrackets start=/\<[a-zA-Z][a-zA-Z0-9_]*"""/ end=/"""\%([^"]\|$\)/ contains=scalaInterpolation,scalaInterpolationB,scalaEscapedChar,scalaUnicodeChar -hi link scalaIString String -hi link scalaTripleIString String +syn region scalaIString matchgroup=scalaInterpolationBrackets start=/\<[a-zA-Z][a-zA-Z0-9_]*"/ skip=/\\"/ end=/"/ contains=scalaInterpolation,scalaInterpolationB,scalaEscapedCharacter,scalaUnicodeCharacter +syn region scalaTripleIString matchgroup=scalaInterpolationBrackets start=/\<[a-zA-Z][a-zA-Z0-9_]*"""/ end=/"""\%([^"]\|$\)/ contains=scalaInterpolation,scalaInterpolationB,scalaEscapedCharacter,scalaUnicodeCharacter +hi def link scalaIString String +hi def link scalaTripleIString String syn match scalaInterpolation /\$[a-zA-Z0-9_$]\+/ contained exe 'syn region scalaInterpolationB matchgroup=scalaInterpolationBoundary start=/\${/ end=/}/ contained contains=' . s:ContainedGroup() -hi link scalaInterpolation Function -hi link scalaInterpolationB Normal +hi def link scalaInterpolation Function +hi def link scalaInterpolationB Normal -syn region scalaFString matchgroup=scalaInterpolationBrackets start=/f"/ skip=/\\"/ end=/"/ contains=scalaFInterpolation,scalaFInterpolationB,scalaEscapedChar,scalaUnicodeChar +syn region scalaFString matchgroup=scalaInterpolationBrackets start=/f"/ skip=/\\"/ end=/"/ contains=scalaFInterpolation,scalaFInterpolationB,scalaEscapedCharacter,scalaUnicodeCharacter syn match scalaFInterpolation /\$[a-zA-Z0-9_$]\+\(%[-A-Za-z0-9\.]\+\)\?/ contained exe 'syn region scalaFInterpolationB matchgroup=scalaInterpolationBoundary start=/${/ end=/}\(%[-A-Za-z0-9\.]\+\)\?/ contained contains=' . s:ContainedGroup() -hi link scalaFString String -hi link scalaFInterpolation Function -hi link scalaFInterpolationB Normal +hi def link scalaFString String +hi def link scalaFInterpolation Function +hi def link scalaFInterpolationB Normal -syn region scalaTripleString start=/"""/ end=/"""\%([^"]\|$\)/ contains=scalaEscapedChar,scalaUnicodeChar -syn region scalaTripleFString matchgroup=scalaInterpolationBrackets start=/f"""/ end=/"""\%([^"]\|$\)/ contains=scalaFInterpolation,scalaFInterpolationB,scalaEscapedChar,scalaUnicodeChar -hi link scalaTripleString String -hi link scalaTripleFString String +syn region scalaTripleString start=/"""/ end=/"""\%([^"]\|$\)/ contains=scalaEscapedCharacter,scalaUnicodeCharacter +syn region scalaTripleFString matchgroup=scalaInterpolationBrackets start=/f"""/ end=/"""\%([^"]\|$\)/ contains=scalaFInterpolation,scalaFInterpolationB,scalaEscapedCharacter,scalaUnicodeCharacter +hi def link scalaTripleString String +hi def link scalaTripleFString String -hi link scalaInterpolationBrackets Special -hi link scalaInterpolationBoundary Function +hi def link scalaInterpolationBrackets Special +hi def link scalaInterpolationBoundary Function syn match scalaNumber /\<0[dDfFlL]\?\>/ " Just a bare 0 syn match scalaNumber /\<[1-9]\d*[dDfFlL]\?\>/ " A multi-digit number - octal numbers with leading 0's are deprecated in Scala @@ -174,16 +174,16 @@ syn match scalaNumber /\<0[xX][0-9a-fA-F]\+[dDfFlL]\?\>/ " Hex number syn match scalaNumber /\%(\<\d\+\.\d*\|\.\d\+\)\%([eE][-+]\=\d\+\)\=[fFdD]\=/ " exponential notation 1 syn match scalaNumber /\<\d\+[eE][-+]\=\d\+[fFdD]\=\>/ " exponential notation 2 syn match scalaNumber /\<\d\+\%([eE][-+]\=\d\+\)\=[fFdD]\>/ " exponential notation 3 -hi link scalaNumber Number +hi def link scalaNumber Number syn region scalaRoundBrackets start="(" end=")" skipwhite contained contains=scalaTypeDeclaration,scalaSquareBrackets,scalaRoundBrackets syn region scalaSquareBrackets matchgroup=scalaSquareBracketsBrackets start="\[" end="\]" skipwhite nextgroup=scalaTypeExtension contains=scalaTypeDeclaration,scalaSquareBrackets,scalaTypeOperator,scalaTypeAnnotationParameter syn match scalaTypeOperator /[-+=:<>]\+/ contained syn match scalaTypeAnnotationParameter /@\<[`_A-Za-z0-9$]\+\>/ contained -hi link scalaSquareBracketsBrackets Type -hi link scalaTypeOperator Keyword -hi link scalaTypeAnnotationParameter Function +hi def link scalaSquareBracketsBrackets Type +hi def link scalaTypeOperator Keyword +hi def link scalaTypeAnnotationParameter Function syn match scalaShebang "\%^#!.*" display syn region scalaMultilineComment start="/\*" end="\*/" contains=scalaMultilineComment,scalaDocLinks,scalaParameterAnnotation,scalaCommentAnnotation,scalaTodo,scalaCommentCodeBlock,@Spell keepend fold @@ -193,20 +193,20 @@ syn match scalaParamAnnotationValue /[.`_A-Za-z0-9$]\+/ contained syn region scalaDocLinks start="\[\[" end="\]\]" contained syn region scalaCommentCodeBlock matchgroup=Keyword start="{{{" end="}}}" contained syn match scalaTodo "\vTODO|FIXME|XXX" contained -hi link scalaShebang Comment -hi link scalaMultilineComment Comment -hi link scalaDocLinks Function -hi link scalaParameterAnnotation Function -hi link scalaParamAnnotationValue Keyword -hi link scalaCommentAnnotation Function -hi link scalaCommentCodeBlock String -hi link scalaTodo Todo +hi def link scalaShebang Comment +hi def link scalaMultilineComment Comment +hi def link scalaDocLinks Function +hi def link scalaParameterAnnotation Function +hi def link scalaParamAnnotationValue Keyword +hi def link scalaCommentAnnotation Function +hi def link scalaCommentCodeBlock String +hi def link scalaTodo Todo syn match scalaAnnotation /@\<[`_A-Za-z0-9$]\+\>/ -hi link scalaAnnotation PreProc +hi def link scalaAnnotation PreProc syn match scalaTrailingComment "//.*$" contains=scalaTodo,@Spell -hi link scalaTrailingComment Comment +hi def link scalaTrailingComment Comment syn match scalaAkkaFSM /goto([^)]*)\_s\+\/ contains=scalaAkkaFSMGotoUsing syn match scalaAkkaFSM /stay\_s\+using/ @@ -219,8 +219,8 @@ syn match scalaAkkaFSM /onTermination/ syn match scalaAkkaFSM /whenUnhandled/ syn match scalaAkkaFSMGotoUsing /\/ syn match scalaAkkaFSMGotoUsing /\/ -hi link scalaAkkaFSM PreProc -hi link scalaAkkaFSMGotoUsing PreProc +hi def link scalaAkkaFSM PreProc +hi def link scalaAkkaFSMGotoUsing PreProc let b:current_syntax = 'scala'