From 058e05031579b4a46afb07b9d18704b806878ae6 Mon Sep 17 00:00:00 2001 From: Steve Occhipinti Date: Sun, 25 Jul 2021 15:35:17 +1000 Subject: [PATCH] Add a basic styled-components injection I've never written this sort of code before but I was able to get this to work with the help of copy and paste and using nvim-treesitter/playground. I had a hard time trying to understand how to indent this style of code so I let vim do it with `=` and 2 spaces seems to match other files I looked at. This works for a basic example, like this: ``` const Layout = styled.div` position: absolute; inset: 0; display: grid; grid-template-rows: 100px 1fr 3rem; ` ``` --- queries/ecma/injections.scm | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/queries/ecma/injections.scm b/queries/ecma/injections.scm index 937ef08d8..52d0d242d 100644 --- a/queries/ecma/injections.scm +++ b/queries/ecma/injections.scm @@ -2,20 +2,25 @@ (comment) @comment (call_expression - function: ((identifier) @language) - arguments: ((template_string) @content - (#offset! @content 0 1 0 -1))) + function: ((identifier) @language) + arguments: ((template_string) @content + (#offset! @content 0 1 0 -1))) (call_expression - function: ((identifier) @_name - (#eq? @_name "gql")) - arguments: ((template_string) @graphql - (#offset! @graphql 0 1 0 -1))) + function: ((identifier) @_name + (#eq? @_name "gql")) + arguments: ((template_string) @graphql + (#offset! @graphql 0 1 0 -1))) (call_expression - function: ((identifier) @_name - (#eq? @_name "hbs")) - arguments: ((template_string) @glimmer - (#offset! @glimmer 0 1 0 -1))) + function: ((identifier) @_name + (#eq? @_name "hbs")) + arguments: ((template_string) @glimmer + (#offset! @glimmer 0 1 0 -1))) + +(call_expression + function: (member_expression + object: (identifier) @_name (#eq? @_name "styled")) + arguments: ((template_string) @css (#offset! @css 0 1 0 -1))) (regex_pattern) @regex