Skip to content

Commit

Permalink
CUE documentation + simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
perelo committed Feb 22, 2024
1 parent e6befe1 commit 12d1d12
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 13 deletions.
11 changes: 1 addition & 10 deletions autoload/sj/cue.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
47 changes: 47 additions & 0 deletions doc/splitjoin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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*

Expand Down
3 changes: 0 additions & 3 deletions ftplugin/cue/splitjoin.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 12d1d12

Please sign in to comment.