File tree Expand file tree Collapse file tree 4 files changed +33
-9
lines changed
emmylua_ls/src/handlers/semantic_token Expand file tree Collapse file tree 4 files changed +33
-9
lines changed Original file line number Diff line number Diff line change @@ -184,7 +184,10 @@ fn build_tokens_semantic_token(
184184 SemanticTokenModifier :: DOCUMENTATION ,
185185 ) ;
186186 }
187- LuaTokenKind :: TkDocDetail | LuaTokenKind :: TkNormalStart => {
187+ LuaTokenKind :: TkNormalStart | LuaTokenKind :: TKNonStdComment => {
188+ builder. push ( token, SemanticTokenType :: COMMENT ) ;
189+ }
190+ LuaTokenKind :: TkDocDetail => {
188191 // We're rendering a description. If description parsing is enabled,
189192 // this token will be handled by the corresponding description parser.
190193 let rendering_description = token
Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ pub enum LuaTokenKind {
100100 TKDocTriviaStart , // --------------
101101 TkDocTrivia , // other can not parsed
102102 TkLongCommentEnd , // ]] or ]===]
103+ TKNonStdComment , // // comment, non-standard lua comment
103104
104105 // tag
105106 TkTagClass , // class
Original file line number Diff line number Diff line change @@ -119,6 +119,15 @@ impl LuaDocLexer<'_> {
119119 }
120120 }
121121 }
122+ '/' if reader. is_start_of_line ( ) => {
123+ let count = reader. consume_char_n_times ( '/' , 3 ) ;
124+ if count >= 2 {
125+ // "//" is a non-standard lua comment
126+ return LuaTokenKind :: TkNormalStart ;
127+ }
128+
129+ LuaTokenKind :: TKNonStdComment
130+ }
122131 _ => {
123132 reader. eat_while ( |_| true ) ;
124133 LuaTokenKind :: TkDocTrivia
@@ -537,6 +546,15 @@ impl LuaDocLexer<'_> {
537546 }
538547 }
539548 }
549+ '/' if reader. is_start_of_line ( ) => {
550+ let count = reader. consume_char_n_times ( '/' , 3 ) ;
551+ if count >= 2 {
552+ // "//" is a non-standard lua comment
553+ return LuaTokenKind :: TkNormalStart ;
554+ }
555+
556+ LuaTokenKind :: TKNonStdComment
557+ }
540558 _ => {
541559 reader. eat_while ( |_| true ) ;
542560 LuaTokenKind :: TkDocDetail
Original file line number Diff line number Diff line change @@ -300,6 +300,7 @@ impl<'a> LuaLexer<'a> {
300300 _ if self . support_non_std_symbol ( LuaNonStdSymbol :: DoubleSlash ) => {
301301 // "//" is a short comment
302302 self . reader . bump ( ) ;
303+ self . reader . eat_while ( |ch| ch != '\n' && ch != '\r' ) ;
303304 return LuaTokenKind :: TkShortComment ;
304305 }
305306 _ => {
@@ -382,10 +383,6 @@ impl<'a> LuaLexer<'a> {
382383 LuaTokenKind :: TkNot
383384 }
384385 '&' => {
385- if !self . lexer_config . support_integer_operation ( ) {
386- self . error ( || t ! ( "bitwise operation is not supported" ) ) ;
387- }
388-
389386 self . reader . bump ( ) ;
390387 if self . reader . current_char ( ) == '&'
391388 && self . support_non_std_symbol ( LuaNonStdSymbol :: DoubleAmp )
@@ -399,26 +396,31 @@ impl<'a> LuaLexer<'a> {
399396 self . reader . bump ( ) ;
400397 return LuaTokenKind :: TkAmpAssign ;
401398 }
402- LuaTokenKind :: TkBitAnd
403- }
404- '|' => {
399+
405400 if !self . lexer_config . support_integer_operation ( ) {
406401 self . error ( || t ! ( "bitwise operation is not supported" ) ) ;
407402 }
408-
403+ LuaTokenKind :: TkBitAnd
404+ }
405+ '|' => {
409406 self . reader . bump ( ) ;
410407 if self . reader . current_char ( ) == '|'
411408 && self . support_non_std_symbol ( LuaNonStdSymbol :: DoublePipe )
412409 {
413410 self . reader . bump ( ) ;
414411 return LuaTokenKind :: TkOr ;
415412 }
413+
416414 if self . reader . current_char ( ) == '='
417415 && self . support_non_std_symbol ( LuaNonStdSymbol :: PipeAssign )
418416 {
419417 self . reader . bump ( ) ;
420418 return LuaTokenKind :: TkPipeAssign ;
421419 }
420+
421+ if !self . lexer_config . support_integer_operation ( ) {
422+ self . error ( || t ! ( "bitwise operation is not supported" ) ) ;
423+ }
422424 LuaTokenKind :: TkBitOr
423425 }
424426 '(' => {
You can’t perform that action at this time.
0 commit comments