44# Detection
55# ‾‾‾‾‾‾‾‾‾
66
7+ declare-option -docstring " disable automatic edition of the buffer (wrap, trailing whitespaces)" \
8+ bool editorconfig_noedit false
9+
710hook global BufCreate .*[.](editorconfig) %{
811 set-option buffer filetype ini
912 set-option buffer static_words indent_style indent_size tab_width \
@@ -19,7 +22,7 @@ define-command editorconfig-load -params ..1 -docstring "editorconfig-load [file
1922 case $file in
2023 /* ) # $kak_buffile is a full path that starts with a '/'
2124 printf %s\\ n " remove-hooks buffer editorconfig-hooks"
22- editorconfig " $file " | awk -v file=" $file " -F= -- '
25+ editorconfig " $file " | awk -v file=" $file " -v noedit= " $kak_opt_editorconfig_noedit " - F= -- '
2326 $1 == "indent_style" { indent_style = $2 }
2427 $1 == "indent_size" { indent_size = $2 == "tab" ? 4 : $2 }
2528 $1 == "tab_width" { tab_width = $2 }
@@ -44,13 +47,15 @@ define-command editorconfig-load -params ..1 -docstring "editorconfig-load [file
4447 if (charset == "utf-8-bom") {
4548 print "set-option buffer BOM utf8"
4649 }
47- if (trim_trailing_whitespace == "true") {
50+ if (trim_trailing_whitespace == "true" && noedit == "false" ) {
4851 print "hook buffer BufWritePre \"" file "\" -group editorconfig-hooks %{ try %{ execute-keys -draft %{%s\\h+$<ret>d} } }"
4952 }
5053 if (max_line_length && max_line_length != "off") {
5154 print "set window autowrap_column " max_line_length
52- print "autowrap-enable"
5355 print "add-highlighter window/ column %sh{ echo $((" max_line_length "+1)) } default,bright-black"
56+ if (noedit == "false") {
57+ print "autowrap-enable"
58+ }
5459 }
5560 }
5661 ' ;;
0 commit comments