ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Clang​Auto​Complete

by pl-ca ST3

Sublime Text 3 plugin that offers auto-completion of C/C++ structure members or class attributes and methods.

Labels Clang, Completion, C, C++

Details

Installs

  • Total 24K
  • Win 9K
  • OS X 5K
  • Linux 10K
Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6
Windows 1 8 21 10 14 5 8 23 12 12 14 14 6 8 12 11 16 11 8 6 7 6 16 14 15 5 12 12 13 11 30 18 12 11 8 5 12 11 13 15 6 14 18 11 9 10
OS X 0 6 5 4 13 2 0 5 2 12 3 4 2 6 7 5 4 13 4 1 8 8 3 3 8 4 5 6 4 1 4 6 8 7 6 2 7 5 5 5 3 3 2 1 10 9
Linux 1 14 16 20 16 9 8 10 12 16 12 14 6 5 13 18 14 20 19 18 15 9 18 13 11 17 4 12 17 20 18 9 18 7 14 12 18 14 18 15 8 8 20 11 13 18

Readme

Source
raw.​githubusercontent.​com

ClangAutoComplete

Sublime Text 3 plugin that offers auto-completion of C/C++ structure members or class attributes and methods.

This plug-in is still maintained, but not very actively. I recommend to consider EasyClangComplete for more features and frequent updates.

Example

Installation

  1. Install “clang”. Note that some people reported issue with clang 3.5.2 when compiled from Cygwin. If you are facing issues on Windows, try to download directly from the official clang website.
  2. Install from Package Control, or clone this repository and put it in your Sublime's packages directory to install from git.
  3. Edit the settings to your needs (in menu Preferences/Package Settings/ClaugAutoComplete/Settings).

Troubleshooting

If completion does not work, it is almost always because of a problem with the include_dirs settings.

  1. Set the debug settings to "true" and attempt completion. An output panel will appear containing the result of the process. For it to work, there has to be lines starting with COMPLETION:. If you see any error like #include <file>: file not found, you need to add the path to that file in the include_dirs settings.

  2. The standard header files should automatically be located, but if nothing works, you should try to manually add them. Here is what it could look like

"include_dirs" : [
              "/usr/include/c++/4.4.7/",                      /* Where you find iostream, vector, etc. */
              "/usr/lib/clang/3.4.2/include",                 /* stdbool, etc */
              "/usr/include/c++/4.4.4/x86_64-redhat-linux/",  /* bits folder */
              "/usr/include",

If you can't find the equivalent path try to search your system to find those key files and add the paths, i.e.

sudo find / -name "iostream"
sudo find / -name "stdbool.h"
sudo find / -name "c++config.h"
  1. Make sure Sublime's own auto-complete settings are properly configured, I've had trouble with mine. Here is my C.sublime-settings as an example

    {
            "auto_complete": true,
            "auto_complete_selector": "source - comment",
            "auto_complete_triggers":
            [
                    {
                            "characters": "."
                    },
                    {
                            "characters": ">"
                    },
            ],
            "extensions":
            [
                    "c",
                    "h"
            ]
    }
    

Settings

  • include_dirs: List of directories where relevant header files are located
  • autocomplete_all: Trigger auto-completion on every keypress (will slow down sublime)
  • selectors: List of characters that will trigger auto-completion ( if “autocomplete_all” is set to “false” )
  • clang_binary: Location of clang binary (if it is not in the path)
  • You can copy the whole settings file under your project base folder named as “.clangautocomplete” to have the plugin load those instead of the general settings.
  • debug and verbose: Set to true to help understand what is going wrong (if completion is not working)

Recommended plugins for C development

Here are some useful plugins I use alongside ClangAutoComplete to have a more complete experience. - CTags: Code navigation, goto definition - SublimeLinter and SublimeLinter-contrib-clang: Errors and warnings highlights.

License

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE

Version 2, December 2004

Copyright © 2016 Pierre-Louis Caron-Auger

Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0.You just DO WHAT THE FUCK YOU WANT TO.