├── .gitignore ├── README.mkd ├── autoload └── ruby_heredoc_syntax.vim ├── plugin └── ruby_heredoc_syntax.vim ├── sample.rb └── screenshot.png /.gitignore: -------------------------------------------------------------------------------- 1 | doc/tags 2 | -------------------------------------------------------------------------------- /README.mkd: -------------------------------------------------------------------------------- 1 | 2 | **This project is deprecated. Please use [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) and colorscheme supporting treesitter** 3 | 4 | # vim-ruby-heredoc-syntax 5 | 6 | This enables syntax highlighting in Ruby here document code blocks. 7 | 8 | ## Install 9 | 10 | Use neobundle.vim: 11 | 12 | ```vim 13 | NeoBundle 'joker1007/vim-ruby-heredoc-syntax' 14 | ``` 15 | 16 | ## For neosnippet & context\_filetype 17 | If you have the context\_filetype.vim plugin, 18 | this adds context filetype setting for Ruby here document block. 19 | 20 | ## Screenshot 21 | 22 | ![screenshot.png](screenshot.png) 23 | 24 | ## Options 25 | 26 | ```vim 27 | " Add syntax rule 28 | let g:ruby_heredoc_syntax_filetypes = { 29 | \ "xml" : { 30 | \ "start" : "XML", 31 | \}, 32 | \} 33 | 34 | " 'start' is heredoc start literal. 35 | ``` 36 | 37 | -------------------------------------------------------------------------------- /autoload/ruby_heredoc_syntax.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " FILE: ruby_heredoc_syntax.vim 3 | " AUTHOR: Tomohiro Hashidate 4 | " License: MIT license {{{ 5 | " Permission is hereby granted, free of charge, to any person obtaining 6 | " a copy of this software and associated documentation files (the 7 | " "Software"), to deal in the Software without restriction, including 8 | " without limitation the rights to use, copy, modify, merge, publish, 9 | " distribute, sublicense, and/or sell copies of the Software, and to 10 | " permit persons to whom the Software is furnished to do so, subject to 11 | " the following conditions: 12 | " 13 | " The above copyright notice and this permission notice shall be included 14 | " in all copies or substantial portions of the Software. 15 | " 16 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | " }}} 24 | "============================================================================= 25 | 26 | let s:save_cpo = &cpo 27 | set cpo&vim 28 | 29 | function! ruby_heredoc_syntax#syntax_group(filetype) 30 | let ft = toupper(a:filetype) 31 | return 'rubyHereDocCodeGroup'.ft 32 | endfunction 33 | 34 | function! ruby_heredoc_syntax#syntax_code_region(filetype) 35 | let ft = toupper(a:filetype) 36 | return 'rubyHereDocCodeRegion'.ft 37 | endfunction 38 | 39 | function! ruby_heredoc_syntax#syntax_start_region(filetype) 40 | let ft = toupper(a:filetype) 41 | return 'rubyHereDocCodeStart'.ft 42 | endfunction 43 | 44 | function! ruby_heredoc_syntax#include_other_syntax(filetype) 45 | let group = ruby_heredoc_syntax#syntax_group(a:filetype) 46 | 47 | " syntax save 48 | if exists('b:current_syntax') 49 | let s:current_syntax = b:current_syntax 50 | unlet b:current_syntax 51 | endif 52 | 53 | execute 'syntax include @'.group.' syntax/'.a:filetype.'.vim' 54 | 55 | " syntax restore 56 | if exists('s:current_syntax') 57 | let b:current_syntax=s:current_syntax 58 | else 59 | unlet b:current_syntax 60 | endif 61 | 62 | return group 63 | endfunction 64 | 65 | function! ruby_heredoc_syntax#enable_heredoc_highlight(filetype, start) 66 | let group = ruby_heredoc_syntax#syntax_group(a:filetype) 67 | let start_region = ruby_heredoc_syntax#syntax_start_region(a:filetype) 68 | let code_region = ruby_heredoc_syntax#syntax_code_region(a:filetype) 69 | 70 | let regexp1 = "\\%(\\%(class\\s*\\|\\%([]})\"'.]\\|::\\)\\)\\_s*\\|\\w\\)\\@ 4 | " License: MIT license {{{ 5 | " Permission is hereby granted, free of charge, to any person obtaining 6 | " a copy of this software and associated documentation files (the 7 | " "Software"), to deal in the Software without restriction, including 8 | " without limitation the rights to use, copy, modify, merge, publish, 9 | " distribute, sublicense, and/or sell copies of the Software, and to 10 | " permit persons to whom the Software is furnished to do so, subject to 11 | " the following conditions: 12 | " 13 | " The above copyright notice and this permission notice shall be included 14 | " in all copies or substantial portions of the Software. 15 | " 16 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | " }}} 24 | "============================================================================= 25 | 26 | if exists('g:loaded_ruby_heredoc_syntax') 27 | finish 28 | endif 29 | 30 | let s:save_cpo = &cpo 31 | set cpo&vim 32 | 33 | if !exists('g:ruby_heredoc_syntax_defaults') 34 | let g:ruby_heredoc_syntax_defaults = { 35 | \ "javascript" : { 36 | \ "start" : "JS", 37 | \}, 38 | \ "sql" : { 39 | \ "start" : "SQL", 40 | \}, 41 | \ "html" : { 42 | \ "start" : "HTML", 43 | \}, 44 | \} 45 | endif 46 | 47 | if !exists('g:ruby_heredoc_syntax_filetypes') 48 | let g:ruby_heredoc_syntax_filetypes = {} 49 | endif 50 | 51 | let s:context_filetypes_ruby = { 52 | \ 'ruby' : [ 53 | \ { 54 | \ 'start' : '\%(\%(class\s*\|\%([]})".]\|::\)\)\_s*\|\w\)\@ () 18 | console.log(@name) 19 | COFFEE 20 | 21 | puts coffee 22 | 23 | sql = < 31 | link 32 | 33 | HTML 34 | 35 | puts html 36 | 37 | normal = <