andreyorst / smarttab.kak

Automatic handling different styles of indentation and alignment.
MIT License
62 stars 4 forks source link

Overwrite default mode only when .editorconfig file is present #15

Closed erazemk closed 2 years ago

erazemk commented 2 years ago

I want to use smarttab as the default option, but allow overwriting it when an editorconfig file is present.

I've tried the following setup:

hook global BufOpenFile .* smarttab
hook global BufNewFile  .* smarttab
hook global BufCreate .* %{
    editorconfig-load
    set-option buffer aligntab false
    autoconfigtab
}

but it doesn't seem to do what I want (I'm not knowledgeable enough about kakoune to figure out how to properly configure it).

Is there a way to make this work with smarttab.kak?

andreyorst commented 2 years ago

I'm not sure how exactly autoconfigtab works, as I've never used it. It was added recently by @clarfonthey, maybe a hint from the author would help?

clarfonthey commented 2 years ago

So, the setup I would recommend is putting smarttab immediately before autoconfigtab in the same hook so you ensure they're always run in the right order.

erazemk commented 2 years ago

hook global BufCreate .* %{ editorconfig-load set-option buffer aligntab false autoconfigtab }

Like this?

hook global BufCreate .* %{
    editorconfig-load
    set-option buffer aligntab false
    smarttab
    autoconfigtab
}

If so, wouldn't autoconfigtab still overwrite smarttab? Also which hook should I use: BufOpenFile, BufNewFile, BufCreate or something else?

Edit: This doesn't seem to work, as smarttab overwrites autoconfigtab for whatever reason.

clarfonthey commented 2 years ago

autoconfigtab shouldn't overwrite smarttab; it should only overwrite it if you specify stuff in editorconfig. But it probably isn't done correctly.

erazemk commented 2 years ago

autoconfigtab shouldn't overwrite smarttab; it should only overwrite it if you specify stuff in editorconfig. But it probably isn't done correctly.

My config isn't done correctly or autoconfigtab? Because my config looks like the code I pasted above, but in the current state, it ignores the editorconfig file and if I remove the smarttab option, it uses spaces for indentation, which might be from the editorconfig file or could just be the default kakoune option.

If it helps, I can test different configurations based on what you think should work.

clarfonthey commented 2 years ago

I should clarify, I meant that autoconfigtab isn't configured correctly. Although, I think the order should be:

  1. smarttab
  2. editorconfig-load
  3. autoconfigtab
erazemk commented 2 years ago

I should clarify, I meant that autoconfigtab isn't configured correctly. Although, I think the order should be:

  1. smarttab
  2. editorconfig-load
  3. autoconfigtab

Thanks, that works.

andreyorst commented 1 year ago

My config isn't done correctly or autoconfigtab?

Does your editorconfig settings work correctly in some other text editor? Maybe you could attach a minimal kakrc and editorconfig files so we could try to reproduce the issue?