From 52033a9e0e5120fbbaeffe6b3676d388243a55b5 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Mon, 12 Aug 2024 14:08:15 +0300 Subject: [PATCH] feat(css): arguments --- lua/splitjoin/languages/css/defaults.lua | 11 ++++++++++- queries/css/splitjoin.scm | 10 +++++++--- test/css_spec.lua | 14 ++++++++++++++ test/fixtures/fixture.css | 2 ++ test/fixtures/fixture.js | 7 +++++-- 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/lua/splitjoin/languages/css/defaults.lua b/lua/splitjoin/languages/css/defaults.lua index 4084e16..ada1aff 100644 --- a/lua/splitjoin/languages/css/defaults.lua +++ b/lua/splitjoin/languages/css/defaults.lua @@ -1,7 +1,8 @@ local Node = require'splitjoin.util.node' ---@return SplitjoinLanguageConfig -return { +return + { nodes = { block = { @@ -12,5 +13,13 @@ return { split = Node.split, }, + arguments = { + surround = { '(', ')' }, + separator = ',', + trailing_separator = false, + join = Node.join, + split = Node.split, + }, + }, } diff --git a/queries/css/splitjoin.scm b/queries/css/splitjoin.scm index 5560944..2efc6c3 100644 --- a/queries/css/splitjoin.scm +++ b/queries/css/splitjoin.scm @@ -1,3 +1,7 @@ -[ - (rule_set (block) @_splitjoin) -] +(rule_set + (block) @splitjoin.css.block) + +(rule_set + (selectors + (_ + (arguments) @splitjoin.css.arguments))) diff --git a/test/css_spec.lua b/test/css_spec.lua index 4ad0187..50a7a0f 100644 --- a/test/css_spec.lua +++ b/test/css_spec.lua @@ -45,6 +45,20 @@ describe(lang, function() ';' ) + H.make_suite(lang, 'arguments', + d[[ + :is(h1, h2, h3) { color: blue } + ]], + d[[ + :is( + h1, + h2, + h3 + ) { color: blue } + ]], + '1' + ) + end) end) diff --git a/test/fixtures/fixture.css b/test/fixtures/fixture.css index 7d34c3b..30f69c3 100644 --- a/test/fixtures/fixture.css +++ b/test/fixtures/fixture.css @@ -3,3 +3,5 @@ a { color: blue } a { color: blue; font: 12px "Fira Code", monospace } a { content: ';' } + + :is(h1, h2, h3, h4, h5, h6) { color: grey; } diff --git a/test/fixtures/fixture.js b/test/fixtures/fixture.js index 698f27a..8e30850 100644 --- a/test/fixtures/fixture.js +++ b/test/fixtures/fixture.js @@ -24,8 +24,11 @@ function destruct({ a, b, c }, d) { return { a, b, c, d }; } destruct = ({ a, b, c }, d) => 0; - /** jsdoc */ - const jsdoc = (thing) => thing +/** jsdoc */ +const jsdoc = (thing) => thing + + /** indented jsdoc */ + const ijsdoc = (thing) => thing /** * multiline