Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template string highlighting and export default interface highlight #64

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions syntax/basic/cluster.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ syntax cluster typescriptStatement
\ typescriptTry,typescriptExceptions,typescriptDebugger,
\ typescriptExport,typescriptInterfaceKeyword,typescriptEnum,typescriptModule

syntax cluster typescriptPrimitive contains=typescriptString,typescriptTemplate,typescriptRegexpString,typescriptNumber,typescriptBoolean,typescriptNull,typescriptArray
syntax cluster typescriptPrimitive contains=typescriptString,typescriptTaggedTemplate,typescriptTemplate,typescriptRegexpString,typescriptNumber,typescriptBoolean,typescriptNull,typescriptArray

syntax cluster typescriptEventTypes contains=typescriptEventString,typescriptTemplate,typescriptNumber,typescriptBoolean,typescriptNull
syntax cluster typescriptEventTypes contains=typescriptEventString,typescriptTaggedTemplate,typescriptTemplate,typescriptNumber,typescriptBoolean,typescriptNull

" top level expression: no arrow func
" also no func keyword. funcKeyword is contained in statement
Expand Down
2 changes: 1 addition & 1 deletion syntax/basic/keyword.vim
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ syntax keyword typescriptRepeat do while for nextgroup=typescript
syntax keyword typescriptRepeat for nextgroup=typescriptLoopParen,typescriptAsyncFor skipwhite skipempty
syntax keyword typescriptBranch break continue containedin=typescriptBlock
syntax keyword typescriptCase case nextgroup=@typescriptPrimitive skipwhite containedin=typescriptBlock
syntax keyword typescriptDefault default containedin=typescriptBlock nextgroup=@typescriptValue,typescriptClassKeyword skipwhite oneline
syntax keyword typescriptDefault default containedin=typescriptBlock nextgroup=@typescriptValue,typescriptClassKeyword,typescriptInterfaceKeyword skipwhite oneline

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good fix! Thanks!

syntax keyword typescriptStatementKeyword with
syntax keyword typescriptStatementKeyword yield skipwhite nextgroup=@typescriptValue containedin=typescriptBlock
syntax keyword typescriptStatementKeyword return skipwhite contained nextgroup=@typescriptValue containedin=typescriptBlock
Expand Down
2 changes: 2 additions & 0 deletions syntax/basic/literal.vim
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ syntax region typescriptTemplate
\ nextgroup=@typescriptSymbols
\ skipwhite skipempty

syntax match typescriptTaggedTemplate /\<\K\k*\ze`/ nextgroup=typescriptTemplate

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't do this. It will overlap with typescriptIdentifier and make backtracking more often.

It also doesn't handle case like funcCall()``

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I think I'm at the limit of my vim syntax knowledge then so I'm not sure where to put it :-).

So far I'm using it and the funcCall()`` case gets handled tho. Must be handled by the usual typescriptTemplate match.


"Array
syntax region typescriptArray matchgroup=typescriptBraces
\ start=/\[/ end=/]/
Expand Down
12 changes: 12 additions & 0 deletions test/syntax.vader
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,18 @@ Given typescript (template tag string):
Execute:
AssertEqual 'typescriptTemplate', SyntaxAt(1, 16)

Given typescript (template tag string inside object):
var a = { key: test`kddkk` }
Execute:
AssertEqual 'typescriptTaggedTemplate', SyntaxAt(1, 18)
AssertEqual 'typescriptTemplate', SyntaxAt(1, 23)

Given typescript (template tag string as default value):
var a = (a: string = T`my template`) => 1
Execute:
AssertEqual 'typescriptTaggedTemplate', SyntaxAt(1, 22)
AssertEqual 'typescriptTemplate', SyntaxAt(1, 26)

Given typescript (multi line arrow func):
filter((test
) => {
Expand Down