Skip to content

Commit 7160dd2

Browse files
committed
autowrap: automatically set autowrap column highlighter
Also the user now can change the value, without duplicating the column.
1 parent 8e876c9 commit 7160dd2

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

rc/detection/editorconfig.kak

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ define-command editorconfig-load -params ..1 -docstring "editorconfig-load [file
5050
if (max_line_length && max_line_length != "off") {
5151
print "set window autowrap_column " max_line_length
5252
print "autowrap-enable"
53-
print "add-highlighter window/ column %sh{ echo $((" max_line_length "+1)) } default,bright-black"
5453
}
5554
}
5655
' ;;

rc/tools/autowrap.kak

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare-option -docstring "maximum amount of characters per line, after which a newline character will be inserted" \
2-
int autowrap_column 80
2+
int autowrap_column 0
33

44
declare-option -docstring %{
55
when enabled, paragraph formatting will reformat the whole paragraph in which characters are being inserted
@@ -48,3 +48,13 @@ define-command autowrap-enable -docstring "Automatically wrap the lines in which
4848
define-command autowrap-disable -docstring "Disable automatic line wrapping" %{
4949
remove-hooks window autowrap
5050
}
51+
52+
hook global WinSetOption autowrap_column=0 %{
53+
try %{
54+
remove-highlighter window/autowrap_column
55+
}
56+
}
57+
58+
hook global WinSetOption autowrap_column=(?!0).* %{
59+
add-highlighter -override window/autowrap_column column %sh{ echo $((kak_opt_autowrap_column+1)) } default,bright-black
60+
}

0 commit comments

Comments
 (0)