Created
May 10, 2012 01:48
-
-
Save LeafCage/2650386 to your computer and use it in GitHub Desktop.
シンタックスハイライトをincludeする関数が意図したとおりに動かない。引数の一つ目については意図通り。2つめからがおかしい。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! Include_syntax(...) | |
for pickedft in a:000 | |
exe 'syn include @'.pickedft.' syntax/'.pickedft.'.vim' | |
exe 'syn region Syscommon_'.pickedft.' matchgroup=Syscommon_metamodify start=/^>|'.pickedft.'|\n/rs=e end=/^||</re=s-1 contains=@'.pickedft.' keepend' | |
endfor | |
hi Syscommon_metamodify gui=bold guifg=lightblue guibg=gray35 | |
endfunction | |
"想定利用法 | |
"例えば行頭に'>|vim|'と書くと次の行からvimのシンタックスが適用される | |
"この効果は行頭に'||<'がある行まで続く | |
"例 | |
>|vim| | |
let s:niconico = 'nicov' | |
noremap <c-a> a | |
||< | |
>|python| | |
print "Hallow" | |
||< | |
"問題点 | |
"なぜか引数の二つ目以降をハイライトしてくれない。 | |
"たとえば、引数に、'python','vim','perl'を与えた場合、 | |
シンタックスをincludeできているのは'python'だけである。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
解決した。
syntax定義ファイルでは、多重ロードを避けるために先頭でb:current_syntaxと言う変数の存在をチェックしている。つまり、syn include する前に unlet! b:current_syntax を実行する必要がある。
for pickedft in a:000
unlet! b:current_syntax
exe 'syn include @'.pickedft.' syntax/'.pickedft.'.vim'
exe 'syn region Syscommon_'.pickedft.' matchgroup=Syscommon_metamodify start=/^>|'.pickedft.'|\n/rs=e end=/^||</re=s-1 contains=@'.pickedft.' keepend'
endfor