editorconfig / editorconfig-emacs

EditorConfig plugin for Emacs
https://editorconfig.org
GNU General Public License v3.0
746 stars 106 forks source link

The indent_size and indent_style property does not work #264

Open ghost opened 3 years ago

ghost commented 3 years ago

OS: Archlinux latest. Emacs version: 29 latest. (27 does not work too) Plugin version: latest.

When I insert Tab, I get tab indent and wrong indent size, But, an editorconfig file in the root of my project.

Please give me an answer! Thanks!

10sr commented 3 years ago

Thanks for reporting issue!

I want to know the result of M-x describe-editorconfig-properties and the content of your .editorconifg file. Cloud you paste them?

serezlan commented 3 years ago

Hi,

I think I have similar issue. Pressing Enter and TAB give me correct result. But running editorconfig-format-buffer, it went back to default setting

System:

[*.cs]
indent_style = space
indent_size = 3
end_of_line = lf
insert_final_newline = true

Steps to reproduce:

10sr commented 3 years ago

@serezlan Umm... I cannot reproduce your problem.

serezlan commented 3 years ago

I forgot to mention I'm using lsp-mode. When I disable lsp, formatting buffer worked as expected and when it is turned on, it will override everything and use value from language server. I can get around this by setting lsp-enable-indentation to nil.

10sr commented 3 years ago

Thanks! I checked the lsp-mode code roughly.

It seems that when lsp-mode is enabled (and lsp-enable-indentation is set to t) lsp-mode configures buffers to use langauage servers' textDocument/rangeFormatting request to format buffers. So Emacs buffers' indent configurations are ignored.

IMO each language server (not lsp-mode) needs to support .editorconfig to fully solve your problem... I'll document this to README.

ghost commented 2 years ago

My .editorconfig file:

root = true
[*]
indent_style = space
indent_size = 2