about summary refs log tree commit diff stats
path: root/cpp/vimrc.vim
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-17 23:24:52 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-17 23:24:52 -0700
commit7284d503f67572dab678f68e5635c471a9d53480 (patch)
tree292b611d694da66c1a881ed11662cf9b0ee64610 /cpp/vimrc.vim
parentb3cdcdd44f6b8db053e4814351fbf04fefb7d7cf (diff)
downloadmu-7284d503f67572dab678f68e5635c471a9d53480.tar.gz
1094 - demarcate sections in layers
We have tangled vs regular comments, but they highlight the same. So
we're still at 3 colors for comments. Anything more starts to seem
gratuitous.
Diffstat (limited to 'cpp/vimrc.vim')
-rw-r--r--cpp/vimrc.vim24
1 files changed, 15 insertions, 9 deletions
diff --git a/cpp/vimrc.vim b/cpp/vimrc.vim
index 4f89542e..627bfc8a 100644
--- a/cpp/vimrc.vim
+++ b/cpp/vimrc.vim
@@ -1,23 +1,29 @@
 " Highlighting literate directives in C++ sources.
 function! HighlightTangledFile()
-  set ft=cpp
+  if &ft == ""
+    set ft=cpp
+  endif
   set comments-=://
   set comments-=n://
   set comments+=n://:,n://
+
+  set isk+=-
+
   syntax region tangleDirective start=+:(+ skip=+".*"+ end=+)+
   highlight link tangleDirective Delimiter
   syntax region traceContains start="^+" end="$"
   highlight traceContains ctermfg=darkgreen
   syntax region traceAbsent start="^-" end="$"
   highlight traceAbsent ctermfg=darkred
+  " Our C++ files can have mu code in scenarios, so highlight mu comments like
+  " regular comments.
+  syntax match muComment /#.*$/ | highlight link muComment Comment
+  syntax match muSalientComment /##.*$/ | highlight link muSalientComment SalientComment
+  " Tangled comments only make sense in the sources and are stripped out of
+  " the generated .cc file. They're highlighted same as regular comments.
+  syntax match tangledComment /\/\/:.*/ | highlight link tangledComment Comment
+  syntax match tangledSalientComment /\/\/::.*/ | highlight link tangledSalientComment SalientComment
 endfunction
 call HighlightTangledFile()
+autocmd BufRead,BufNewFile *.mu set ft=mu
 autocmd BufRead,BufNewFile 0* call HighlightTangledFile()
-
-set isk+=-
-
-" scenarios inside c++ files
-syntax match muComment /#.*$/ | highlight link muComment Comment
-syntax keyword muControl reply jump jump-if jump-unless loop loop-if loop-unless break-if break-unless | highlight link muControl Identifier
-syntax match muAssign "<-" | highlight link muAssign SpecialChar
-syntax match muAssign "\<raw\>"