From f820d55e993024f4d4db148c93815c84dc9fcb5c Mon Sep 17 00:00:00 2001 From: lelgenio Date: Mon, 7 Dec 2020 15:32:45 -0300 Subject: [PATCH] create a file for indentation --- dotfiles/kak/hooks.kak | 9 ++------- dotfiles/kak/indent.kak | 40 ++++++++++++++++++++++++++++++++++++++++ dotfiles/kak/kakrc | 8 +------- 3 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 dotfiles/kak/indent.kak diff --git a/dotfiles/kak/hooks.kak b/dotfiles/kak/hooks.kak index 0cd199e..13ecde3 100644 --- a/dotfiles/kak/hooks.kak +++ b/dotfiles/kak/hooks.kak @@ -1,12 +1,5 @@ # {{@@ header() @@}} -# {%@@ if not tabs @@%} -# use spaces insted of tabs -hook global InsertChar \t %{ - exec -draft -itersel h@ -} -group kakrc-replace-tabs-with-spaces -# {%@@ endif @@%} - hook global NormalIdle .* %{ try %{ git show-diff palette-status @@ -37,3 +30,5 @@ hook global RegisterModified '"' %{ nop %sh{ hook global BufWritePre .* %{ try %{ execute-keys -draft \%s\h+$d } } + + diff --git a/dotfiles/kak/indent.kak b/dotfiles/kak/indent.kak new file mode 100644 index 0000000..ce08269 --- /dev/null +++ b/dotfiles/kak/indent.kak @@ -0,0 +1,40 @@ +# {{@@ header() @@}} +# _ __ _ +# | |/ /__ _| | _____ _ _ _ __ ___ +# | ' // _` | |/ / _ \| | | | '_ \ / _ \ +# | . \ (_| | < (_) | |_| | | | | __/ +# |_|\_\__,_|_|\_\___/ \__,_|_| |_|\___| + +set global tabstop 4 + +{%@@ 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 %{ + set buffer tabstop 2 + execute-keys -draft '%s^\s*' + } -group kakrc-replace-spaces-with-tabs + + hook global BufWritePre .*\.ya?ml %{ + execute-keys -draft '%s^\s*@' + } -group kakrc-replace-spaces-with-tabs + +{%@@ else @@%} +################################################################# +# Spaces +################################################################# + + set global indentwidth 4 + + # use spaces insted of tabs + hook global InsertChar \t %{ + exec -draft -itersel h@ + } -group kakrc-replace-tabs-with-spaces + +{%@@ endif @@%} diff --git a/dotfiles/kak/kakrc b/dotfiles/kak/kakrc index 79dbfe3..e635716 100644 --- a/dotfiles/kak/kakrc +++ b/dotfiles/kak/kakrc @@ -6,13 +6,6 @@ # |_|\_\__,_|_|\_\___/ \__,_|_| |_|\___| -set global tabstop 4 -{%@@ if tabs @@%} -set global indentwidth 4 -{%@@ else @@%} -set global indentwidth 0 -{%@@ endif @@%} - set global scrolloff 8,8 add-highlighter global/ wrap @@ -20,4 +13,5 @@ source "%val{config}/plug.kak" source "%val{config}/keys.kak" source "%val{config}/usermode.kak" source "%val{config}/hooks.kak" +source "%val{config}/indent.kak" source "%val{config}/colors.kak"