Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The indent_size and indent_style property does not work #264

Open
ghost opened this issue Oct 6, 2021 · 6 comments
Open

The indent_size and indent_style property does not work #264

ghost opened this issue Oct 6, 2021 · 6 comments

Comments

@ghost
Copy link

ghost commented Oct 6, 2021

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
Copy link
Member

10sr commented Oct 11, 2021

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
Copy link

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)

@10sr
Copy link
Member

10sr commented Oct 27, 2021

@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?

@serezlan
Copy link

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
Copy link
Member

10sr commented Nov 4, 2021

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
Copy link
Author

ghost commented Nov 19, 2021

My .editorconfig file:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants