├── .gitignore ├── README.markdown ├── after └── syntax │ ├── ruby.vim │ └── ruby │ └── minitest.vim └── doc └── ft-ruby-minitest-syntax.txt /.gitignore: -------------------------------------------------------------------------------- 1 | doc/tags 2 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | # vim-ruby-minitest 2 | 3 | Vim syntax highlighting and `i_CTRL-X_CTRL-U` completion of [MiniTest]( 4 | https://github.com/seattlerb/minitest#readme) methods and assertions. 5 | 6 | ## Installation 7 | 8 | 1. Copy the `after/` directory into one of your Vim runtime directories. 9 | 10 | 2. Add this snippet to your vimrc file for `i_CTRL-X_CTRL-U` completion: 11 | 12 | set completefunc=syntaxcomplete#Complete 13 | -------------------------------------------------------------------------------- /after/syntax/ruby.vim: -------------------------------------------------------------------------------- 1 | syntax keyword rubyTestMethod 2 | \ assert 3 | \ assert_block 4 | \ assert_empty 5 | \ assert_equal 6 | \ assert_in_delta 7 | \ assert_in_epsilon 8 | \ assert_includes 9 | \ assert_instance_of 10 | \ assert_kind_of 11 | \ assert_match 12 | \ assert_nil 13 | \ assert_operator 14 | \ assert_predicate 15 | \ assert_raises 16 | \ assert_respond_to 17 | \ assert_same 18 | \ assert_silent 19 | \ assert_throws 20 | \ flunk 21 | \ must_be 22 | \ must_be_close_to 23 | \ must_be_empty 24 | \ must_be_instance_of 25 | \ must_be_kind_of 26 | \ must_be_nil 27 | \ must_be_same_as 28 | \ must_be_silent 29 | \ must_be_within_delta 30 | \ must_be_within_epsilon 31 | \ must_equal 32 | \ must_include 33 | \ must_match 34 | \ must_output 35 | \ must_raise 36 | \ must_respond_to 37 | \ must_send 38 | \ must_throw 39 | \ pass 40 | \ refute 41 | \ refute_empty 42 | \ refute_equal 43 | \ refute_in_delta 44 | \ refute_in_epsilon 45 | \ refute_includes 46 | \ refute_instance_of 47 | \ refute_kind_of 48 | \ refute_match 49 | \ refute_nil 50 | \ refute_operator 51 | \ refute_predicate 52 | \ refute_respond_to 53 | \ refute_same 54 | \ skip 55 | \ wont_be 56 | \ wont_be_close_to 57 | \ wont_be_empty 58 | \ wont_be_instance_of 59 | \ wont_be_kind_of 60 | \ wont_be_nil 61 | \ wont_be_same_as 62 | \ wont_be_within_delta 63 | \ wont_be_within_epsilon 64 | \ wont_equal 65 | \ wont_include 66 | \ wont_match 67 | \ wont_respond_to 68 | 69 | syntax keyword rubyTestStatement 70 | \ after 71 | \ before 72 | \ context 73 | \ expect 74 | \ setup 75 | \ should 76 | \ teardown 77 | \ scenario 78 | \ feature 79 | \ background 80 | 81 | " See after/syntax/ruby/minitest.vim for "describe, it" blocks definition 82 | 83 | highlight link rubyTestMethod Function 84 | highlight link rubyTestStatement Statement 85 | -------------------------------------------------------------------------------- /after/syntax/ruby/minitest.vim: -------------------------------------------------------------------------------- 1 | let s:fold = get(b:, 'ruby_minitest_fold', get(g:, 'ruby_minitest_fold')) 2 | let s:i = '' 3 | 4 | if !has('folding') || empty(s:fold) 5 | syntax keyword rubyTestMethod 6 | \ describe 7 | \ it 8 | finish 9 | else 10 | let s:fold = ' fold' 11 | endif 12 | 13 | " Regions for `describe ... end` blocks, 14 | " named with `rubyMinitestDescribeBlock` and so on. 15 | for s:i in ['describe', 'it'] 16 | let s:group_name = 'rubyMinitest' . substitute(s:i, '^.', '\u\0', '') . 'Block' 17 | execute 'syntax region ' . s:group_name . ' matchgroup=rubyControl ' . 18 | \ 'start="^\z(\s*\)' . s:i . '\>[?!]\@!" ' . 19 | \ 'end="^\z1end\>" ' . 20 | \ 'contains=ALLBUT,@rubyNotTop' . 21 | \ s:fold 22 | endfor 23 | unlet s:i 24 | -------------------------------------------------------------------------------- /doc/ft-ruby-minitest-syntax.txt: -------------------------------------------------------------------------------- 1 | RUBY MINITEST *ruby-minitest-syntax.vim* *ft-rubyminitest-syntax* 2 | 3 | ============================================================================== 4 | OPTIONS ~ 5 | 6 | *ruby_minitest_fold* 7 | ruby_minitest_fold (default: none) ~ 8 | 9 | Set to 1 to enable |folding| on main section blocks (`describe` and `it` 10 | blocks). 11 | 12 | Note: to reduce complexity, only `end` with same indentation level as 13 | its beginning is detected. > 14 | 15 | let g:ruby_minitest_fold = 1 16 | < 17 | - Must set before loading this syntax file. e.g., in .vimrc. 18 | - Remember also set 'foldmethod' to "syntax". 19 | - Support global (|g:|) or buffer-local (|b:|) setting. 20 | 21 | Note: Enabling ruby_mintest_fold if using another Ruby plug-in that provides 22 | folding, especially vim-ruby, is discouraged; block folding regions are 23 | defined in these plug-ins in incompatible ways. 24 | 25 | ============================================================================== 26 | vim:tw=78:fo=tcroq2mM:et:sts=2:sw=2:ft=help:norl: 27 | --------------------------------------------------------------------------------