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

feat: Enable Clangd in repo #6430

Merged
merged 7 commits into from
Aug 23, 2024
Merged

feat: Enable Clangd in repo #6430

merged 7 commits into from
Aug 23, 2024

Conversation

tjzel
Copy link
Collaborator

@tjzel tjzel commented Aug 19, 2024

Summary

Bringing clangd to our monorepo.

What's clangd?

It's a language server that plugs into your text editor (yes, I'm looking at you VSCode) and provides you with syntax highlighting, autocompletion, inspections and much more. You can read about it on clangd's webpage.

Why do we need this?

Often times when we develop C++ code, we have to jump between Xcode and Android Studio just to get autosuggestions or be able to inspect some functions. This slows down development and these IDEs have their downsides.

With this change, you'll be able to edit the code in VSCode and have all the necessary information there, including static checks. In my experience it also works much faster than native IDEs.

Just to name a few useful features:

  • CMD+click leads you to source
  • Macros are resolved and you can see which branch of the code is active and which isn't
  • It parses objective C 🤯

How do I use it?

I automated the whole pipeline for clangd, so all you need to do is install VSCode's clangd extension.

You also need to compile the project once to generate all the artifacts utilized by clangd. For example, if you are developing for Fabric, iOS, just build FabricExample.

As a bonus, built-in VSCode's C++ plugin also benefits from this, so you don't need to use clangd at all. However, I still recommend clangd as a replacement. Try it out yourself!

Before:
Screenshot 2024-08-21 at 18 26 23

After:
Screenshot 2024-08-21 at 18 15 42

Test plan

🚀

tjzel added 6 commits August 19, 2024 22:22

Verified

This commit was signed with the committer’s verified signature.
nickzelei Nick Zelei
@tjzel tjzel marked this pull request as ready for review August 21, 2024 15:31
Copy link
Member

@piaskowyk piaskowyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 🫡

I want to use IT!

@tjzel tjzel added this pull request to the merge queue Aug 23, 2024
Merged via the queue into main with commit 3351e6b Aug 23, 2024
18 checks passed
@tjzel tjzel deleted the @tjzel/clangd-support branch August 23, 2024 09:52
generator_script_path = '../../../packages/react-native-reanimated/scripts/clangd-generate-xcode-metadata.sh'

script_phase :name => 'Generate metadata for clangd', :script => generator_script_path, :shell_path => '/bin/bash', :always_out_of_date => 'true', :execution_position => :after_compile
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no newline at the end of file, not very nice

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contributions are welcome 🤗

coado added a commit to software-mansion/react-native-gesture-handler that referenced this pull request Oct 3, 2024
## Description

This pull request introduces `clangd` support. You can read more about
it in
[this](software-mansion/react-native-reanimated#6430)
awesome PR that bring it to reanimated. For now it supports iOS only as
I am not sure if we need it for android here. To make it work, you have
build `FabricExample` or `MacOSExample` first.

<!--
Description and motivation for this PR.

Include 'Fixes #<number>' if this is fixing some issue.
-->


<!--
Describe how did you test this change here.
-->
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

3 participants