2016-02-23 02:11:20 +03:00
|
|
|
def editorconfig-load -docstring "Set indentation options according to editorconfig file" %{
|
|
|
|
%sh{
|
2016-04-23 08:47:01 +03:00
|
|
|
command -v editorconfig >/dev/null 2>&1 || { echo 'echo -color Error The editorconfig tool could not be found'; exit 1; }
|
2016-02-23 02:11:20 +03:00
|
|
|
editorconfig $kak_buffile | awk -F= -- \
|
|
|
|
'{
|
|
|
|
if ($1 == "indent_style" && $2 == "tab") {
|
2016-04-23 08:47:01 +03:00
|
|
|
print "set buffer indentwidth 0"
|
2016-02-23 02:11:20 +03:00
|
|
|
}
|
|
|
|
else if ($1 == "indent_size" && $2 ~ "[0-9]+") {
|
|
|
|
print "set buffer indentwidth", $2
|
|
|
|
}
|
|
|
|
else if ($1 == "tab_width" && $2 ~ "[0-9]+") {
|
2016-04-23 08:47:01 +03:00
|
|
|
print "set buffer tabstop", $2
|
2016-02-23 02:11:20 +03:00
|
|
|
}
|
|
|
|
else if ($1 == "end_of_line") {
|
|
|
|
if ($2 == "lf" || $2 == "crlf") {
|
|
|
|
print "set buffer eolformat", $2
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print "echo -color yellow",$2,"is not a valid eolformat string: ignored\""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($1 == "charset") {
|
|
|
|
if ($2 == "utf-8-bom") {
|
|
|
|
print "set buffer BOM utf8"
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print "set buffer BOM none"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
}
|
|
|
|
}
|