Inbuilt editorconfig not adhering to my 2 space rule?

I am having some difficulties getting the built in editorconfig support working properly or I’m doing something wrong. I realize that there is also a smart tabs plugin but wanted to use editorconfig files instead. What is happening is I have the file from git.io editor config for Elixir projects which is set for a style of space and size of 2, which is what I want. As I code, whenever I do a tab I see what looks like 2 spaces so it appears perfect on my screen. When however I have working code I submit my file to a challenge site exercism and what I am finding is that some tabs are actualy showing up with a size of 5. I need to remember before submiting code to use elixirs mix tool to fix the formating. I think the problem is within Kakoune because I assume the CLI tool exercism uses is just uploading the file, not transforming it, but I could be wrong.

Has anyone else had problems where the editorconfig does not seem to be applied?

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

Forgot to mention I have this in my kakrc hook global WinCreate ^[^*]+$ %{editorconfig-load}

Btw, this will not work for any buffer that has * symbol, like foo*bar.

1 Like

Hi slipsnip, you could try the below

Enable editor config
<https://github.com/mawww/config/blob/master/kakrc#L17>
hook global BufOpenFile .* %{ editorconfig-load }
hook global BufNewFile .* %{ editorconfig-load }

or check your kakoune settings which may be conflicting.

set-option global tabstop 4
set-option global indentwidth 4

Hope this helps. Bye :wave:

1 Like

quote=“duncan, post:3, topic:1793”]

hook global BufOpenFile .* %{ editorconfig-load }
hook global BufNewFile .* %{ editorconfig-load }

[/quote]

Thank you both, I have now replaced hook global WinCreate ^[^*]+$ %{editorconfig-load} with the aforementioned hooks noted by @duncan. Also thanks (offtopic @andreyorst love your fzf plugin, used it every day all day)

I will try these changes and see what happens the next time I submit code which should be today sometime. Hope this works. I will put my full kakrc incase someone sees something off.

source "%val{config}/plugins/plug.kak/rc/plug.kak"
plug "andreyorst/plug.kak" noload

plug "andreyorst/fzf.kak"

hook global BufOpenFile .* %{ editorconfig-load }
hook global BufNewFile .* %{ editorconfig-load }
hook global WinSetOption filetype=elixir %{
  # NOTE: The `Elixir.CredoNaming.Check.Consistency.ModuleFilename` rule is
  #   not supported because Kakoune moves the file to a temporary directory
  #   before linting.
  set-option window lintcmd "mix credo list --config-file=.credo.exs --format=flycheck --ignore-checks='Elixir.CredoNaming.Check.Consistency.ModuleFilename'"
}

colorscheme dracula

add-highlighter global/ number-lines

map global normal <c-p> ': fzf-mode<ret>'
map global user y '<a-|>xsel -i -b<ret>' -docstring "Yank to system clipboard"
map global user s ': w<ret>' -docstring "Save file"
map global user P '!xsel --output --clipboard<ret>' -docstring "Paste above from clipboard"
map global user p '<a-!>xsel --output --clipboard<ret>' -docstring "Paste from system clipboard"
map global user q ': q' -docstring "Quit"

Thus far it appears that your sugested changes has corrected the problem and I can now focus on learning and not wory about my formating. Thank you.