Skip to content

Conversation

@haxiomic
Copy link

This PR adds support for .clang_complete files which are used in the atom and vim plugins

The advantage of supporting a .clang_complete file is that if the project is being used with multiple editors then only one set of clang complete arguments needs to be maintained

At the moment the arguments are added to the current options, rather than overriding, so if a .sublime-project is also used, then the result will be a combination of the options.

Do you think it would it be better to have the .sublime-project options override the .clang_complete file?

I'm new to python and sublime plugin development, so although it works, if it's going to merge it'd be good if it's looked over thoroughly to make sure it's the best approach

@haxiomic haxiomic changed the title Added support for .clang_complete files (see vim and atom clang autocomplete plugins) Added support for .clang_complete files for consistency with vim and atom plugins Jan 30, 2016

# seach for .clang_complete file and add lines to options
target_file = ".clang_complete"
directory = os.path.dirname(view.file_name())
Copy link

Choose a reason for hiding this comment

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

EDIT: I jumped the gun on this comment. I notice later on you search up the tree, negating this issue. Ignore this comment.

Won't this not work with nested structures? The .clang_complete file is typically in the root of the project but what if some of my code is in lib/ or src/. Maybe it would be better to use os.path.dirname(sublime.active_window().folders()[0]) which will be the main folder of the current window.

Or even better, use the current window's folder if there is one, and otherwise use the file's folder. Or try both.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for checking it over @trishume

I agree about taking into account the window's folder - it might be best stop the search for .clang_complete when it reaches the root of the folder that's associated with both the window and the file, using sublime.active_window().folders() would work but I think we'd need to search all of them so we choose the folder that the file is buried within

Searching up the entire directory tree works but there's some edge cases where it could pick up a .clang-complete you didn't intent it to use

@trishume
Copy link

trishume commented Feb 8, 2016

The code looks good to me and I would appreciate this feature 👍
cc @lvzixun

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.

2 participants