Skip to content

Commit

Permalink
feat(css): arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
bennypowers committed Aug 12, 2024
1 parent 57fddfa commit 52033a9
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
11 changes: 10 additions & 1 deletion lua/splitjoin/languages/css/defaults.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
local Node = require'splitjoin.util.node'

---@return SplitjoinLanguageConfig
return {
return
{
nodes = {

block = {
Expand All @@ -12,5 +13,13 @@ return {
split = Node.split,
},

arguments = {
surround = { '(', ')' },
separator = ',',
trailing_separator = false,
join = Node.join,
split = Node.split,
},

},
}
10 changes: 7 additions & 3 deletions queries/css/splitjoin.scm
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[
(rule_set (block) @_splitjoin)
]
(rule_set
(block) @splitjoin.css.block)

(rule_set
(selectors
(_
(arguments) @splitjoin.css.arguments)))
14 changes: 14 additions & 0 deletions test/css_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 2 additions & 0 deletions test/fixtures/fixture.css
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
7 changes: 5 additions & 2 deletions test/fixtures/fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 52033a9

Please sign in to comment.