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

🕴🏾 Our pre-commit/clang-format config is not great 🕴🏾 #212

Open
BaseMax opened this issue Aug 2, 2021 · 4 comments
Open

🕴🏾 Our pre-commit/clang-format config is not great 🕴🏾 #212

BaseMax opened this issue Aug 2, 2021 · 4 comments

Comments

@BaseMax
Copy link
Member

BaseMax commented Aug 2, 2021

As you see in some file for example lexer.test.c file I want to implement items of tokens in several lines..
https://github.com/One-Language/One/blob/master/test/lexer.test.c#L82

for example:

lexer_tests[lexer_tests_count++] = (LexerTest){"1\r\n    2\n3\n4", {token_make(TOKEN_VALUE_NUMBER), token_make(TOKEN_SKIP_WHITESPACE_LINE), token_make(TOKEN_VALUE_NUMBER), token_make(TOKEN_SKIP_WHITESPACE_LINE), token_make(TOKEN_VALUE_NUMBER), token_make(TOKEN_SKIP_WHITESPACE_LINE), token_make(TOKEN_VALUE_NUMBER), token_make(TOKEN_EOF)}, 7};

This is VERY BAD and not readable, we want some better syntax format.

This is much better:

lexer_tests[lexer_tests_count++] = (LexerTest){"1\r\n    2\n3\n4", {
	token_make(TOKEN_VALUE_NUMBER),
	token_make(TOKEN_SKIP_WHITESPACE_LINE),
	token_make(TOKEN_VALUE_NUMBER),
	token_make(TOKEN_SKIP_WHITESPACE_LINE),
	token_make(TOKEN_VALUE_NUMBER),
	token_make(TOKEN_SKIP_WHITESPACE_LINE),
	token_make(TOKEN_VALUE_NUMBER),
	token_make(TOKEN_EOF)
}, 7};
@BaseMax
Copy link
Member Author

BaseMax commented Aug 2, 2021

This is our clang-format config:
https://github.com/One-Language/One/blob/master/.clang-format

We can take a look at other c/c++ projects to see what clang-config these use...

@jbampton jbampton self-assigned this Aug 6, 2021
@jbampton jbampton reopened this Aug 14, 2021
@jbampton
Copy link
Contributor

https://stackoverflow.com/questions/33258159/how-to-make-clang-format-skip-sections-of-c-code

@BaseMax

@BaseMax
Copy link
Member Author

BaseMax commented Sep 3, 2021

Good trick

// clang-format off
.....
.....
.....
// clang-format on

@jbampton jbampton changed the title Our pre-commit/clang-format config is not great 🕴🏾 Our pre-commit/clang-format config is not great 🕴🏾 Sep 7, 2021
@jbampton
Copy link
Contributor

Do we need any other custom Clang Format settings ?

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

4 participants