Skip to content

Commit

Permalink
Fix nested js in jsFuncCall region
Browse files Browse the repository at this point in the history
Previously in a styled `jsFuncCall` region (e.g. `styled(<here>)`), only
keyword items (e.g. "\k") was highlighted, this thus was excluding
certain js constructs like property access syntax and function calls.

This commit changes this to basically ignore the specifics inside of the
insides of the `jsFuncCall` and to transparently highlight this. It also
adds styles to display the issue as was proposed in #44.

This should fix #44.
  • Loading branch information
fleischie committed Jul 21, 2018
1 parent 0ad81d8 commit 277402e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion after/syntax/javascript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ syn match cssError contained "{@<>"
syn match jsTaggedTemplate extend
\ "\<css\>\|\<keyframes\>\|\<injectGlobal\>\|\<fontFace\>"
\ nextgroup=styledDefinition
syn match jsFuncCall "\<styled\>\s*(\k\+)"
syn match jsFuncCall "\<styled\>\s*(.\+)" transparent
\ nextgroup=styledDefinition
syn match jsFuncCall "\<styled\>\s*(\%('\k\+'\|\"\k\+\"\|`\k\+`\))"
\ contains=styledTagNameString
Expand Down
35 changes: 35 additions & 0 deletions examples/issue-44.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import styled from 'styled-components';

const Schedule = styled.div`
display: none;
`;

Schedule.Part = styled.div`
align-items: center;
display: flex;
`;

const Something = styled(Link)`
align-items: center;
display: none;
`;

function test() {
return styled.div;
}

Schedule.CourseTimes = styled(test())`
align-items: flex-start;
img {
margin-top: 0.3rem;
}
`;

Schedule.CourseTimes = styled(Schedule.Part)`
align-items: flex-start;
img {
margin-top: 0.3rem;
}
`;

0 comments on commit 277402e

Please sign in to comment.