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

code: add .editorconfig for consistent code style across editors #22916

Merged
merged 1 commit into from
Mar 22, 2024

Conversation

flyingthingsintothings
Copy link
Contributor

@flyingthingsintothings flyingthingsintothings commented Mar 21, 2024

EditorConfig is a well-known convention to share style settings across different editors. Adding one will make it easier for new contributors or people who like to use a different editor to contribute.

Solved Problem

I've switched from using Visual Studio Code to Neovim because the language server works quite a lot better. Neovim has no way to tell how to indent lines or how to represent tabs. Having this file tells a lot of different editors some basic information like how many spaces a tab represents, whether to indent with spaces or tabs, what the maximum line length should be... It can also tell editors to use a certain encoding, add a newline at the end of files and some other QOL settings.

The developer documentation mentions that a lot of files do not yet follow the style guidelines. This file could help to organically convert more and more files to the correct format as quite a lot of editors are automatically set up correctly.

Solution

  • Add a .editorconfig file with shared options for all C/C++ files.

Changelog Entry

For release notes:

Feature/Bugfix XYZ
New parameter: XYZ_Z
Documentation: Need to clarify page ... / done, read docs.px4.io/...

Alternatives

I think this is the most general approach. It's used by a ton of editors. Sadly Visual Studio Code requires an extension, which could be added to the list of recommended extensions.

Context

I find it weird that nobody has suggested this before. Maybe I'm overlooking something but I can't find a single mention of EditorConfig anywhere in the issues or PRs. Sorry if this has been proposed before.

EditorConfig is a well-known convention to share style settings across
different editors. Adding one will make it easier for new contributors
or people who like to use a different editor to contribute.
@dagar dagar merged commit d0251b8 into PX4:main Mar 22, 2024
88 of 89 checks passed
@flyingthingsintothings flyingthingsintothings deleted the pr-editorconfig branch March 22, 2024 08:01
Peize-Liu pushed a commit to Peize-Liu/PX4-Autopilot that referenced this pull request Mar 24, 2024
EditorConfig is a well-known convention to share style settings across
different editors. Adding one will make it easier for new contributors
or people who like to use a different editor to contribute.
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

Successfully merging this pull request may close these issues.

None yet

2 participants