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

Fix #436 Search .clang-format file in parent folders, before creating it #444

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

travkin79
Copy link
Contributor

Instead of creating a .clang-format file for each project, CDT LSP now would check if there is a .clang-format file in some of the project's parent folders and use that. This way, multi-project directory structures (multi-project git repos) can offer common settings in their root folder that apply to all contained projects.

@jonahgraham jonahgraham linked an issue Feb 25, 2025 that may be closed by this pull request
Copy link
Member

@jonahgraham jonahgraham left a comment

Choose a reason for hiding this comment

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

@travkin79 Thanks for putting this together. I think this is generally the right idea and avoiding creating clang format files in this case is a good idea.

I see this is only a draft at the moment. I did a quick review because I would really like to get this merged by end of the day Wednesday, assuming no objection.

Let me know what I can do to make this happen.

private IFileStore findClangFormatFileInParentFolders(IProject project) {
IFileStore currentDirStore = EFS.getLocalFileSystem().getStore(project.getLocation());
IFileStore clangFormatFileStore = currentDirStore.getChild(format_file);
while (!clangFormatFileStore.fetchInfo().exists() && currentDirStore.getParent().fetchInfo().exists()) {
Copy link
Member

Choose a reason for hiding this comment

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

I think there is an NPE here? as getParent can return null when the root is reached


@Override
public void performDone(IJobChangeEvent event) {
if (openFile) {
Copy link
Member

Choose a reason for hiding this comment

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

Can this if openFile guard be moved out to prevent creating this job in the first place?

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.

Do not create .clangd-format file in project if parent has one
2 participants