Skip to content

Commit 75cd798

Browse files
authored
Add “VimL” lang (#455)
* Add VimL lang * Document need to save and quit VimL * VimL svg logo * Provide VimL arguments via args variable instead of in output file * VimL info language
1 parent b9c079d commit 75cd798

File tree

10 files changed

+118
-2
lines changed

10 files changed

+118
-2
lines changed

css/golfer/holes.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ input.rust:not(:checked) ~ .rust,
6363
input.sql:not(:checked) ~ .sql,
6464
input.swift:not(:checked) ~ .swift,
6565
input.v:not(:checked) ~ .v,
66+
input.viml:not(:checked) ~ .viml,
6667
input.zig:not(:checked) ~ .zig { display: none }
6768

6869
input:checked + label {
@@ -88,7 +89,7 @@ main svg:nth-of-type(2) {
8889

8990
@media (min-width: 95rem) {
9091
/* Increase this number when adding a language. */
91-
main { grid-template-columns: 4fr repeat(32, 1fr) }
92+
main { grid-template-columns: 4fr repeat(33, 1fr) }
9293

9394
main a { height: 1.9rem }
9495

db/a-schema.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ CREATE TYPE lang AS ENUM (
3434
'assembly', 'bash', 'brainfuck', 'c', 'c-sharp', 'cobol', 'crystal',
3535
'f-sharp', 'fish', 'fortran', 'go', 'haskell', 'hexagony', 'j', 'java',
3636
'javascript', 'julia', 'lisp', 'lua', 'nim', 'pascal', 'perl', 'php',
37-
'powershell', 'python', 'raku', 'ruby', 'rust', 'sql', 'swift', 'v', 'zig'
37+
'powershell', 'python', 'raku', 'ruby', 'rust', 'sql', 'swift', 'v',
38+
'viml', 'zig'
3839
);
3940

4041
CREATE TYPE medal AS ENUM ('diamond', 'gold', 'silver', 'bronze');

docker/dev.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ COPY --from=codegolf/lang-j ["/", "/langs/j/rootfs/" ] # 4.77 M
3333
COPY --from=codegolf/lang-brainfuck ["/", "/langs/brainfuck/rootfs/" ] # 4.56 MiB
3434
COPY --from=codegolf/lang-perl ["/", "/langs/perl/rootfs/" ] # 4.32 MiB
3535
COPY --from=codegolf/lang-cobol ["/", "/langs/cobol/rootfs/" ] # 4.1 MiB
36+
COPY --from=codegolf/lang-viml ["/", "/langs/viml/rootfs/" ] # 3.25 MiB
3637
COPY --from=codegolf/lang-c ["/", "/langs/c/rootfs/" ] # 1.61 MiB
3738
COPY --from=codegolf/lang-bash ["/", "/langs/bash/rootfs/" ] # 1.14 MiB
3839
COPY --from=codegolf/lang-sql ["/", "/langs/sql/rootfs/" ] # 1.03 MiB

docker/live.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ COPY --from=codegolf/lang-j ["/", "/langs/j/rootfs/" ] # 4.77 M
4646
COPY --from=codegolf/lang-brainfuck ["/", "/langs/brainfuck/rootfs/" ] # 4.56 MiB
4747
COPY --from=codegolf/lang-perl ["/", "/langs/perl/rootfs/" ] # 4.32 MiB
4848
COPY --from=codegolf/lang-cobol ["/", "/langs/cobol/rootfs/" ] # 4.1 MiB
49+
COPY --from=codegolf/lang-viml ["/", "/langs/viml/rootfs/" ] # 3.25 MiB
4950
COPY --from=codegolf/lang-c ["/", "/langs/c/rootfs/" ] # 1.61 MiB
5051
COPY --from=codegolf/lang-bash ["/", "/langs/bash/rootfs/" ] # 1.14 MiB
5152
COPY --from=codegolf/lang-sql ["/", "/langs/sql/rootfs/" ] # 1.03 MiB

langs.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,27 @@ for arg in os.args[1..] {
672672
}
673673
'''
674674

675+
[VimL]
676+
size = '3.25 MiB'
677+
version = 'v8.2.3131'
678+
website = 'https://www.vim.org/'
679+
example = '''
680+
" Printing
681+
execute "normal! iHello, World!\r"
682+
683+
" Looping
684+
for i in range(0, 9)
685+
execute "normal! i".i."\r"
686+
endfor
687+
688+
" Accessing arguments
689+
for a in args
690+
execute "normal! i".a."\r"
691+
endfor
692+
693+
execute "normal! :wq\<cr>"
694+
'''
695+
675696
[Zig]
676697
size = '241 MiB'
677698
version = '0.8.0'

langs/viml/Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM alpine:3.14 as builder
2+
3+
RUN mkdir /empty
4+
5+
RUN apk add --no-cache build-base git ncurses-dev
6+
7+
RUN git clone --branch v8.2.3131 --depth 1 https://github.com/vim/vim.git
8+
RUN cd vim/src \
9+
&& ./configure --prefix=/usr --with-features=normal --enable-multibyte \
10+
&& make \
11+
&& make install
12+
13+
# Quiet warnings about missing ftdetect
14+
RUN mkdir /usr/share/vim/vim82/ftdetect && touch /usr/share/vim/vim82/ftdetect/vim.vim
15+
16+
FROM scratch
17+
18+
COPY --from=0 /bin /bin
19+
COPY --from=0 /lib/ld-musl-x86_64.so.1 /lib/
20+
COPY --from=0 /usr/lib/libncurses.so \
21+
/usr/lib/libncursesw.so.6 /usr/lib/
22+
COPY --from=0 /usr/share/vim/vim82 /usr/share/vim/vim82
23+
COPY --from=0 /empty /proc
24+
COPY --from=0 /empty /tmp
25+
COPY --from=0 /usr/bin/vim /usr/bin/
26+
27+
COPY viml /usr/bin/
28+
29+
ENTRYPOINT ["/usr/bin/viml"]
30+
31+
CMD ["--version"]

langs/viml/viml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/sh -e
2+
3+
export PATH=/usr/bin:/bin
4+
5+
if [ "$1" = "--version" ]; then
6+
/usr/bin/vim --version
7+
exit 0
8+
fi
9+
10+
cd /tmp
11+
12+
# Inject args variable into code
13+
shift
14+
printf "let args = [" > code.vim
15+
while [[ $# -gt 0 ]]; do
16+
17+
# Escape double quotes and newlines
18+
escaped="$(\
19+
printf "$1" \
20+
| sed -e 's/"/\\\\"/g' \
21+
| sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\\\n/g' \
22+
)"
23+
24+
printf "\"$escaped\"" >> code.vim
25+
26+
if [[ $# -gt 1 ]]; then
27+
printf ", " >> code.vim
28+
fi
29+
30+
shift
31+
done
32+
printf "]\n" >> code.vim
33+
34+
# Write code to .vim file
35+
cat - >> code.vim
36+
37+
# Create output file
38+
touch output
39+
40+
# Execute
41+
set +e
42+
err="$(/usr/bin/vim --clean --not-a-term --noplugin -eZ -V1 +0 -S code.vim output 2>&1)"
43+
status=$?
44+
set -e
45+
46+
if [[ $status -eq 0 ]];then
47+
cat output
48+
else
49+
echo "$err" >&2
50+
exit $status
51+
fi

svg/viml.svg

Lines changed: 1 addition & 0 deletions
Loading

views/hole-ng.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ <h1>{{ .Data.Hole.Name }}</h1>
117117
column of the first result set will be printed, NULL values will be
118118
skipped, and the dialect is <a href=//sqlite.org/index.html>SQLite</a>.
119119
</div>
120+
<div class="info viml">
121+
Arguments are available via <b>args</b> list variable. To terminate
122+
script execution, write and quit the current buffer.
123+
</div>
120124

121125
<div id=run>
122126
ctrl + enter

views/hole.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ <h1>{{ .Data.Hole.Name }}</h1>
116116
column of the first result set will be printed, NULL values will be
117117
skipped, and the dialect is <a href=//sqlite.org/index.html>SQLite</a>.
118118
</div>
119+
<div class="info viml">
120+
Arguments are available via <b>args</b> list variable. To terminate
121+
script execution, write and quit the current buffer.
122+
</div>
119123
<div id=run>
120124
ctrl + enter
121125
<span>or</span>

0 commit comments

Comments
 (0)