Sublime Forum

Why do all c++ autocomplete plugins rely on Clang?

#1

I was looking for plugins to use Sublime Text for c++, but noticed all of them require Clang to be installed.

I was just wondering why this is and why I couldn’t just point the plugin to gcc’s include directories?

I won’t be using clang to compile anyway, so it seems strange to me that I can’t use any c++ autocomplete plugin unless I install clang?

0 Likes

#2

All those plugins boil down to relying on some clever external program that can actually parse your file. clang just so happens to have a convenient API for that.

4 Likes

#3

Yes, I just thought it seemed like overkill to require another compiler, but It seems that clang, coming from llvm I suppose, has such good parsing capabilities that code completion was buit in and makes it the best option. Even emacs and vim plugins use clang.

I noticed there are C++ snippets available. I guess my question is what is the difference for a user between writing code with a snippets package vs an autocomplete plugin? maybe that is better as a new topic, but what would the functional difference be between using an autocomplete plugin vs just the snippets?

0 Likes

#4

Snippets (and completions from a sublime-completions file) are essentially hard coded items that expand the same way every time based on matching input text, while an auto completion plugin analyses your code and provides you suggestions based on the code you’re currently writing.

For example you can create and install a set of snippets for say the SDL library; those snippets will always be available to you, so you can easily expand out SDL library calls.

In the meantime, any other libraries that you might be using, for which you don’t have snippets defined, aren’t going to be offered as completions; neither are the names of functions in the code you’re editing (all else being equal; they would appear if you’d used them before in the buffer, for example).

I would consider snippets exactly that; easy to invoke snippets of commonly used code and code constructs. If you want true auto completion of methods, variables, etc even if they don’t exist in the file you’re currently editing, you want an autocomplete plugin.

1 Like

#5

Ok.
It seems like the autocomplete plugin would still be best for me since I only want snippets for the std library, but not for loops and things like that, and completion of variables would be nice.

I noticed Sublime’s built-in suggestions approximate code completion of previous variables pretty well, so snippets might be nice if I can wittle down or find a package that just provides the std library, but otherwise installing the full plugin that uses Clang seems like a pretty good option.

edit: besides snippets and autocomplete, a third package category -“language syntax”- seems to have a lot of what I’m looking for, so that seems like a good place to look.

-Much thanks

0 Likes

#6

This plugin contains snippets-like completion for the std:
https://packagecontrol.io/packages/C%2B%2B%20Completions

0 Likes