forked from lenormf/kakoune-extra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
syntastic.kak
67 lines (54 loc) · 2.08 KB
/
syntastic.kak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
##
## syntastic.kak by lenormf
## Auto lint (and optionally format) your code on write
##
decl -docstring "format the buffer on save" \
bool syntastic_autoformat no
def -params 2..3 \
-docstring %{syntastic-declare-filetype <filetype> <lintcmd> <formatcmd>: automatically lint and/or format buffers on write} \
syntastic-declare-filetype %{ %sh{
readonly filetype="$1"
printf 'hook global WinSetOption filetype=%s %%{\n' "${filetype}"
if [ $# -gt 2 ] && [ -n "$3" ]; then
printf 'hook buffer BufWritePre "\Q%%val{buffile}" %%{ %%sh{
if [ "${kak_opt_syntastic_autoformat}" = true ]; then
if [ -z "${kak_opt_formatcmd}" ]; then
printf "set buffer formatcmd \\"%%s\\"\\\\n" "%s"
fi
echo format
fi
} }\n' "$(printf %s "$3" | sed -e 's/"/\\\\\\"/g' -e 's/%/\\\\%/g')"
fi
## FIXME: try isn't the good solution, this has to be executed only once
echo '
try %{ lint-enable }
hook buffer BufWritePost "\Q%val{buffile}" %{
'
if [ -n "$2" ]; then
printf '%%sh{
if [ -z "${kak_opt_lintcmd}" ]; then
printf "set window lintcmd \\"%%s\\"\\\\n" "%s"
fi
}\n' "$(printf %s "$2" | sed -e 's/"/\\\\\\"/g' -e 's/%/\\\\%/g')"
fi
echo 'lint } }'
} }
syntastic-declare-filetype "c" \
'cppcheck --language=c --enable=all --template="{file}:{line}:1: {severity}: {message}" 2>&1' \
'clang-format'
syntastic-declare-filetype "cpp" \
'cppcheck --language=c++ --enable=all --template="{file}:{line}:1: {severity}: {message}" 2>&1' \
'clang-format'
## FIXME: `dscanner` hasn't been tested
syntastic-declare-filetype "d" \
'dscanner' \
'dfmt'
## FIXME: `gometalinter` only takes directories as argument, create a wrapper
syntastic-declare-filetype "go" \
'gometalinter' \
'gofmt -e -s'
syntastic-declare-filetype "python" \
'flake8 --filename=* --format="%(path)s:%(row)d:%(col)d: error: %(text)s"' \
'autopep8 -'
syntastic-declare-filetype "sh" \
'shellcheck -fgcc -Cnever'