From 270fb29052417f1fd818fecd4ec8a439c771aeba Mon Sep 17 00:00:00 2001 From: gryf Date: Wed, 20 Apr 2011 21:41:16 +0200 Subject: [PATCH] Update for mark, sorcerer, vylight. Removed syntax for C files (which was the base for pd_opl) --- GetLatest/GetLatestVimScripts.dat | 11 +- autoload/mark.vim | 219 +++++++++++------- colors/sorcerer.vim | 2 +- colors/vylight.vim | 42 ++-- doc/mark.txt | 53 ++++- doc/tags | 1 + plugin/mark.vim | 38 ++- syntax/c.vim | 368 ------------------------------ 8 files changed, 239 insertions(+), 495 deletions(-) delete mode 100644 syntax/c.vim diff --git a/GetLatest/GetLatestVimScripts.dat b/GetLatest/GetLatestVimScripts.dat index f9f4cd7..fcab87c 100644 --- a/GetLatest/GetLatestVimScripts.dat +++ b/GetLatest/GetLatestVimScripts.dat @@ -7,7 +7,7 @@ ScriptID SourceID Filename 311 7645 grep.vim 3304 15211 gundo.vim 2727 11120 jsbeautify.vim -2666 14741 Mark +2666 15477 Mark 2262 8944 occur.vim 910 14691 pydoc.vim #2421 9423 pysmell.vim @@ -24,9 +24,15 @@ ScriptID SourceID Filename 1984 13961 :AutoInstall: FuzzyFinder 3252 13948 :AutoInstall: L9 ### colors -1975 7471 lettuce.vim +2855 12456 github.vim +1143 11833 inkpot.vim +2555 15432 jellybeans.vim 2536 15197 lucius.vim +3299 14475 sorcerer.vim +3309 14699 vydark +2589 14175 vylight 1165 3741 tolerable.vim +415 15463 zenburn # compiler 891 10365 pylint.vim # ftplugin @@ -39,6 +45,7 @@ ScriptID SourceID Filename # http://monkey.org/~caz/python.vim ### syntax 790 14268 python.vim +2651 10658 fitnesse.vim ### doc 3277 14056 py2stdlib diff --git a/autoload/mark.vim b/autoload/mark.vim index cf1e01e..a29d216 100644 --- a/autoload/mark.vim +++ b/autoload/mark.vim @@ -10,8 +10,44 @@ " Dependencies: " - SearchSpecial.vim autoload script (optional, for improved search messages). " -" Version: 2.4.1 +" Version: 2.4.4 " Changes: +" 18-Apr-2011, Ingo Karkat +" - BUG: Include trailing newline character in check for current mark, so that a +" mark that matches the entire line (e.g. created by Vm) can be +" cleared via n. Thanks to ping for reporting this. +" - Minor restructuring of mark#MarkCurrentWord(). +" - FIX: On overlapping marks, mark#CurrentMark() returned the lowest, not the +" highest visible mark. So on overlapping marks, the one that was not visible +" at the cursor position was removed; very confusing! Use reverse iteration +" order. +" - FIX: To avoid an arbitrary ordering of highlightings when the highlighting +" group names roll over, and to avoid order inconsistencies across different +" windows and tabs, we assign a different priority based on the highlighting +" group. +" - Rename s:cycleMax to s:markNum; the previous name was too +" implementation-focused and off-by-one with regards to the actual value. +" +" 16-Apr-2011, Ingo Karkat +" - Move configuration variable g:mwHistAdd to plugin/mark.vim (as is customary) +" and make the remaining g:mw... variables script-local, as these contain +" internal housekeeping information that does not need to be accessible by the +" user. +" +" 15-Apr-2011, Ingo Karkat +" - Robustness: Move initialization of w:mwMatch from mark#UpdateMark() to +" s:MarkMatch(), where the variable is actually used. I had encountered cases +" where it w:mwMatch was undefined when invoked through mark#DoMark() -> +" s:MarkScope() -> s:MarkMatch(). This can be forced by :unlet w:mwMatch +" followed by :Mark foo. +" - Robustness: Checking for s:markNum == 0 in mark#DoMark(), trying to +" re-detect the mark highlightings and finally printing an error instead of +" choking. This can happen when somehow no mark highlightings are defined. +" +" 14-Jan-2011, Ingo Karkat +" - FIX: Capturing the visual selection could still clobber the blockwise yank +" mode of the unnamed register. +" " 13-Jan-2011, Ingo Karkat " - FIX: Using a named register for capturing the visual selection on " {Visual}m and {Visual}r clobbered the unnamed register. Now @@ -71,14 +107,14 @@ endfunction function! mark#MarkCurrentWord() let l:regexp = mark#CurrentMark()[0] if empty(l:regexp) - let l:cword = expand("") - - " The star command only creates a \ search pattern if the - " actually only consists of keyword characters. - if l:cword =~# '^\k\+$' - let l:regexp = '\<' . s:EscapeText(l:cword) . '\>' - elseif l:cword != '' + let l:cword = expand('') + if ! empty(l:cword) let l:regexp = s:EscapeText(l:cword) + " The star command only creates a \ search pattern if the + " actually only consists of keyword characters. + if l:cword =~# '^\k\+$' + let l:regexp = '\<' . l:regexp . '\>' + endif endif endif @@ -90,10 +126,11 @@ endfunction function! s:GetVisualSelection() let save_clipboard = &clipboard set clipboard= " Avoid clobbering the selection and clipboard registers. - let save_reg = @@ + let save_reg = getreg('"') + let save_regmode = getregtype('"') silent normal! gvy - let res = @@ - let @@ = save_reg + let res = getreg('"') + call setreg('"', save_reg, save_regmode) let &clipboard = save_clipboard return res endfunction @@ -117,14 +154,18 @@ function! mark#MarkRegex( regexpPreset ) endfunction function! s:Cycle( ... ) - let l:currentCycle = g:mwCycle - let l:newCycle = (a:0 ? a:1 : g:mwCycle) + 1 - let g:mwCycle = (l:newCycle < g:mwCycleMax ? l:newCycle : 0) + let l:currentCycle = s:cycle + let l:newCycle = (a:0 ? a:1 : s:cycle) + 1 + let s:cycle = (l:newCycle < s:markNum ? l:newCycle : 0) return l:currentCycle endfunction -" Set / clear matches in the current window. +" Set match / clear matches in the current window. function! s:MarkMatch( indices, expr ) + if ! exists('w:mwMatch') + let w:mwMatch = repeat([0], s:markNum) + endif + for l:index in a:indices if w:mwMatch[l:index] > 0 silent! call matchdelete(w:mwMatch[l:index]) @@ -133,13 +174,21 @@ function! s:MarkMatch( indices, expr ) endfor if ! empty(a:expr) + let l:index = a:indices[0] " Can only set one index for now. + + " Info: matchadd() does not consider the 'magic' (it's always on), + " 'ignorecase' and 'smartcase' settings. " Make the match according to the 'ignorecase' setting, like the star command. " (But honor an explicit case-sensitive regexp via the /\C/ atom.) let l:expr = ((&ignorecase && a:expr !~# '\\\@= 0 - call histadd("/", regexp) + if s:markNum <= 0 + " Uh, somehow no mark highlightings were defined. Try to detect them again. + call s:InitMarkVariables() + if s:markNum <= 0 + " Still no mark highlightings; complain. + let v:errmsg = 'No mark highlightings defined' + echohl ErrorMsg + echomsg v:errmsg + echohl None + return + endif endif - if stridx(g:mwHistAdd, "@") >= 0 - call histadd("@", regexp) + + " add to history + if stridx(g:mwHistAdd, '/') >= 0 + call histadd('/', regexp) + endif + if stridx(g:mwHistAdd, '@') >= 0 + call histadd('@', regexp) endif " choose an unused mark group let i = 0 - while i < g:mwCycleMax - if empty(g:mwWord[i]) - let g:mwWord[i] = regexp + while i < s:markNum + if empty(s:pattern[i]) + let s:pattern[i] = regexp call s:Cycle(i) call s:MarkScope([i], regexp) return @@ -224,43 +286,46 @@ function! mark#DoMark(...) " DoMark(regexp) " choose a mark group by cycle let i = s:Cycle() - if g:mwLastSearched == g:mwWord[i] - let g:mwLastSearched = '' + if s:lastSearch == s:pattern[i] + let s:lastSearch = '' endif - let g:mwWord[i] = regexp + let s:pattern[i] = regexp call s:MarkScope([i], regexp) endfunction " Initialize mark colors in a (new) window. function! mark#UpdateMark() - if ! exists('w:mwMatch') - let w:mwMatch = repeat([0], g:mwCycleMax) - endif - let i = 0 - while i < g:mwCycleMax - if empty(g:mwWord[i]) + while i < s:markNum + if empty(s:pattern[i]) call s:MarkMatch([i], '') else - call s:MarkMatch([i], g:mwWord[i]) + call s:MarkMatch([i], s:pattern[i]) endif let i += 1 endwhile endfunction " Return [mark text, mark start position] of the mark under the cursor (or -" ['', []] if there is no mark); multi-lines marks not supported. +" ['', []] if there is no mark). +" The mark can include the trailing newline character that concludes the line, +" but marks that span multiple lines are not supported. function! mark#CurrentMark() - let line = getline(".") - let i = 0 - while i < g:mwCycleMax - if !empty(g:mwWord[i]) + let line = getline('.') . "\n" + + " Highlighting groups with higher numbers take precedence over lower numbers, + " and therefore its marks appear "above" other marks. To retrieve the visible + " mark in case of overlapping marks, we need to check from highest to lowest + " highlighting group. + let i = s:markNum - 1 + while i >= 0 + if ! empty(s:pattern[i]) " Note: col() is 1-based, all other indexes zero-based! let start = 0 - while start >= 0 && start < strlen(line) && start < col(".") - let b = match(line, g:mwWord[i], start) - let e = matchend(line, g:mwWord[i], start) - if b < col(".") && col(".") <= e - return [g:mwWord[i], [line("."), (b + 1)]] + while start >= 0 && start < strlen(line) && start < col('.') + let b = match(line, s:pattern[i], start) + let e = matchend(line, s:pattern[i], start) + if b < col('.') && col('.') <= e + return [s:pattern[i], [line('.'), (b + 1)]] endif if b == e break @@ -268,7 +333,7 @@ function! mark#CurrentMark() let start = e endwhile endif - let i += 1 + let i -= 1 endwhile return ['', []] endfunction @@ -277,15 +342,15 @@ endfunction function! mark#SearchCurrentMark( isBackward ) let [l:markText, l:markPosition] = mark#CurrentMark() if empty(l:markText) - if empty(g:mwLastSearched) + if empty(s:lastSearch) call mark#SearchAnyMark(a:isBackward) - let g:mwLastSearched = mark#CurrentMark()[0] + let s:lastSearch = mark#CurrentMark()[0] else - call s:Search(g:mwLastSearched, a:isBackward, [], 'same-mark') + call s:Search(s:lastSearch, a:isBackward, [], 'same-mark') endif else - call s:Search(l:markText, a:isBackward, l:markPosition, (l:markText ==# g:mwLastSearched ? 'same-mark' : 'new-mark')) - let g:mwLastSearched = l:markText + call s:Search(l:markText, a:isBackward, l:markPosition, (l:markText ==# s:lastSearch ? 'same-mark' : 'new-mark')) + let s:lastSearch = l:markText endif endfunction @@ -436,7 +501,7 @@ endfunction " Combine all marks into one regexp. function! s:AnyMark() - return join(filter(copy(g:mwWord), '! empty(v:val)'), '\|') + return join(filter(copy(s:pattern), '! empty(v:val)'), '\|') endfunction " Search any mark. @@ -444,7 +509,7 @@ function! mark#SearchAnyMark( isBackward ) let l:markPosition = mark#CurrentMark()[1] let l:markText = s:AnyMark() call s:Search(l:markText, a:isBackward, l:markPosition, 'any-mark') - let g:mwLastSearched = "" + let s:lastSearch = "" endfunction " Search last searched mark. @@ -453,7 +518,7 @@ function! mark#SearchNext( isBackward ) if empty(l:markText) return 0 else - if empty(g:mwLastSearched) + if empty(s:lastSearch) call mark#SearchAnyMark(a:isBackward) else call mark#SearchCurrentMark(a:isBackward) @@ -472,25 +537,13 @@ augroup END " Define global variables and initialize current scope. function! s:InitMarkVariables() - if !exists("g:mwHistAdd") - let g:mwHistAdd = "/@" - endif - if !exists("g:mwCycleMax") - let i = 1 - while hlexists("MarkWord" . i) - let i = i + 1 - endwhile - let g:mwCycleMax = i - 1 - endif - if !exists("g:mwCycle") - let g:mwCycle = 0 - endif - if !exists("g:mwWord") - let g:mwWord = repeat([''], g:mwCycleMax) - endif - if !exists("g:mwLastSearched") - let g:mwLastSearched = "" - endif + let s:markNum = 0 + while hlexists('MarkWord' . (s:markNum + 1)) + let s:markNum += 1 + endwhile + let s:cycle = 0 + let s:pattern = repeat([''], s:markNum) + let s:lastSearch = "" endfunction call s:InitMarkVariables() call mark#UpdateScope() diff --git a/colors/sorcerer.vim b/colors/sorcerer.vim index 80fc2b9..d708c10 100644 --- a/colors/sorcerer.vim +++ b/colors/sorcerer.vim @@ -24,7 +24,7 @@ hi DiffText guifg=#000000 guibg=#8ee5ee gui=NONE hi Directory guifg=#1e90ff guibg=bg gui=NONE hi ErrorMsg guifg=#ff6a6a guibg=NONE gui=bold hi FoldColumn guifg=#68838b guibg=#4B4B4B gui=bold -hi Folded guifg=#99aacc guibg=#40403c gui=NONE +hi Folded guifg=#406060 guibg=#232c2c gui=NONE hi IncSearch guifg=#ffffff guibg=#ff4500 gui=bold hi LineNr guifg=#686858 guibg=#000000 gui=NONE hi MatchParen guifg=#fff000 guibg=#000000 gui=bold diff --git a/colors/vylight.vim b/colors/vylight.vim index 1f10785..85c86c6 100644 --- a/colors/vylight.vim +++ b/colors/vylight.vim @@ -2,8 +2,7 @@ " Vim colour file " " Maintainer: Vy-Shane Sin Fat -" Last Change: 20 November 2009 -" Version: 1.1 +" Version: 1.3 " " This colour file is meant for GUI use. " @@ -16,47 +15,46 @@ endif let g:colors_name="vylight" -hi Normal guifg=#1a1a1a guibg=white +hi Normal guifg=#111111 guibg=white hi Title guifg=black guibg=white -hi Cursor guibg=#111111 -hi LineNr guifg=#aaaaaa guibg=#f8f8f8 -hi Visual guibg=#bbddff -hi NonText guifg=#cccccc guibg=#fafafa +hi Cursor guibg=#FF7311 +hi LineNr guifg=#bebebe guibg=#f8f8f8 +hi Visual guibg=#bbddff +hi NonText guifg=#fafafa guibg=#fafafa hi StatusLine guifg=#222222 guibg=#eeeeee gui=none -hi StatusLineNC guifg=#666666 guibg=#eeeeee gui=none +hi StatusLineNC guifg=#888888 guibg=#eeeeee gui=none hi VertSplit guifg=#eeeeee guibg=#eeeeee gui=none -hi ModeMsg guifg=#007050 guibg=#eeeeee gui=none -hi ErrorMsg guifg=#f03050 guibg=#eeeeee gui=none +hi ModeMsg guifg=black guibg=#bbddff gui=none +hi ErrorMsg guifg=black guibg=#ffbbbb gui=none hi Error guifg=#bb3355 guibg=white gui=none " Vim 7.x specific if version >= 700 - hi CursorLine guibg=#eeeeee gui=none - hi ColorColumn guibg=#efefef gui=none - hi MatchParen guibg=#ccffdd gui=none + hi MatchParen guibg=#ccffdd gui=none hi Pmenu guifg=#60656f guibg=#f0f5ff gui=none hi PmenuSel guifg=white guibg=#3585ef gui=bold hi PmenuSbar guifg=#d0d5dd guibg=#e0e5ee gui=bold hi PmenuThumb guifg=#e0e5ee guibg=#c0c5dd gui=bold - hi Search guibg=#fcfcaa gui=none - hi IncSearch guibg=#ffff33 gui=bold + hi Search guibg=#fcfcaa gui=none + hi IncSearch guibg=#ffff33 gui=bold + hi CursorLine guibg=#f1faff + hi ColorColumn guibg=#fafafa endif " Syntax highlighting -hi Comment guifg=#668866 gui=none -"hi Todo guifg=#225522 guibg=white gui=italic +hi Comment guifg=#777777 gui=none hi Todo guifg=#446644 guibg=#ddeecc gui=italic hi Operator guifg=#1a1a1a gui=none hi Identifier guifg=#1a1a1a gui=none -hi Statement guifg=#0050b0 gui=none +hi Statement guifg=#1a1a1a gui=none hi Type guifg=#0050b0 gui=none hi Constant guifg=#204070 gui=none -hi Conditional guifg=#006040 gui=none +hi Conditional guifg=#006633 gui=none hi Delimiter guifg=#1a1a1a gui=none -hi PreProc guifg=#007050 gui=none -hi Special guifg=#a05050 gui=none +hi PreProc guifg=#006633 gui=none +hi Special guifg=#006633 gui=none hi Keyword guifg=#007050 gui=none hi link Function Normal @@ -68,7 +66,7 @@ hi link Float Number hi link Repeat Conditional hi link Label Statement hi link Exception Statement -hi link Include PreProc +hi link Include Normal hi link Define PreProc hi link Macro PreProc hi link PreCondit PreProc diff --git a/doc/mark.txt b/doc/mark.txt index c301ad8..a54c3e8 100644 --- a/doc/mark.txt +++ b/doc/mark.txt @@ -40,23 +40,35 @@ RELATED WORKS * - http://vim.wikia.com/wiki/Highlight_multiple_words offers control over the color used by mapping the 1-9 keys on the numeric keypad, persistence, and highlights only a single window. +- highlight.vim (vimscript #1599) highlights lines or patterns of interest in + different colors, using mappings that start with CTRL-H and work on cword. ============================================================================== USAGE *mark-usage* HIGHLIGHTING *mark-highlighting* *m* *v_m* -m Mark or unmark the word under the cursor, similar to - the |star| command. +m Mark the word under the cursor, similar to the |star| + command. The next free highlight group is used. + If already on a mark: Clear the mark, like + |n|. {Visual}m Mark or unmark the visual selection. *r* *v_r* -r Manually input a regular expression to highlight. +r Manually input a regular expression to mark. {Visual}r (Based on the visual selection.) + In accordance with the built-in |star| command, all these mappings use 'ignorecase', but not 'smartcase'. *n* -n Clear the mark under the cursor / all marks. +n Clear the mark under the cursor. + If not on a mark: Clear all marks. + + Note: Marks that span multiple lines are not detected, + so the use of n on such a mark will + unintentionally remove all marks! Use + {Visual}r or :Mark {pattern} to clear + multi-line marks. *:Mark* :Mark {pattern} Mark or unmark {pattern}. For implementation reasons, {pattern} cannot use the @@ -119,13 +131,14 @@ You may define your own colors or more than the default 6 highlightings in your vimrc file (or anywhere before this plugin is sourced), in the following form (where N = 1..): > highlight MarkWordN ctermbg=Cyan ctermfg=Black guibg=#8CCBEA guifg=Black -< +Higher numbers always take precedence and are displayed above lower ones. + The search type highlighting (in the search message) can be changed via: > highlight link SearchSpecialSearchType MoreMsg -< +< *g:mwHistAdd* By default, any marked words are also added to the search (/) and input (@) history; if you don't want that, remove the corresponding symbols from: > - let g:mwHistAdd = "/@" + let g:mwHistAdd = '/@' < You can use different mappings by mapping to the Mark... mappings before this plugin is sourced. To remove the default overriding of * and #, use: > @@ -164,6 +177,32 @@ http://vim.wikia.com/wiki/Highlight_multiple_words: ============================================================================== HISTORY *mark-history* +2.4.4 18-Apr-2011 +- BUG: Include trailing newline character in check for current mark, so that a + mark that matches the entire line (e.g. created by Vm) can be + cleared via n. Thanks to ping for reporting this. +- FIX: On overlapping marks, mark#CurrentMark() returned the lowest, not the + highest visible mark. So on overlapping marks, the one that was not visible + at the cursor position was removed; very confusing! Use reverse iteration + order. +- FIX: To avoid an arbitrary ordering of highlightings when the highlighting + group names roll over, and to avoid order inconsistencies across different + windows and tabs, we assign a different priority based on the highlighting + group. + +2.4.3 16-Apr-2011 +- Avoid losing the mark highlightings on :syn on or :colorscheme commands. + Thanks to Zhou YiChao for alerting me to this issue and suggesting a fix. +- Made the script more robust when somehow no highlightings have been defined + or when the window-local reckoning of match IDs got lost. I had very + occasionally encountered such script errors in the past. +- Made global housekeeping variables script-local, only g:mwHistAdd is used + for configuration. + +2.4.2 14-Jan-2011 (unreleased) +- FIX: Capturing the visual selection could still clobber the blockwise yank + mode of the unnamed register. + 2.4.1 13-Jan-2011 - FIX: Using a named register for capturing the visual selection on {Visual}m and {Visual}r clobbered the unnamed register. Now diff --git a/doc/tags b/doc/tags index 21abdfc..2237788 100644 --- a/doc/tags +++ b/doc/tags @@ -365,6 +365,7 @@ g:loremipsum_files loremipsum.txt /*g:loremipsum_files* g:loremipsum_marker loremipsum.txt /*g:loremipsum_marker* g:loremipsum_paragraph_template loremipsum.txt /*g:loremipsum_paragraph_template* g:loremipsum_words loremipsum.txt /*g:loremipsum_words* +g:mwHistAdd mark.txt /*g:mwHistAdd* g:snippets_dir snipMate.txt /*g:snippets_dir* g:snips_author snipMate.txt /*g:snips_author* g:tagbar_autoclose tagbar.txt /*g:tagbar_autoclose* diff --git a/plugin/mark.vim b/plugin/mark.vim index 4f7fa9b..7a6378f 100644 --- a/plugin/mark.vim +++ b/plugin/mark.vim @@ -2,7 +2,7 @@ " Description: Highlight several words in different colors simultaneously. " " Copyright: (C) 2005-2008 by Yuheng Xie -" (C) 2008-2009 by Ingo Karkat +" (C) 2008-2011 by Ingo Karkat " The VIM LICENSE applies to this script; see ':help copyright'. " " Maintainer: Ingo Karkat @@ -13,12 +13,16 @@ " - Requires Vim 7.1 with "matchadd()", or Vim 7.2 or higher. " - mark.vim autoload script. " -" Version: 2.3.2 +" Version: 2.4.3 " Changes: +" 15-Apr-2011, Ingo Karkat +" - Avoid losing the mark highlightings on :syn on or :colorscheme commands. +" Thanks to Zhou YiChao for alerting me to this issue and suggesting a fix. +" " 17-Nov-2009, Ingo Karkat -" - Replaced the (overly) generic mark#GetVisualSelectionEscaped() with -" mark#GetVisualSelectionAsRegexp() and -" mark#GetVisualSelectionAsLiteralPattern(). +" - Replaced the (overly) generic mark#GetVisualSelectionEscaped() with +" mark#GetVisualSelectionAsRegexp() and +" mark#GetVisualSelectionAsLiteralPattern(). " " 04-Jul-2009, Ingo Karkat " - A [count] before any mapping either caused "No range allowed" error or just @@ -133,14 +137,24 @@ if exists('g:loaded_mark') || (v:version == 701 && ! exists('*matchadd')) || (v: endif let g:loaded_mark = 1 +"- configuration -------------------------------------------------------------- +if !exists('g:mwHistAdd') + let g:mwHistAdd = '/@' +endif + + "- default highlightings ------------------------------------------------------ -" You may define your own colors in your vimrc file, in the form as below: -highlight def MarkWord1 ctermbg=Cyan ctermfg=Black guibg=#8CCBEA guifg=Black -highlight def MarkWord2 ctermbg=Green ctermfg=Black guibg=#A4E57E guifg=Black -highlight def MarkWord3 ctermbg=Yellow ctermfg=Black guibg=#FFDB72 guifg=Black -highlight def MarkWord4 ctermbg=Red ctermfg=Black guibg=#FF7272 guifg=Black -highlight def MarkWord5 ctermbg=Magenta ctermfg=Black guibg=#FFB3FF guifg=Black -highlight def MarkWord6 ctermbg=Blue ctermfg=Black guibg=#9999FF guifg=Black +function! s:DefaultHighlightings() + " You may define your own colors in your vimrc file, in the form as below: + highlight def MarkWord1 ctermbg=Cyan ctermfg=Black guibg=#8CCBEA guifg=Black + highlight def MarkWord2 ctermbg=Green ctermfg=Black guibg=#A4E57E guifg=Black + highlight def MarkWord3 ctermbg=Yellow ctermfg=Black guibg=#FFDB72 guifg=Black + highlight def MarkWord4 ctermbg=Red ctermfg=Black guibg=#FF7272 guifg=Black + highlight def MarkWord5 ctermbg=Magenta ctermfg=Black guibg=#FFB3FF guifg=Black + highlight def MarkWord6 ctermbg=Blue ctermfg=Black guibg=#9999FF guifg=Black +endfunction +call s:DefaultHighlightings() +autocmd ColorScheme * call DefaultHighlightings() " Default highlighting for the special search type. " You can override this by defining / linking the 'SearchSpecialSearchType' diff --git a/syntax/c.vim b/syntax/c.vim deleted file mode 100644 index 07df36b..0000000 --- a/syntax/c.vim +++ /dev/null @@ -1,368 +0,0 @@ -" Vim syntax file -" Language: C -" Maintainer: Bram Moolenaar -" Last Change: 2008 Mar 19 - -" Quit when a (custom) syntax file was already loaded -if exists("b:current_syntax") - finish -endif - -" A bunch of useful C keywords -syn keyword cStatement goto break return continue asm -syn keyword cLabel case default -syn keyword cConditional if else switch -syn keyword cRepeat while for do - -syn keyword cTodo contained TODO FIXME XXX - -" cCommentGroup allows adding matches for special things in comments -syn cluster cCommentGroup contains=cTodo - -" String and Character constants -" Highlight special characters (those which have a backslash) differently -syn match cSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)" -if !exists("c_no_utf") - syn match cSpecial display contained "\\\(u\x\{4}\|U\x\{8}\)" -endif -if exists("c_no_cformat") - syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell - " cCppString: same as cString, but ends at end of line - syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,@Spell -else - if !exists("c_no_c99") " ISO C99 - syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlLjzt]\|ll\|hh\)\=\([aAbdiuoxXDOUfFeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained - else - syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([bdiuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained - endif - syn match cFormat display "%%" contained - syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell - " cCppString: same as cString, but ends at end of line - syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell -endif - -syn match cCharacter "L\='[^\\]'" -syn match cCharacter "L'[^']*'" contains=cSpecial -if exists("c_gnu") - syn match cSpecialError "L\='\\[^'\"?\\abefnrtv]'" - syn match cSpecialCharacter "L\='\\['\"?\\abefnrtv]'" -else - syn match cSpecialError "L\='\\[^'\"?\\abfnrtv]'" - syn match cSpecialCharacter "L\='\\['\"?\\abfnrtv]'" -endif -syn match cSpecialCharacter display "L\='\\\o\{1,3}'" -syn match cSpecialCharacter display "'\\x\x\{1,2}'" -syn match cSpecialCharacter display "L'\\x\x\+'" - -"when wanted, highlight trailing white space -if exists("c_space_errors") - if !exists("c_no_trail_space_error") - syn match cSpaceError display excludenl "\s\+$" - endif - if !exists("c_no_tab_space_error") - syn match cSpaceError display " \+\t"me=e-1 - endif -endif - -" This should be before cErrInParen to avoid problems with #define ({ xxx }) -if exists("c_curly_error") - syntax match cCurlyError "}" - syntax region cBlock start="{" end="}" contains=ALLBUT,cCurlyError,@cParenGroup,cErrInParen,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell fold -else - syntax region cBlock start="{" end="}" transparent fold -endif - -"catch errors caused by wrong parenthesis and brackets -" also accept <% for {, %> for }, <: for [ and :> for ] (C99) -" But avoid matching <::. -syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom -if exists("c_no_curly_error") - syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell - " cCppParen: same as cParen but ends at end-of-line; used in cDefine - syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell - syn match cParenError display ")" - syn match cErrInParen display contained "^[{}]\|^<%\|^%>" -elseif exists("c_no_bracket_error") - syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell - " cCppParen: same as cParen but ends at end-of-line; used in cDefine - syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell - syn match cParenError display ")" - syn match cErrInParen display contained "[{}]\|<%\|%>" -else - syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell - " cCppParen: same as cParen but ends at end-of-line; used in cDefine - syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell - syn match cParenError display "[\])]" - syn match cErrInParen display contained "[\]{}]\|<%\|%>" - syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' contains=ALLBUT,@cParenGroup,cErrInParen,cCppParen,cCppBracket,cCppString,@Spell - " cCppBracket: same as cParen but ends at end-of-line; used in cDefine - syn region cCppBracket transparent start='\[\|<::\@!' skip='\\$' excludenl end=']\|:>' end='$' contained contains=ALLBUT,@cParenGroup,cErrInParen,cParen,cBracket,cString,@Spell - syn match cErrInBracket display contained "[);{}]\|<%\|%>" -endif - -"integer number, or floating point number without a dot and with "f". -syn case ignore -syn match cNumbers display transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctalError,cOctal -" Same, but without octal error (for comments) -syn match cNumbersCom display contained transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctal -syn match cNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>" -"hex number -syn match cNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>" -" Flag the first zero of an octal number as something special -syn match cOctal display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=cOctalZero -syn match cOctalZero display contained "\<0" -syn match cFloat display contained "\d\+f" -"floating point number, with dot, optional exponent -syn match cFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=" -"floating point number, starting with a dot, optional exponent -syn match cFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" -"floating point number, without dot, with exponent -syn match cFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>" -if !exists("c_no_c99") - "hexadecimal floating point number, optional leading digits, with dot, with exponent - syn match cFloat display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>" - "hexadecimal floating point number, with leading digits, optional dot, with exponent - syn match cFloat display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>" -endif - -" flag an octal number with wrong digits -syn match cOctalError display contained "0\o*[89]\d*" -syn case match - -if exists("c_comment_strings") - " A comment can contain cString, cCharacter and cNumber. - " But a "*/" inside a cString in a cComment DOES end the comment! So we - " need to use a special type of cString: cCommentString, which also ends on - " "*/", and sees a "*" at the start of the line as comment again. - " Unfortunately this doesn't very well work for // type of comments :-( - syntax match cCommentSkip contained "^\s*\*\($\|\s\+\)" - syntax region cCommentString contained start=+L\=\\\@" skip="\\$" end="$" end="//"me=s-1 contains=cComment,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError -syn match cPreCondit display "^\s*\(%:\|#\)\s*\(else\|endif\)\>" -if !exists("c_no_if0") - if !exists("c_no_if0_fold") - syn region cCppOut start="^\s*\(%:\|#\)\s*if\s\+0\+\>" end=".\@=\|$" contains=cCppOut2 fold - else - syn region cCppOut start="^\s*\(%:\|#\)\s*if\s\+0\+\>" end=".\@=\|$" contains=cCppOut2 - endif - syn region cCppOut2 contained start="0" end="^\s*\(%:\|#\)\s*\(endif\>\|else\>\|elif\>\)" contains=cSpaceError,cCppSkip - syn region cCppSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppSkip -endif -syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ -syn match cIncluded display contained "<[^>]*>" -syn match cInclude display "^\s*\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded -"syn match cLineSkip "\\$" -syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cErrInBracket,cUserLabel,cSpecial,cOctalZero,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti -syn region cDefine start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" end="//"me=s-1 keepend contains=ALLBUT,@cPreProcGroup,@Spell -syn region cPreProc start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell - -" Highlight User Labels -syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString -syn region cMulti transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup,@Spell -" Avoid matching foo::bar() in C++ by requiring that the next char is not ':' -syn cluster cLabelGroup contains=cUserLabel -syn match cUserCont display "^\s*\I\i*\s*:$" contains=@cLabelGroup -syn match cUserCont display ";\s*\I\i*\s*:$" contains=@cLabelGroup -syn match cUserCont display "^\s*\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup -syn match cUserCont display ";\s*\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup - -syn match cUserLabel display "\I\i*" contained - -" Avoid recognizing most bitfields as labels -syn match cBitField display "^\s*\I\i*\s*:\s*[1-9]"me=e-1 contains=cType -syn match cBitField display ";\s*\I\i*\s*:\s*[1-9]"me=e-1 contains=cType - -if exists("c_minlines") - let b:c_minlines = c_minlines -else - if !exists("c_no_if0") - let b:c_minlines = 50 " #if 0 constructs can be long - else - let b:c_minlines = 15 " mostly for () constructs - endif -endif -if exists("c_curly_error") - syn sync fromstart -else - exec "syn sync ccomment cComment minlines=" . b:c_minlines -endif - -" Define the default highlighting. -" Only used when an item doesn't have highlighting yet -hi def link cFormat cSpecial -hi def link cCppString cString -hi def link cCommentL cComment -hi def link cCommentStart cComment -hi def link cLabel Label -hi def link cUserLabel Label -hi def link cConditional Conditional -hi def link cRepeat Repeat -hi def link cCharacter Character -hi def link cSpecialCharacter cSpecial -hi def link cNumber Number -hi def link cOctal Number -hi def link cOctalZero PreProc " link this to Error if you want -hi def link cFloat Float -hi def link cOctalError cError -hi def link cParenError cError -hi def link cErrInParen cError -hi def link cErrInBracket cError -hi def link cCommentError cError -hi def link cCommentStartError cError -hi def link cSpaceError cError -hi def link cSpecialError cError -hi def link cCurlyError cError -hi def link cOperator Operator -hi def link cStructure Structure -hi def link cStorageClass StorageClass -hi def link cInclude Include -hi def link cPreProc PreProc -hi def link cDefine Macro -hi def link cIncluded cString -hi def link cError Error -hi def link cStatement Statement -hi def link cPreCondit PreCondit -hi def link cType Type -hi def link cConstant Constant -hi def link cCommentString cString -hi def link cComment2String cString -hi def link cCommentSkip cComment -hi def link cString String -hi def link cComment Comment -hi def link cSpecial SpecialChar -hi def link cTodo Todo -hi def link cCppSkip cCppOut -hi def link cCppOut2 cCppOut -hi def link cCppOut Comment - -let b:current_syntax = "c" - -" vim: ts=8