diff --git a/.config/kak/autoload/detection/editorconfig.kak b/.config/kak/autoload/detection/editorconfig.kak index 34a8c82d..69fe4a6a 100644 --- a/.config/kak/autoload/detection/editorconfig.kak +++ b/.config/kak/autoload/detection/editorconfig.kak @@ -18,18 +18,39 @@ define-command editorconfig-load -params ..1 -docstring "editorconfig-load [file file="${1:-$kak_buffile}" filetype="$kak_opt_filetype" # check if we have a real file or a scratch buffer - # if [ -f "$file" ]; then - # case "$filetype" in - # markdown) file="scratch.md" ;; - # python) file="scratch.py" ;; - # sh) file="scratch.sh" ;; - # bash) file="scratch.sh" ;; - # fish) file="scratch.fish" ;; - # json) file="scratch.json" ;; - # toml) file="scratch.toml" ;; - # *) file="scratch.txt" ;; - # esac - # fi + if [ ! -f "$file" ]; then + scratch="true" + # need to create .editorconfig in /tmp if it's not there + if [ ! -f "/tmp/.editorconfig" ]; then + cp "$HOME/.editorconfig" "/tmp/.editorconfig" + fi + case "$filetype" in + markdown) + file="/tmp/scratch.md" + touch "$file";; + python) + file="/tmp/scratch.py" + touch "$file";; + sh) + file="/tmp/scratch.sh" + touch "$file";; + bash) + file="/tmp/scratch.sh" + touch "$file";; + fish) + file="/tmp/scratch.fish" + touch "$file";; + json) + file="/tmp/scratch.json" + touch "$file";; + toml) + file="/tmp/scratch.toml" + touch "$file";; + *) + file="/tmp/scratch.txt" + touch "$file";; + esac + fi case $file in /*) # $kak_buffile is a full path that starts with a '/' printf %s\\n "remove-hooks buffer editorconfig-hooks" @@ -69,6 +90,10 @@ define-command editorconfig-load -params ..1 -docstring "editorconfig-load [file } ' ;; esac + # if [ -n "$scratch" ]; then + # rm "/tmp/.editorconfig" + # rm "$file" + # fi } } complete-command editorconfig-load file diff --git a/.config/kak/autoload/plugins.kak b/.config/kak/autoload/plugins.kak index 4fd24c62..399bae9d 100644 --- a/.config/kak/autoload/plugins.kak +++ b/.config/kak/autoload/plugins.kak @@ -95,7 +95,7 @@ bundle-noload kakoune-text-objects https://github.com/Delapouite/kakoune-text-ob bundle smarttab.kak https://github.com/andreyorst/smarttab.kak %{ require-module smarttab set-option global softtabstop 2 - hook global BufCreate .* %{ + hook global WinSetOption filetype=.* %{ editorconfig-load autoconfigtab } diff --git a/.editorconfig b/.editorconfig index 472d81ce..5907a1c9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -15,18 +15,18 @@ indent_size = 4 [*.go] indent_style = tab -[*md] +[*.md] trim_trailing_whitespace = false insert_final_newline = true indent_style = space indent_size = 2 -[*yml] +[*.yml] indent_style = space indent_size = 2 -[*typ] +[*.typ] indent_style = space indent_size = 2 -[*fish] +[*.fish] indent_style = space indent_size = 4