changed directories and addet fzf to zsh

This commit is contained in:
piecka 2024-12-11 15:02:36 +01:00
parent 0acd581d40
commit cb928bb0b4
428 changed files with 20659 additions and 15 deletions

View file

@ -0,0 +1,15 @@
#!/usr/bin/env zsh
source autopair.zsh
export KEYS=
export LBUFFER=
export RBUFFER=
assert_true() {
run $@
assert $state equals 0
}
assert_false() {
run $@
assert $state equals 1
}

View file

@ -0,0 +1,16 @@
#!/usr/bin/env zunit
@test 'basic boundary tests' {
LBUFFER="abc"
RBUFFER="123"
assert_false _ap-boundary-p " " " "
assert_true _ap-boundary-p "[^3]" "[^a]"
assert_false _ap-boundary-p "[^c]" "[^1]"
assert_true _ap-boundary-p "c" " "
assert_true _ap-boundary-p " " "1"
}
@test 'no boundary on blank line' {
LBUFFER=
RBUFFER=
assert_false _ap-next-to-boundary-p "{"
}

View file

@ -0,0 +1,24 @@
#!/usr/bin/env zunit
@test 'delete if next to space and pair' {
LBUFFER="[ " RBUFFER=" ]" assert_true _ap-can-delete-p
}
@test 'delete if next to homogeneous counter-pair' {
LBUFFER="'" RBUFFER="'" assert_true _ap-can-delete-p
}
@test 'delete if next to heterogeneous counter-pair' {
LBUFFER="(" RBUFFER=")" assert_true _ap-can-delete-p
}
@test 'do not delete if at eol' {
LBUFFER="'" assert_false _ap-can-delete-p
}
@test 'do not delete if within too many spaces' {
LBUFFER="[ " RBUFFER=" ]" assert_false _ap-can-delete-p
}
@test 'do not delete if only next to space' {
LBUFFER=" " RBUFFER=" " assert_false _ap-can-delete-p
}

View file

@ -0,0 +1,59 @@
#!/usr/bin/env zunit
@test 'pair if blank line' {
KEYS="'" LBUFFER="" RBUFFER="" assert_true _ap-can-pair-p
}
@test 'pair if next to balanced delimiter' { # {{|}}
KEYS="{" LBUFFER="{" RBUFFER="}" assert_true _ap-can-pair-p
}
@test 'pair space if next to brackets' { # { | }
KEYS=" "
LBUFFER="{" RBUFFER="}" assert_true _ap-can-pair-p
LBUFFER="[" RBUFFER="]" assert_true _ap-can-pair-p
LBUFFER="(" RBUFFER=")" assert_true _ap-can-pair-p
}
@test 'pair brackets at the end of a word' { # abc{|}
KEYS='{' LBUFFER="hello" assert_true _ap-can-pair-p
}
@test 'do not pair brackets at the beginning of a word' { # {|abc
KEYS='{' RBUFFER="hello" assert_false _ap-can-pair-p
}
@test 'do not pair quotes next to a word' {
KEYS="'"
LBUFFER="hello" assert_false _ap-can-pair-p # abc"|
RBUFFER="hello" assert_false _ap-can-pair-p # "|abc
}
@test 'do not pair the same quotes from inside quotes' { # ""|"
KEYS='"' LBUFFER='"' RBUFFER='"' assert_false _ap-can-pair-p
}
@test 'do not pair if delimiter is invalid' {
KEYS="<" LBUFFER="<" RBUFFER=">" assert_false _ap-can-pair-p
}
@test 'do not pair if next to unbalanced delimiter' { # {|}
KEYS="{" LBUFFER="" RBUFFER="}" assert_false _ap-can-pair-p
}
@test 'do not pair if next to unbalanced delimiter after space' { # {| }
AUTOPAIR_BETWEEN_WHITESPACE=
KEYS="{" LBUFFER="" RBUFFER=" }" assert_false _ap-can-pair-p
KEYS="{" LBUFFER="" RBUFFER=" }" assert_false _ap-can-pair-p
KEYS="{" LBUFFER=" " RBUFFER=" }" assert_false _ap-can-pair-p
}
@test 'do not pair space if next to non-brackets/spaces' {
KEYS=" "
LBUFFER="'" RBUFFER="'" assert_false _ap-can-pair-p # ' |'
LBUFFER="abc" RBUFFER="xyz" assert_false _ap-can-pair-p # abc |xyz'
LBUFFER="[ " RBUFFER=" ]" assert_false _ap-can-pair-p # [ | ]
}
@test 'AUTOPAIR_BETWEEN_WHITESPACE=1' {
AUTOPAIR_BETWEEN_WHITESPACE=1 KEYS='{' LBUFFER=" " RBUFFER=" }" assert_true _ap-can-pair-p
}

View file

@ -0,0 +1,25 @@
#!/usr/bin/env zunit
@test 'fail skip-check on blank line' {
LBUFFER='' RBUFFER='' assert_false _ap-can-skip-p '{' '}'
}
@test 'fail skip-check on wrong pair' {
LBUFFER='"' RBUFFER='"' assert_false _ap-can-skip-p '{' '}'
}
@test 'skip if next to homogeneous counter-pair' {
LBUFFER='"' RBUFFER='"' assert_true _ap-can-skip-p '"' '"'
}
@test 'skip if next to heterogeneous counter-pair' {
LBUFFER='{' RBUFFER='}' assert_true _ap-can-skip-p '{' '}'
}
@test 'do not skip if next to unbalanced, homogeneous counter-pair' {
LBUFFER='' RBUFFER='"' assert_false _ap-can-skip-p '"' '"'
}
@test 'do not skip if next to unbalanced, heterogeneous counter-pair' {
LBUFFER='' RBUFFER='}' assert_false _ap-can-skip-p '{' '}'
}

View file

@ -0,0 +1,26 @@
#!/usr/bin/env zunit
@test 'existing pair' {
assert $(_ap-get-pair "{") same_as "}"
}
@test 'existing right-pair' {
assert $(_ap-get-pair "" "}") same_as "{"
}
@test 'non-existent pair' {
assert $(_ap-get-pair "<") same_as ""
}
@test 'non-existent right-pair' {
assert $(_ap-get-pair "" ">") same_as ""
}
@test 'all default pairs' {
assert '"' in ${(@k)AUTOPAIR_PAIRS}
assert "'" in ${(@k)AUTOPAIR_PAIRS}
assert '`' in ${(@k)AUTOPAIR_PAIRS}
assert '{' in ${(@k)AUTOPAIR_PAIRS}
assert '[' in ${(@k)AUTOPAIR_PAIRS}
assert '(' in ${(@k)AUTOPAIR_PAIRS}
assert ' ' in ${(@k)AUTOPAIR_PAIRS}
}