Skip to content
Browse files

Highlight trailing comment as error

Fixes #19
  • Loading branch information...
1 parent 278be56 commit 64ac3b0a55363151beda60946f8839c1687acd9a @JesseKPhillips committed Oct 5, 2013
Showing with 35 additions and 8 deletions.
  1. +11 −8 syntax/d.vim
  2. +24 −0 tests/comments.d
View
19 syntax/d.vim
@@ -2,7 +2,7 @@
"
" Language: D
" Maintainer: Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
-" Last Change: 2013 May 21
+" Last Change: 2013 October 5
" Version: 0.25
"
" Contributors:
@@ -194,6 +194,9 @@ syn cluster dTokens add=dUserLabel,dLabel
" Comments
"
+syn match dCommentError display "\*/"
+syn match dNestedCommentError display "+/"
+
syn keyword dTodo contained TODO FIXME TEMP REFACTOR REVIEW HACK BUG XXX
syn match dCommentStar contained "^\s*\*[^/]"me=e-1
syn match dCommentStar contained "^\s*\*$"
@@ -203,15 +206,12 @@ if exists("d_comment_strings")
syn region dBlockCommentString contained start=+"+ end=+"+ end=+\*/+me=s-1,he=s-1 contains=dCommentStar,dUnicode,dEscSequence,@Spell
syn region dNestedCommentString contained start=+"+ end=+"+ end="+"me=s-1,he=s-1 contains=dCommentPlus,dUnicode,dEscSequence,@Spell
syn region dLineCommentString contained start=+"+ end=+$\|"+ contains=dUnicode,dEscSequence,@Spell
- syn region dBlockComment start="/\*" end="\*/" contains=dBlockCommentString,dTodo,@Spell fold
- syn region dNestedComment start="/+" end="+/" contains=dNestedComment,dNestedCommentString,dTodo,@Spell fold
- syn match dLineComment "//.*" contains=dLineCommentString,dTodo,@Spell
-else
- syn region dBlockComment start="/\*" end="\*/" contains=dBlockCommentString,dTodo,@Spell fold
- syn region dNestedComment start="/+" end="+/" contains=dNestedComment,dNestedCommentString,dTodo,@Spell fold
- syn match dLineComment "//.*" contains=dLineCommentString,dTodo,@Spell
endif
+syn region dBlockComment start="/\*" end="\*/" contains=dBlockCommentString,dTodo,dCommentStartError,@Spell fold
+syn region dNestedComment start="/+" end="+/" contains=dNestedComment,dNestedCommentString,dTodo,@Spell fold
+syn match dLineComment "//.*" contains=dLineCommentString,dTodo,@Spell
+
hi link dLineCommentString dBlockCommentString
hi link dBlockCommentString dString
hi link dNestedCommentString dString
@@ -370,6 +370,9 @@ hi def link dType Type
hi def link dLineComment Comment
hi def link dBlockComment Comment
hi def link dNestedComment Comment
+hi def link dCommentError Error
+hi def link dNestedCommentError Error
+hi def link dCommentStartError Error
hi def link dExternal Include
hi def link dAnnotation PreProc
hi def link dSharpBang PreProc
View
24 tests/comments.d
@@ -0,0 +1,24 @@
+// This is the highlighting off comments file
+module comments;
+
+/* It shows the different comments
+ * and how they are highlightedt
+ */
+
+import std.stdio;
+
+/++
+ + As we can see it does look to work.
+ +/
+
+void main() {
+ for (i = 0; i < 10; ++i)
+ {
+ writeln(i, "\* This is not a comment \+");
+ }*/ // Error
+ while(true) {
+ }+/ // Error
+
+ /* This is an /* inner comment test */
+ int a;
+}

0 comments on commit 64ac3b0

Please sign in to comment.
Something went wrong with that request. Please try again.