2014-03-13 3 views
0

coffee.vimjavascript.vim을 복사했습니다. 이제 커피 파일은 js 파일처럼 강조 표시됩니다.내 coffee.vim 구문 파일에서 "->"기호를 강조 표시하는 방법은 무엇입니까?

hi Special   guifg=#66D9EF guibg=bg  gui=italic 

내가 어디서부터 시작 정말 잘 모르겠어요 - ">"같은 색깔로 지금은 커피 스크립트 기능 화살표를하고 싶습니다.

제안 사항?

구문/coffee.vim :

" Language: CoffeeScript 
" Maintainer: Mick Koch <[email protected]> 
" URL:   http://github.com/kchmck/vim-coffee-script 
" License:  WTFPL 

if !exists("main_syntax") 
    if version < 600 
    syntax clear 
    elseif exists("b:current_syntax") 
    finish 
    endif 
    let main_syntax = 'coffeescript' 
endif 

"" Drop fold if it is set but VIM doesn't support it. 
let b:coffeescript_fold='true' 
if version < 600 " Don't support the old version 
    unlet! b:coffeescript_fold 
endif 

"" dollar sign is permittd anywhere in an identifier 
setlocal iskeyword+=$ 

syntax sync fromstart 

"" coffeescript comments 
syntax keyword coffeescriptCommentTodo TODO FIXME XXX TBD contained 
syntax region coffeescriptLineComment start=+\/\/+ end=+$+ keepend contains=coffeescriptCommentTodo,@Spell 
syntax region coffeescriptEnvComment  start="\%^#!" end="$" display 
syntax region coffeescriptLineComment start=+^\s*\/\/+ skip=+\n\s*\/\/+ end=+$+ keepend contains=coffeescriptCommentTodo,@Spell fold 
syntax region coffeescriptCvsTag   start="\$\cid:" end="\$" oneline contained 
syntax region coffeescriptComment  start="/\*" end="\*/" contains=coffeescriptCommentTodo,coffeescriptCvsTag,@Spell fold 

"" JSDoc/JSDoc Toolkit 
if !exists("coffeescript_ignore_coffeescriptdoc") 
    syntax case ignore 

    "" syntax coloring for javadoc comments (HTML) 
    "syntax include @javaHtml <sfile>:p:h/html.vim 
    "unlet b:current_syntax 

    syntax region coffeescriptDocComment  matchgroup=coffeescriptComment start="/\*\*\s*" end="\*/" contains=coffeescriptDocTags,coffeescriptCommentTodo,coffeescriptCvsTag,@coffeescriptHtml,@Spell fold 

    " tags containing a param 
    syntax match coffeescriptDocTags   contained "@\(augments\|base\|borrows\|class\|constructs\|default\|exception\|exports\|extends\|file\|member\|memberOf\|methodOf\|module\|name\|namespace\|optional\|requires\|title\|throws\|version\)\>" nextgroup=coffeescriptDocParam skipwhite 
    " tags containing type and param 
    syntax match coffeescriptDocTags   contained "@\(argument\|param\|property\)\>" nextgroup=coffeescriptDocType skipwhite 
    " tags containing type but no param 
    syntax match coffeescriptDocTags   contained "@\(type\|return\|returns\|api\)\>" nextgroup=coffeescriptDocTypeNoParam skipwhite 
    " tags containing references 
    syntax match coffeescriptDocTags   contained "@\(lends\|link\|see\)\>" nextgroup=coffeescriptDocSeeTag skipwhite 
    " other tags (no extra syntax) 
    syntax match coffeescriptDocTags   contained "@\(access\|addon\|alias\|author\|beta\|constant\|const\|constructor\|copyright\|deprecated\|description\|event\|example\|exec\|field\|fileOverview\|fileoverview\|function\|global\|ignore\|inner\|license\|overview\|private\|protected\|project\|public\|readonly\|since\|static\)\>" 

    syntax region coffeescriptDocType   start="{" end="}" oneline contained nextgroup=coffeescriptDocParam skipwhite 
    syntax match coffeescriptDocType   contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+" nextgroup=coffeescriptDocParam skipwhite 
    syntax region coffeescriptDocTypeNoParam start="{" end="}" oneline contained 
    syntax match coffeescriptDocTypeNoParam contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+" 
    syntax match coffeescriptDocParam  contained "\%(#\|\"\|{\|}\|\w\|\.\|:\|\/\)\+" 
    syntax region coffeescriptDocSeeTag  contained matchgroup=coffeescriptDocSeeTag start="{" end="}" contains=coffeescriptDocTags 

    syntax case match 
endif "" JSDoc end 

syntax case match 

"" Syntax in the coffeescript code 
syntax match coffeescriptSpecial  "\\\d\d\d\|\\x\x\{2\}\|\\u\x\{4\}\|\\." 
syntax region coffeescriptStringD  start=+"+ skip=+\\\\\|\\$"+ end=+"+ contains=coffeescriptSpecial,@htmlPreproc 
syntax region coffeescriptStringS  start=+'+ skip=+\\\\\|\\$'+ end=+'+ contains=coffeescriptSpecial,@htmlPreproc 
syntax region coffeescriptRegexpCharClass start=+\[+ end=+\]+ contained 
syntax region coffeescriptRegexpString start=+\(\(\(return\|case\)\s\+\)\@<=\|\(\([)\]"']\|\d\|\w\)\s*\)\@<!\)/\(\*\|/\)\@!+ skip=+\\\\\|\\/+ end=+/[gimy]\{,4}+ contains=coffeescriptSpecial,coffeescriptRegexpCharClass,@htmlPreproc oneline 
syntax match coffeescriptNumber   /\<-\=\d\+L\=\>\|\<0[xX]\x\+\>/ 
syntax match coffeescriptFloat   /\<-\=\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-]\=\d\+\)\=\>/ 
syntax match coffeescriptLabel   /\<\w\+\(\s*:\)\@=/ 

"" coffeescript Prototype 
syntax keyword coffeescriptPrototype  prototype 

"" Program Keywords 
syntax keyword coffeescriptSource   import export 
syntax keyword coffeescriptType   const undefined var void yield 
syntax keyword coffeescriptOperator  delete new in instanceof let typeof 
syntax keyword coffeescriptBoolean  true false 
syntax keyword coffeescriptNull   null 
syntax keyword coffeescriptThis   this 

"" Statement Keywords 
syntax keyword coffeescriptConditional if else 
syntax keyword coffeescriptRepeat   do while for 
syntax keyword coffeescriptBranch   break continue switch case default return 
syntax keyword coffeescriptStatement  try catch throw with finally 

syntax keyword coffeescriptGlobalObjects Array Boolean Date Function Infinity JavaArray JavaClass JavaObject JavaPackage Math Number NaN Object Packages RegExp String Undefined java netscape sun 

syntax keyword coffeescriptExceptions  Error EvalError RangeError ReferenceError SyntaxError TypeError URIError 

syntax keyword coffeescriptFutureKeys  abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws goto private transient debugger implements protected volatile double import public 

"" DOM/HTML/CSS specified things 

    " DOM2 Objects 
    syntax keyword coffeescriptGlobalObjects DOMImplementation DocumentFragment Document Node NodeList NamedNodeMap CharacterData Attr Element Text Comment CDATASection DocumentType Notation Entity EntityReference ProcessingInstruction 
    syntax keyword coffeescriptExceptions  DOMException 

    " DOM2 CONSTANT 
    syntax keyword coffeescriptDomErrNo  INDEX_SIZE_ERR DOMSTRING_SIZE_ERR HIERARCHY_REQUEST_ERR WRONG_DOCUMENT_ERR INVALID_CHARACTER_ERR NO_DATA_ALLOWED_ERR NO_MODIFICATION_ALLOWED_ERR NOT_FOUND_ERR NOT_SUPPORTED_ERR INUSE_ATTRIBUTE_ERR INVALID_STATE_ERR SYNTAX_ERR INVALID_MODIFICATION_ERR NAMESPACE_ERR INVALID_ACCESS_ERR 
    syntax keyword coffeescriptDomNodeConsts ELEMENT_NODE ATTRIBUTE_NODE TEXT_NODE CDATA_SECTION_NODE ENTITY_REFERENCE_NODE ENTITY_NODE PROCESSING_INSTRUCTION_NODE COMMENT_NODE DOCUMENT_NODE DOCUMENT_TYPE_NODE DOCUMENT_FRAGMENT_NODE NOTATION_NODE 

    " HTML events and internal variables 
    syntax case ignore 
    syntax keyword coffeescriptHtmlEvents  onblur onclick oncontextmenu ondblclick onfocus onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup onresize 
    syntax case match 

" Follow stuff should be highligh within a special context 
" While it can't be handled with context depended with Regex based highlight 
" So, turn it off by default 
if exists("coffeescript_enable_domhtmlcss") 

    " DOM2 things 
    syntax match coffeescriptDomElemAttrs  contained /\%(nodeName\|nodeValue\|nodeType\|parentNode\|childNodes\|firstChild\|lastChild\|previousSibling\|nextSibling\|attributes\|ownerDocument\|namespaceURI\|prefix\|localName\|tagName\)\>/ 
    syntax match coffeescriptDomElemFuncs  contained /\%(insertBefore\|replaceChild\|removeChild\|appendChild\|hasChildNodes\|cloneNode\|normalize\|isSupported\|hasAttributes\|getAttribute\|setAttribute\|removeAttribute\|getAttributeNode\|setAttributeNode\|removeAttributeNode\|getElementsByTagName\|getAttributeNS\|setAttributeNS\|removeAttributeNS\|getAttributeNodeNS\|setAttributeNodeNS\|getElementsByTagNameNS\|hasAttribute\|hasAttributeNS\)\>/ nextgroup=coffeescriptParen skipwhite 
    " HTML things 
    syntax match coffeescriptHtmlElemAttrs contained /\%(className\|clientHeight\|clientLeft\|clientTop\|clientWidth\|dir\|id\|innerHTML\|lang\|length\|offsetHeight\|offsetLeft\|offsetParent\|offsetTop\|offsetWidth\|scrollHeight\|scrollLeft\|scrollTop\|scrollWidth\|style\|tabIndex\|title\)\>/ 
    syntax match coffeescriptHtmlElemFuncs contained /\%(blur\|click\|focus\|scrollIntoView\|addEventListener\|dispatchEvent\|removeEventListener\|item\)\>/ nextgroup=coffeescriptParen skipwhite 

    " CSS Styles in coffeescript 
    syntax keyword coffeescriptCssStyles  contained color font fontFamily fontSize fontSizeAdjust fontStretch fontStyle fontVariant fontWeight letterSpacing lineBreak lineHeight quotes rubyAlign rubyOverhang rubyPosition 
    syntax keyword coffeescriptCssStyles  contained textAlign textAlignLast textAutospace textDecoration textIndent textJustify textJustifyTrim textKashidaSpace textOverflowW6 textShadow textTransform textUnderlinePosition 
    syntax keyword coffeescriptCssStyles  contained unicodeBidi whiteSpace wordBreak wordSpacing wordWrap writingMode 
    syntax keyword coffeescriptCssStyles  contained bottom height left position right top width zIndex 
    syntax keyword coffeescriptCssStyles  contained border borderBottom borderLeft borderRight borderTop borderBottomColor borderLeftColor borderTopColor borderBottomStyle borderLeftStyle borderRightStyle borderTopStyle borderBottomWidth borderLeftWidth borderRightWidth borderTopWidth borderColor borderStyle borderWidth borderCollapse borderSpacing captionSide emptyCells tableLayout 
    syntax keyword coffeescriptCssStyles  contained margin marginBottom marginLeft marginRight marginTop outline outlineColor outlineStyle outlineWidth padding paddingBottom paddingLeft paddingRight paddingTop 
    syntax keyword coffeescriptCssStyles  contained listStyle listStyleImage listStylePosition listStyleType 
    syntax keyword coffeescriptCssStyles  contained background backgroundAttachment backgroundColor backgroundImage gackgroundPosition backgroundPositionX backgroundPositionY backgroundRepeat 
    syntax keyword coffeescriptCssStyles  contained clear clip clipBottom clipLeft clipRight clipTop content counterIncrement counterReset cssFloat cursor direction display filter layoutGrid layoutGridChar layoutGridLine layoutGridMode layoutGridType 
    syntax keyword coffeescriptCssStyles  contained marks maxHeight maxWidth minHeight minWidth opacity MozOpacity overflow overflowX overflowY verticalAlign visibility zoom cssText 
    syntax keyword coffeescriptCssStyles  contained scrollbar3dLightColor scrollbarArrowColor scrollbarBaseColor scrollbarDarkShadowColor scrollbarFaceColor scrollbarHighlightColor scrollbarShadowColor scrollbarTrackColor 

    " Highlight ways 
    syntax match coffeescriptDotNotation  "\." nextgroup=coffeescriptPrototype,coffeescriptDomElemAttrs,coffeescriptDomElemFuncs,coffeescriptHtmlElemAttrs,coffeescriptHtmlElemFuncs 
    syntax match coffeescriptDotNotation  "\.style\." nextgroup=coffeescriptCssStyles 

endif "DOM/HTML/CSS 

"" end DOM/HTML/CSS specified things 


"" Code blocks 
" there is a name collision with coffeescriptExpression in html.vim, hence the use of the '2' here 
syntax cluster coffeescriptExpression2 contains=coffeescriptComment,coffeescriptLineComment,coffeescriptDocComment,coffeescriptStringD,coffeescriptStringS,coffeescriptRegexpString,coffeescriptNumber,coffeescriptFloat,coffeescriptSource,coffeescriptThis,coffeescriptType,coffeescriptOperator,coffeescriptBoolean,coffeescriptNull,coffeescriptFunction,coffeescriptGlobalObjects,coffeescriptExceptions,coffeescriptFutureKeys,coffeescriptDomErrNo,coffeescriptDomNodeConsts,coffeescriptHtmlEvents,coffeescriptDotNotation,coffeescriptBracket,coffeescriptParen,coffeescriptBlock,coffeescriptParenError 
syntax cluster coffeescriptAll  [email protected],coffeescriptLabel,coffeescriptConditional,coffeescriptRepeat,coffeescriptBranch,coffeescriptStatement,coffeescriptTernaryIf 
syntax region coffeescriptBracket matchgroup=coffeescriptBracket transparent start="\[" end="\]" [email protected],coffeescriptParensErrB,coffeescriptParensErrC,coffeescriptBracket,coffeescriptParen,coffeescriptBlock,@htmlPreproc 
syntax region coffeescriptParen  matchgroup=coffeescriptParen transparent start="(" end=")" [email protected],coffeescriptParensErrA,coffeescriptParensErrC,coffeescriptParen,coffeescriptBracket,coffeescriptBlock,@htmlPreproc 
syntax region coffeescriptBlock  matchgroup=coffeescriptBlock transparent start="{" end="}" [email protected],coffeescriptParensErrA,coffeescriptParensErrB,coffeescriptParen,coffeescriptBracket,coffeescriptBlock,@htmlPreproc 
syntax region coffeescriptTernaryIf matchgroup=coffeescriptTernaryIfOperator start=+?+ end=+:+ [email protected] 

"" catch errors caused by wrong parenthesis 
syntax match coffeescriptParensError ")\|}\|\]" 
syntax match coffeescriptParensErrA  contained "\]" 
syntax match coffeescriptParensErrB  contained ")" 
syntax match coffeescriptParensErrC  contained "}" 

if main_syntax == "coffeescript" 
    syntax sync clear 
    syntax sync ccomment coffeescriptComment minlines=200 
    syntax sync match coffeescriptHighlight grouphere coffeescriptBlock /{/ 
endif 

"" Fold control 
if exists("b:coffeescript_fold") 
    syntax match coffeescriptFunction  /\<function\>/ nextgroup=coffeescriptFuncName skipwhite 
    syntax match coffeescriptOpAssign  /=\@<!=/ nextgroup=coffeescriptFuncBlock skipwhite skipempty 
    syntax region coffeescriptFuncName  contained matchgroup=coffeescriptFuncName start=/\%(\$\|\w\)*\s*(/ end=/)/ contains=coffeescriptLineComment,coffeescriptComment nextgroup=coffeescriptFuncBlock skipwhite skipempty 
    syntax region coffeescriptFuncBlock  contained matchgroup=coffeescriptFuncBlock start="{" end="}" [email protected],coffeescriptParensErrA,coffeescriptParensErrB,coffeescriptParen,coffeescriptBracket,coffeescriptBlock fold 
else 
    syntax keyword coffeescriptFunction  function 
endif 

" Define the default highlighting. 
" For version 5.7 and earlier: only when not done already 
" For version 5.8 and later: only when an item doesn't have highlighting yet 
if version >= 508 || !exists("did_coffeescript_syn_inits") 
    if version < 508 
    let did_coffeescript_syn_inits = 1 
    command -nargs=+ HiLink hi link <args> 
    else 
    command -nargs=+ HiLink hi def link <args> 
    endif 
    HiLink coffeescriptComment    Comment 
    HiLink coffeescriptLineComment   Comment 
    HiLink coffeescriptEnvComment   PreProc 
    HiLink coffeescriptDocComment   Comment 
    HiLink coffeescriptCommentTodo   Todo 
    HiLink coffeescriptCvsTag    Function 
    HiLink coffeescriptDocTags    Special 
    HiLink coffeescriptDocSeeTag   Function 
    HiLink coffeescriptDocType    Type 
    HiLink coffeescriptDocTypeNoParam  Type 
    HiLink coffeescriptDocParam    Label 
    HiLink coffeescriptStringS    String 
    HiLink coffeescriptStringD    String 
    HiLink coffeescriptTernaryIfOperator Conditional 
    HiLink coffeescriptRegexpString   String 
    HiLink coffeescriptRegexpCharClass  Character 
    HiLink coffeescriptCharacter   Character 
    HiLink coffeescriptPrototype   Type 
    HiLink coffeescriptConditional   Conditional 
    HiLink coffeescriptBranch    Conditional 
    HiLink coffeescriptRepeat    Repeat 
    HiLink coffeescriptStatement   Statement 
    HiLink coffeescriptFunction    Function 
    HiLink coffeescriptError    Error 
    HiLink coffeescriptParensError   Error 
    HiLink coffeescriptParensErrA   Error 
    HiLink coffeescriptParensErrB   Error 
    HiLink coffeescriptParensErrC   Error 
    HiLink coffeescriptOperator    Operator 
    HiLink coffeescriptType     Type 
    HiLink coffeescriptThis     Type 
    HiLink coffeescriptNull     Type 
    HiLink coffeescriptNumber    Number 
    HiLink coffeescriptFloat    Number 
    HiLink coffeescriptBoolean    Boolean 
    HiLink coffeescriptLabel    Label 
    HiLink coffeescriptSpecial    Special 
    HiLink coffeescriptSource    Special 
    HiLink coffeescriptGlobalObjects  Special 
    HiLink coffeescriptExceptions   Special 

    HiLink coffeescriptDomErrNo    Constant 
    HiLink coffeescriptDomNodeConsts  Constant 
    HiLink coffeescriptDomElemAttrs   Label 
    HiLink coffeescriptDomElemFuncs   PreProc 

    HiLink coffeescriptHtmlEvents   Special 
    HiLink coffeescriptHtmlElemAttrs  Label 
    HiLink coffeescriptHtmlElemFuncs  PreProc 

    HiLink coffeescriptCssStyles   Label 

    delcommand HiLink 
endif 

" Define the htmlcoffeescript for HTML syntax html.vim 
"syntax clear htmlcoffeescript 
"syntax clear coffeescriptExpression 
syntax cluster htmlcoffeescript [email protected],coffeescriptBracket,coffeescriptParen,coffeescriptBlock,coffeescriptParenError 
syntax cluster coffeescriptExpression [email protected],coffeescriptBracket,coffeescriptParen,coffeescriptBlock,coffeescriptParenError,@htmlPreproc 
" Vim's default html.vim highlights all coffeescript as 'Special' 
hi! def link coffeescript NONE 

let b:current_syntax = "coffeescript" 
if main_syntax == 'coffeescript' 
    unlet main_syntax 
endif 

" vim: ts=4 

EDIT :

enter image description here

enter image description here

답변

1

원경 다른 구문 기 일치하지 않는 경우 ->, 그것은

처럼 간단해야합니다.
:syntax match coffeescriptArrow "->" 
:highlight def link coffeescriptArrow Special 

원본 구문 파일을 수정하지 않으려면 ~/.vim/after/syntax/coffeescript.vim에 넣으십시오.

+0

고마워요! 그러나 이상한 일부 화살표는 강조 표시되지 않습니다. EDIT를 참조하십시오. – alexchenco

+1

다른 구문 그룹에 포함되어 있습니다. 당신은 어느 것을 찾아야합니다. ': syn list'는 모든 활성 그룹을 보여줍니다. 그러나 [SyntaxAttr.vim - 커서 밑에있는 문자의 구문 강조 속성보기] (http://www.vim.org/scripts/script.php?script_id= 383) plugin. 불쾌한 구문 그룹의 이름을 가지고있을 때,'containsin = ..., ... '을 통해 명령에 추가합니다. –

+0

고마워요! 나는 그것을 시도 할 것이다. 마지막 질문 하나. 어디에서'containedin ='을 추가해야합니까? 왜 그것을 추가하면 문제가 해결됩니까? – alexchenco

관련 문제