This repository has been archived on 2024-04-07. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/dotfiles/kak/indent.kak

56 lines
1.5 KiB
Plaintext
Raw Normal View History

2020-12-07 19:32:45 +01:00
# {{@@ header() @@}}
# _ __ _
# | |/ /__ _| | _____ _ _ _ __ ___
# | ' // _` | |/ / _ \| | | | '_ \ / _ \
# | . \ (_| | < (_) | |_| | | | | __/
# |_|\_\__,_|_|\_\___/ \__,_|_| |_|\___|
set global tabstop {{@@ indent_width @@}}
2021-03-10 00:20:07 +01:00
hook global BufCreate .*\.py %{
set global indentwidth 4
2020-12-11 18:13:03 +01:00
}
2020-12-07 19:32:45 +01:00
{%@@ if tabs @@%}
#################################################################
# Tabs
#################################################################
# This means use tabs for `>` and `<`
set global indentwidth 0
# yaml is ass and does not allow tabs for indent
hook global BufOpenFile .*\.ya?ml %{
2021-03-10 00:20:07 +01:00
execute-keys -draft '%s^\s+<ret><a-@>'
write
set buffer autoreload false
2020-12-11 18:15:17 +01:00
} -group yaml-replace-spaces-with-tabs
2020-12-07 19:32:45 +01:00
hook global BufWritePost .*\.ya?ml %{ nop %sh{
tmpf=$(mktemp)
2021-04-14 07:58:07 +02:00
expand --tabs={{@@ indent_width @@}} --initial "${kak_buffile}" > "${tmpf}"
cat "${tmpf}" > "${kak_buffile}"
rm -- "${tmpf}"
} } -group yaml-replace-spaces-with-tabs
2020-12-07 19:32:45 +01:00
{%@@ else @@%}
#################################################################
# Spaces
#################################################################
set global indentwidth {{@@ indent_width @@}}
2020-12-07 19:32:45 +01:00
# use spaces insted of tabs
2021-03-10 00:10:43 +01:00
hook global BufCreate .* %{
hook buffer InsertChar \t %{
exec -draft -itersel h@
} -group replace-tabs-with-spaces
}
hook global WinSetOption filetype=makefile %{
remove-hooks buffer replace-tabs-with-spaces
}
2020-12-07 19:32:45 +01:00
{%@@ endif @@%}