kak: Separar sleuth a otro archivo

This commit is contained in:
Cat /dev/Nulo 2022-01-02 17:27:00 -03:00
parent b77c2e0269
commit 116241fbd5
2 changed files with 26 additions and 25 deletions

View file

@ -55,33 +55,12 @@ map global insert '<c-w>' '<esc>b<a-c>'
source "%val{config}/plugins/smarttab.kak/rc/smarttab.kak" source "%val{config}/plugins/smarttab.kak/rc/smarttab.kak"
hook global ModuleLoaded smarttab %{ hook global ModuleLoaded smarttab %{
set-option global softtabstop 4 set-option global softtabstop 4
source "%val{config}/sleuth.kak"
hook -group sleuth global BufOpenFile .* %{ sleuth }
hook -group sleuth global BufWritePost .* %{ sleuth }
} }
# https://github.com/mawww/kakoune/issues/2108#issuecomment-721313321
define-command sleuth -docstring 'Heuristically set buffer options' %{
try %{
evaluate-commands -draft %{
# Search the first indent level
execute-keys 'gg' '/' '^\h+' '<ret>'
# Tab vs. Space
# https://youtu.be/V7PLxL8jIl8
try %{
execute-keys '<a-k>' '\t' '<ret>'
noexpandtab
set-option buffer indentwidth 0
} catch %{
expandtab
set-option buffer indentwidth %val{selection_length}
set-option buffer softtabstop %val{selection_length}
}
}
}
}
hook -group sleuth global BufOpenFile .* %{ sleuth }
hook -group sleuth global BufWritePost .* %{ sleuth }
# ------------ # ------------
# FZF # FZF
# ------------ # ------------

22
.config/kak/sleuth.kak Normal file
View file

@ -0,0 +1,22 @@
# https://github.com/mawww/kakoune/issues/2108#issuecomment-721313321
define-command sleuth -docstring 'Heuristically set buffer options' %{
try %{
evaluate-commands -draft %{
# Search the first indent level
execute-keys 'gg' '/' '^\h+' '<ret>'
# Tab vs. Space
# https://youtu.be/V7PLxL8jIl8
try %{
execute-keys '<a-k>' '\t' '<ret>'
noexpandtab
set-option buffer indentwidth 0
} catch %{
expandtab
set-option buffer indentwidth %val{selection_length}
set-option buffer softtabstop %val{selection_length}
}
}
}
}