Browse files

C highlighting. Closes #4

  • Loading branch information...
1 parent 6cd279c commit 3e2f29039fc025488855039c3e65db836472dbd9 @rking committed with rking@sharpsaw.org Nov 27, 2012
Showing with 103 additions and 17 deletions.
  1. +40 −17 colors/detailed.vim
  2. +63 −0 test/example.c
View
57 colors/detailed.vim
@@ -65,8 +65,9 @@ let ruby_operators = 1
" If you don't have this, rails.vim will zap the matchers when it resets
" syntax for its own additions:
au Syntax * call s:fatpacked_rainbow_parens()
+au Syntax * call s:detailed_syntax_addtions()
-au Syntax ruby call s:detailed_syntax_addtions()
+au Syntax ruby call s:ruby_syntax_addtions()
" Show detailed syntax stack
nmap <Leader>dets :call <SID>SynStack()<CR>
@@ -386,9 +387,11 @@ let s:c = {
\'purple99 (TODO: use this)': 79,
\'purple125': 125,
\'purple126': 126,
- \'purple127 (TODO: use this)': 127,
+ \'purple127': 127,
\'purple129 (TODO: use this)': 129,
\'purple131': 131,
+ \'purple132': 132,
+ \'purple134': 134,
\'purple141 (TODO: use this)': 141,
\'purple161 (TODO: use this)': 161,
\'purple201': 201,
@@ -583,7 +586,7 @@ fun! s:detailed_colors()
call s:fg('detailedInstanceVariable', 'blue75')
- call s:fgbg('rubyString', 'red160', 'gray233')
+ call s:fgbg('detailedString', 'red160', 'gray233')
call s:fg('detailedStringDelimiter', 'blue33')
call s:fg('detailedInterpolationDelimiter', 'gray244')
@@ -602,8 +605,8 @@ fun! s:detailed_colors()
call s:fg('detailedASCIICode', 'green71')
call s:fg('detailedPseudoVariable', 'purple125')
- call s:fg('detailedInteger', 'red124')
- call s:fg('detailedFloat', 'red160')
+ call s:fg('detailedInteger', 'purple134')
+ call s:fg('detailedFloat', 'purple132')
call s:fg('detailedBlockArgument', 'blue87')
call s:fg('detailedSymbol', 'lavender104')
@@ -660,6 +663,20 @@ fun! s:detailed_colors()
call s:fg('detailedInitialize', 'green84')
call s:bold_fg('detailedEncodingDirective', 'green22')
+ hi link detailedExits Exception
+
+ hi link cRepeat detailedRepeat
+ hi link cUserLabel detailedRepeat
+ hi link cInclude detailedModule
+ hi link cCppString detailedString
+ hi link cStatement detailedControl " return goto asm continue break
+ hi link cConstant detailedConstant
+ hi link cNumber detailedInteger
+ " Since the C details came after Ruby, the names could be redone a bit:
+ hi link cIncluded detailedString
+ hi link cStructure detailedClass
+ hi link cStorageClass detailedClass
+ hi link cOperator detailedDefine
hi link rubyConditional Conditional
hi link rubyExceptional rubyConditional " No-show.
@@ -674,7 +691,6 @@ fun! s:detailed_colors()
hi link rubyEncodingDirective detailedEncodingDirective
hi link rubyInitialize detailedInitialize
hi link rubyRailsARAssociationMethod detailedRailsARAssociationMethod
- hi link rubyExits Exception
hi link rubySpaceError BadWhitespace
hi link rubyData detailedData
hi link rubyDataDirective detailedDataDirective
@@ -719,6 +735,7 @@ fun! s:detailed_colors()
hi link rubyRegexpComment Comment
hi link rubyRegexpSpecial detailedRegexpSpecial
hi link rubyInterpolationDelimiter detailedInterpolationDelimiter
+ hi link rubyString detailedString
hi link rubyStringDelimiter detailedStringDelimiter
hi link rubyInstanceVariable detailedInstanceVariable
hi link rubyFunction detailedFunction
@@ -754,31 +771,37 @@ endfun
fun! s:detailed_syntax_addtions()
call s:detailed_colors()
+ " Steal this back from the too-generic 'rubyControl':
+ syn match detailedExits "\<\%(exit!\|\%(abort\|at_exit\|exit\|fork\|trap\)\>[?!]\@!\)"
+
+ " TODO - somehow make the detail{Todo,Fixme,Xxx} work for non-ruby langs.
+ " E.g., shTodo overrides them, so it will need something like:
+ " syn match rubyComment "#.*" contains=rubySharpBang,rubySpaceError,
+ " \rubyFirstAndSecondCommentLine,detailedTodo,detailedFixme,detailedXxx,@Spell
+ syn keyword detailedTodo TODO contained
+ syn keyword detailedFixme FIXME contained
+ syn keyword detailedXxx XXX contained
+endfun
+call s:detailed_syntax_addtions()
+
+fun! s:ruby_syntax_addtions()
" The default syntax/ruby.vim gets this way wrong (only does 2 chars and is
" transparent):
syn match rubyBlockArgument "&[_[:lower:]][_[:alnum:]]*" contains=NONE display
- " Steal this back from the too-generic 'rubyControl':
- syn match rubyExits "\<\%(exit!\|\%(abort\|at_exit\|exit\|fork\|trap\)\>[?!]\@!\)"
-
" Bonus!
syn match rubyInitialize '\<initialize\>' contained containedin=rubyMethodDeclaration
syn match rubyEncodingDirective "\cencoding: *utf-8" contained
" TODO - make this more elegant.
syn match rubyFirstAndSecondCommentLine '\%^#.*'
- \ contains=rubyEncodingDirective contained
+ \ contains=rubyEncodingDirective contained
syn match rubyFirstAndSecondCommentLine '\%^#.*\n#.*'
- \ contains=rubyEncodingDirective contained
+ \ contains=rubyEncodingDirective contained
- syn keyword detailedTodo TODO contained
- syn keyword detailedFixme FIXME contained
- syn keyword detailedXxx XXX contained
syn match rubyComment "#.*" contains=rubySharpBang,rubySpaceError,
- \rubyFirstAndSecondCommentLine,detailedTodo,detailedFixme,detailedXxx,@Spell
- " TODO - somehow make the detail{Todo,Fixme,Xxx} work for non-ruby langs.
+ \rubyFirstAndSecondCommentLine,detailedTodo,detailedFixme,detailedXxx,@Spell
endfun
-call s:detailed_syntax_addtions()
" Rainbow-Parens Improved {{{
" Inlined from v2.3 of http://www.vim.org/scripts/script.php?script_id=4176
View
63 test/example.c
@@ -0,0 +1,63 @@
+void launch_job (job *j, int foreground)
+{
+ process *p;
+ pid_t pid;
+ int mypipe[2], infile, outfile;
+
+ infile = j->stdin;
+ for (p = j->first_process; p; p = p->next)
+ {
+ /* Set up pipes, if necessary. */
+ if (p->next)
+ {
+ if (pipe (mypipe) < 0)
+ {
+ perror ("pipe");
+ exit (1);
+ }
+ outfile = mypipe[1];
+ }
+ else
+ outfile = j->stdout;
+
+ /* Fork the child processes. */
+ pid = fork ();
+ if (pid == 0)
+ /* This is the child process. */
+ launch_process (p, j->pgid, infile,
+ outfile, j->stderr, foreground);
+ else if (pid < 0)
+ {
+ /* The fork failed. */
+ perror ("fork");
+ exit (1);
+ }
+ else
+ {
+ /* This is the parent process. */
+ p->pid = pid;
+ if (shell_is_interactive)
+ {
+ if (!j->pgid)
+ j->pgid = pid;
+ setpgid (pid, j->pgid);
+ }
+ }
+
+ /* Clean up after pipes. */
+ if (infile != j->stdin)
+ close (infile);
+ if (outfile != j->stdout)
+ close (outfile);
+ infile = mypipe[0];
+ }
+
+ format_job_info (j, "launched");
+
+ if (!shell_is_interactive)
+ wait_for_job (j);
+ else if (foreground)
+ put_job_in_foreground (j, 0);
+ else
+ put_job_in_background (j, 0);
+}

0 comments on commit 3e2f290

Please sign in to comment.