From 12d1d124b71c5198d204a8826d11e494d7423d8b Mon Sep 17 00:00:00 2001 From: Eloi Perdereau Date: Fri, 23 Feb 2024 00:12:30 +0100 Subject: [PATCH] CUE documentation + simplifications --- autoload/sj/cue.vim | 11 +-------- doc/splitjoin.txt | 47 ++++++++++++++++++++++++++++++++++++++ ftplugin/cue/splitjoin.vim | 3 --- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/autoload/sj/cue.vim b/autoload/sj/cue.vim index dbad13c9..a2475c5b 100644 --- a/autoload/sj/cue.vim +++ b/autoload/sj/cue.vim @@ -90,19 +90,10 @@ function! s:SplitList(delimiter, cursor_position) return 0 endif - if sj#settings#Read('trailing_comma') - let body = start."\n".join(items, ",\n").",\n".end - else - let body = start."\n".join(items, ",\n")."\n".end - endif + let body = start."\n".join(items, ",\n")."\n".end call sj#ReplaceMotion('Va'.start, body) - " built-in js indenting doesn't indent this properly - for l in range(lineno + 1, lineno + len(items)) - call sj#SetIndent(l, indent + &sw) - endfor - " closing bracket let end_line = lineno + len(items) + 1 call sj#SetIndent(end_line, indent) diff --git a/doc/splitjoin.txt b/doc/splitjoin.txt index b58a33ae..88404530 100644 --- a/doc/splitjoin.txt +++ b/doc/splitjoin.txt @@ -10,6 +10,7 @@ CONTENTS *splitjoin* *splitjoin-content Clojure................................: |splitjoin-clojure| Coffeescript...........................: |splitjoin-coffee| CSS....................................: |splitjoin-css| + CUE....................................: |splitjoin-cue| Elixir.................................: |splitjoin-elixir| Elm....................................: |splitjoin-elm| Eruby..................................: |splitjoin-eruby| @@ -356,6 +357,52 @@ Multiline selectors ~ } < +============================================================================== +CUE *splitjoin-cue* + +CUE Structs are JSON objects but with a cleaner syntax. Lists and Function +arguments behave like JSON's. +See |splitjoin-json|. + +Structs ~ + +Structs are first class, so the cursor can precede the first curly brace. +> + a: foo: { x: bar: baz: bool, y: bar: baz: int, z: bar: baz: string } + + a: foo: { + x: bar: baz: bool + y: bar: baz: int + z: bar: baz: string + } +< +Lists ~ + +The same applies to lists. +> + foo: [ 'x:y:z', "\xFFFF0000", a.foo.y ] + + foo: [ + 'x:y:z', + "\xFFFF0000", + a.foo.y + ] +< +Function Arguments ~ + +Function splitting requires the cursor to be positioned inside the +parenthesis, preferably near the closing one. +> + bar: m.Baz(foo[2].bar.baz, 42, true) + + bar: m.Baz( + foo[2].bar.baz, + 42, + true + ) +< + + ============================================================================== ELIXIR *splitjoin-elixir* diff --git a/ftplugin/cue/splitjoin.vim b/ftplugin/cue/splitjoin.vim index 2176f66b..7b635596 100644 --- a/ftplugin/cue/splitjoin.vim +++ b/ftplugin/cue/splitjoin.vim @@ -13,6 +13,3 @@ if !exists('b:splitjoin_join_callbacks') \ 'sj#cue#JoinArgs', \ ] endif - -" in CUE, trailing comma means something else -let b:splitjoin_trailing_comma = 0