-
Notifications
You must be signed in to change notification settings - Fork 25
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
feat: rewrite the scanner in C #56
Conversation
Hey @amaanq, thanks for the PR :) I think there are a couple other places to adjust with relation to bindings (ref), can you also please adjust those? (FTR why we switch tree-sitter/tree-sitter-cpp#209) |
src/scanner.c
Outdated
// =, ==, ===, =~, => | ||
} else if (lexer->lookahead == '=') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, I would keep the original formatting :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'd be nice if there was a clang-format file for that standard..having to manually do that is a bit annoying 😅 if the main want is indents being 2 spaces then thats much easier to do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be fair there is no standard, I didn't use a formatter :D
If there's an easy way to add a formatter task then that works for me (otherwise whoever changes the file may reformat it using different tool or IDE). Perhaps the clang-format
npm package would do? Then we could add it to the formatting tasks we have:
tree-sitter-elixir/package.json
Lines 19 to 20 in 4ba9dab
"format": "prettier --trailing-comma es5 --write grammar.js", | |
"format-check": "prettier --trailing-comma es5 --check grammar.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto formatting happens from the clangd lsp, a .clang-format
file in the project root can set this up easily and clangd will pick it up and override the users config. Here's my config for example to show you a few options that can be configured:
AlignArrayOfStructures: Left
BasedOnStyle: LLVM
IndentCaseLabels: true
IndentGotoLabels: true
IndentPPDirectives: AfterHash
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: false
SeparateDefinitionBlocks: Always
SortIncludes: CaseInsensitive
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceBeforeCaseColon: false
Rest are here https://clang.llvm.org/docs/ClangFormatStyleOptions.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, my point is that we should have a way to easily run it with CLI and also check formatting on CI. Here's the package I found, which as far as I understand calls the clang formatter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm..sure that could be fine - I'm not against it but a clang-format file could be enough if anyone's using the lsp/format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but with the file alone we can't enforce it on CI, and we assume they use LSP (which for example I don't :)).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep..understandable. Added the dep + format script, but it has no easy "just show me the errors" option so I just used diff (returns 1 on differences, 0 if none)
done |
301951e
to
be29840
Compare
Forgot to add the .clang-format file 🙈 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you!
thank you too! |
No description provided.