improved formatting for destructure

This commit is contained in:
XeroOl 2024-03-01 17:28:24 -06:00
parent cab3bbc49d
commit 0dd9c0ff65
2 changed files with 14 additions and 7 deletions

View File

@ -14,9 +14,14 @@ user code. Fennel-ls doesn't support user-code formatting as of now."
(.. (code-block (.. "("
(tostring special)
(if name (.. " " (tostring name)) "")
(.. " " (view args
{:one-line? true
:prefer-colon? true}))
(.. " "
(: (view args
{:empty-as-sequence? true
:one-line? true
:prefer-colon? true})
:gsub ":([%w?_-]+) ([%w?]+)([ }])"
#(if (= $1 $2)
(.. ": " $2 $3))))
" ...)"))
(if docstring (.. "\n" docstring) "")))

View File

@ -80,10 +80,12 @@ new message handler `msgh`.")
(check "(λ foo| [x ...]
\"not a docstring, this gets returned\")"
"```fnl\n(fn foo [x ...] ...)\n```")
;; TODO cleanup signatures
; (check "(λ foo| [{: start : end} ...]
; :body)"
; "```fnl\n(fn foo [{: start : end} ...] ...)\n```")
(check "(λ foo| [{: start : end}]
:body)"
"```fnl\n(fn foo [{: end : start}] ...)\n```")
(check "(λ foo| [{:list [a b c] :table {: d : e : f}}]
:body)"
"```fnl\n(fn foo [{:list [a b c] :table {: d : e : f}}] ...)\n```")
nil)
(fn test-multisym []