Plugin for Sublime Text 3 for easy to use, out of the box autocompletions for C, C++, Objective-C, and Objective-C++.
You are just three simple steps away!
- Best is to use Package Control
- CTRL+Shift+P and install
EasyClangComplete
- CTRL+Shift+P and install
- If you don't have Package Control (you should)
- download one of the releases from here and restart Sublime Text after unpacking.
- Ubuntu :
sudo apt-get install clang
- OSX : ships
clang
by default. You are all set! - Windows : install the latest release from clang website.
- Other Systems : use your package manager or install from clang website.
- clang website: http://llvm.org/releases/download.html
Plugin will run cmake on a proper CMakeLists.txt
in your project folder and
will use information from it to complete your code out of the box.
Plugin will search for a compilation database compile_commands.json
in the
project folder and will load it to complete your code. If you want to specify a custom path to a comilation database you can do it in settings:
"flags_sources": [
{"file": "compile_commands.json", "search_in": "<YOUR_PATH>"},
],
You will need a little bit of manual setup for now. Clang
will automatically
search for headers in the folder that contains the file you are working on and
its parent. If you have a more sophisticated project you will need to help
clang
just a little bit. There are three ways to do it.
Pick ANY of the following:
-
Set include dirs in
"common_flags"
setting inUser Settings
:- See default settings to get started. These flags will be included in every project you run.
-
Add
.clang_complete
file to the root of your project folder.- This file should contain all includes and macroses you want to use.
- Example file contents:
-Isrc -I/usr/include
-
Override
"common_flags"
setting in your project file! Just define the same setting in project specific settings with either one of two prefixes:"ecc_"
or"easy_clang_complete_"
. See the project file in this repo for a working example. Minimal example for clarity:{ "settings": { "ecc_common_flags": ["-Isrc", "-I/usr/include"], "easy_clang_complete_verbose": true } }
These settings are prioritized in a configurable way. Check out the settings to learn more about it.
All the essential information to make the plugin run is written above. If you are still interested in more details - please read on.
The plugin uses libclang
with its python bindings. This method fully utilizes
caching from libclang
that makes your completions blazingly fast. It is unit
tested to complete STL functions on Linux, OSX and Windows platforms.
There is also a fallback mode if something is wrong with the libclang
one
that parses the output from clang -Xclang -code-completion-at
which is called
from the command line.
This plugin is intended to be easy to use. It should autocomplete STL out of
the box and is capable of working with multiple flag storages, such as a
compilation database or a .clang_complete
file. If you experience problems -
create an issue. I will try to respond as soon as possible.
Here are some highlights for the commands. You can see all commands in command pallet. Open it by pressing:
- Windows/Linux: Ctrl + Shift + P
- OSX: Cmd + Shift + P
All the commands of this plugin start with EasyClangComplete:
and should be
self explanatory. Open an issue if they are not.
EasyClangComplete provides several default key bindings listed here. Modify or create your own bindings by editing your Sublime Key Binding preferences to run a command listed in this file. For example, to show a popup with info about the currently selected symbol, add this to your key bindings:
{ "keys": ["ctrl+i"], "command": "ecc_show_popup_info" },
Please see the default settings file shipped with the plugin for explanations and sane default values.
The whole work seen here was originally a fork of another repository: ClangAutoComplete
However, with time this plugin has grown quite different from its origin and
this is why you see it as a separate package now. Anyway, feel free to check
out what ClangAutoComplete
has to offer and come back if you still like this
plugin more.
The trick with multiple clang.cindex
files is inspired by this repo:
clangHelper. Thanks for inspiration!
The progress indicator idea is from ColorSublime plugin.
Some functionality is there only because of the awesome contributors to this project. To see their names plese check out the contributors page.
Most crucial functionality is covered with unit tests using UnitTesting Sublime Text plugin.
Contributions are welcome! Look at the issue list. If there is something you think you can tackle, write about it in that issue and submit a Pull Request.
Please follow the issue template exactly when creating a new issue. I will be closing issues that do not follow that template. Please understand that maintaining this codebase takes time and I expect at least well-formatted issue statement to be able to tackle it. It is very demotivating to format the issues instead of the original submitter.
Please don't jump into creating a Pull Request straight away and open an issue first. This way, we can synchronize our views on the problem, so that everyone avoids losing time.
There are two branches:
master
: should be stable and generally following the last release. Used for urgent bug fixing.dev
: used to develop new features. Merges with master right before a new release.
- Line width is
80
characters - Every public function should be documented.
- The code must pass linters:
pep8
pep257
: ignoring["D209", "D203", "D204", "D213", "D406", "D407"]
Please ensure, that your code conforms to this.
Current sponsor of this project is my sleep. Please buy me a cup of tea if you appreciate the effort.
Also, pull requests are welcome! And don't forget to tell people about this plugin! The more people use it - the merrier.
This project exists thanks to all the people who contribute. [Contribute].
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]
╔═╗┌─┐┌─┐┬ ┬ ╔═╗┬ ┌─┐┌┐┌┌─┐ ╔═╗┌─┐┌┬┐┌─┐┬ ┌─┐┌┬┐┌─┐
║╣ ├─┤└─┐└┬┘ ║ │ ├─┤││││ ┬ ║ │ ││││├─┘│ ├┤ │ ├┤
╚═╝┴ ┴└─┘ ┴ ╚═╝┴─┘┴ ┴┘└┘└─┘ ╚═╝└─┘┴ ┴┴ ┴─┘└─┘ ┴ └─┘