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

How to Code Formatting configuration #497

Open
Pavllick opened this issue Sep 26, 2019 · 2 comments
Open

How to Code Formatting configuration #497

Pavllick opened this issue Sep 26, 2019 · 2 comments

Comments

@Pavllick
Copy link

Cannot figure out how to config emacs to format code to any other styles other that to default. Can, please, anyone help me with configuration which on call omnisharp-code-format-entire-file format code to for instance "k&r" style?

@razzmatazz
Copy link
Contributor

Hi @Pavllick

I am not using omnisharp-server-native formatting features, but the one from csharp-mode.

My init.el contains this code:

  (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))

  (add-hook 'csharp-mode-hook 'sm-csharp-mode-setup t)

I then do:

  • M-x c-indent-line-or-region -- bound to TAB key in csharp mode

This does indentation for me using the "ellemtel" C-indentation style which I find most suitable for my code style.

Not sure omnisharp-code-format-entire-file' behaves, to be honest, -- hopefully my hint on (c-set-style "ellemtel")` is helpful to you.

@Pavllick
Copy link
Author

Thank you Saulius for your hint. It's very helpful ) But still not exactly what I'm looking for. It solves a half of the problem. The function omnisharp-code-format-entire-file is not the panacea but format file, not only indent, it move brackets on it's places and so on. I'm not that advanced user of emacs and still explore it, so any other advises on how to do that would be appreciated.

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

No branches or pull requests

2 participants