Skip to content
New issue

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

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

Already on GitHub? # to your account

How to set indentation to 2 spaces? #48

Closed
blldw opened this issue Sep 13, 2022 · 4 comments
Closed

How to set indentation to 2 spaces? #48

blldw opened this issue Sep 13, 2022 · 4 comments

Comments

@blldw
Copy link

blldw commented Sep 13, 2022

I am accustomed to using 2 spaces of indentation, and I would like to know whether there is a variable to keep the indentation to 2 spaces or if there is any way to keep these 2 spaces of indentation. When I input a `;', the code becomes 4 spaces of indentation automatically, and I want to avoid this happening.

@razzmatazz
Copy link
Owner

Hey @blldw; which editor are you using? Asking to make sure it is lsp formatting features that are formatting your code and not the editor.

At the moment csharp-ls provides about 0 :) configuration -- but this should be feasible to do by setting roslyn configurables.

@blldw
Copy link
Author

blldw commented Sep 14, 2022

I'm using Emacs 29.0.50 for editing the CSharp code, and whenever I input a `;',

Hey @blldw; which editor are you using? Asking to make sure it is lsp formatting features that are formatting your code and not the editor.

At the moment csharp-ls provides about 0 :) configuration -- but this should be feasible to do by setting roslyn configurables.

I'm using Emacs 29.0.50 for editing the CSharp code, and how can I change the roslyn configurations?

@razzmatazz
Copy link
Owner

razzmatazz commented Sep 15, 2022

hmm, have you tried configuring c-basic-offset, tab-width and evil-shift-width (if you're using evil?)

I am not 100% sure how it is setup on your machine, but I think by default csharp-mode does indentation unless you have specific configuration

e.g. I have this on my config.el file which works quite nicely for my coding style..

(after! csharp-mode
  (defun sm-csharp-mode-setup ()
    (setq indent-tabs-mode nil)
    (setq c-syntactic-indentation t)
    (c-set-style "ellemtel")
    (setq c-basic-offset 4)
    (setq truncate-lines t)
    (setq tab-width 4)
    (setq evil-shift-width 4))

also @kstatz12 is working on .editorconfig support so maybe that will help #49

in your case maybe you don't even need changes in csharp-ls if you set proper values in .editorconfig and you have https://github.com/editorconfig/editorconfig-emacs plugged in..

@blldw
Copy link
Author

blldw commented Sep 17, 2022

If I only use csharp-mode when writing csharp code, 2 space indentation works fine; However, If I enable lsp-mode, the problem I posted will occur:

(use-package csharp-mode
  :hook (csharp-mode . lsp))

@razzmatazz Your configuration for 4 spaces indentation worked, but not the solution for 2 space indentation.

With LSP, C/C++, Python, and Javascript all worked with 2 space indentation, and C# is an exception. I can't figure out whether the problem is attributed to csharp-mode package, C# language server, or LSP client.

@blldw blldw closed this as completed Sep 26, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants