editorconfig-emacs icon indicating copy to clipboard operation
editorconfig-emacs copied to clipboard

The indent_size and indent_style property does not work

Open ghost opened this issue 3 years ago • 6 comments

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!

ghost avatar Oct 06 '21 11:10 ghost

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?

10sr avatar Oct 11 '21 02:10 10sr

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:

  • Emacs 27.2
    • Fedora 34
    • Latest editorconfig
    • CSharp mode editorconfig file:
[*.cs]
indent_style = space
indent_size = 3
end_of_line = lf
insert_final_newline = true

Steps to reproduce:

  • Create new project
  • dotnet sln new
  • dotnet new classlib -o alpha
    • create .editorconfig file with above content
    • Open alpha/Class1.cs
    • Run editorconfig-format-buffer

Expected behavior:

    • Buffer is formatted with correct indent width

Actual result:

  • Indent is incorrect (width 4)

serezlan avatar Oct 25 '21 02:10 serezlan

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

  • What is the results of describe-editorconfig-properties before and after running editorconfig-format-buffer?
  • What if you disable your init.el (emacs -q)? Does this problem still happen?

10sr avatar Oct 27 '21 03:10 10sr

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.

serezlan avatar Oct 28 '21 00:10 serezlan

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.

10sr avatar Nov 04 '21 02:11 10sr

My .editorconfig file:

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

ghost avatar Nov 19 '21 11:11 ghost