Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

C/C++/ObjC/ObjC++ autocompletions and code navigation

branch: master
Octocat-spinner-32 internals Moved the use of project_path into the if statement. For #224 August 15, 2013
Octocat-spinner-32 issues Added archived issue history March 30, 2013
Octocat-spinner-32 src Fix a linking warning May 09, 2013
Octocat-spinner-32 unittests Issues #204 and #192 wip February 17, 2013
Octocat-spinner-32 .gitignore Added coverage files to .gitignore. November 11, 2012
Octocat-spinner-32 .gitmodules Internals subdir. February 01, 2013
Octocat-spinner-32 CONTRIBUTING.md Added unit testing section to CONTRIBUTING.md November 22, 2012
Octocat-spinner-32 Context.sublime-menu Added right click menu with the navigation commands in it January 19, 2012
Octocat-spinner-32 Default.sublime-commands Configuration file renamed December 10, 2011
Octocat-spinner-32 Default.sublime-keymap Tweaks for issue #91. July 13, 2012
Octocat-spinner-32 ErrorPanel.JSON-tmLanguage Adding syntax highlighting to SublimeClang's output panel. September 18, 2012
Octocat-spinner-32 ErrorPanel.tmLanguage Adding syntax highlighting to SublimeClang's output panel. September 18, 2012
Octocat-spinner-32 Main.sublime-menu Added menu item for the key bindings. More member regex tweaks December 27, 2011
Octocat-spinner-32 README.creole SublimeClang requires testing version of Package Control to install April 09, 2013
Octocat-spinner-32 SublimeClang.sublime-settings fixup! Support simple ${project_path} syntax in options May 09, 2013
Octocat-spinner-32 errormarkers.py Use sencode rather than encode("utf-8"). Fixes #202 February 16, 2013
Octocat-spinner-32 package.json Change url to sourceforge for #179. February 15, 2013
Octocat-spinner-32 staticanalyzer.py Internals subdir. February 01, 2013
Octocat-spinner-32 sublimeclang.py Fix misbehaving caret movement with multiple cursors. April 16, 2013
Octocat-spinner-32 sublimeclang.sublime-project Updated WIN_RELEASE target to download the versioned package. November 21, 2012
README.creole

Plugin discontinued

I don't intend to continue development of this plugin, so I've disabled the issues page. If something is broken, submit a pull request and I'll consider merging it. The issue history is archived should you want to poke in it.

Eventually SublimeClang will be replaced by https://github.com/quarnster/completion, but as I don't code much in clang supported languages these days it's not a very high priority for me personally. If you'd like to see it move along quicker, submit a pull request in that project and/or participate in its discussions.

Description

Clang plugin for Sublime Text 2 providing auto complete suggestions for C/C++/ObjC/ObjC++. It'll also optionally parse the code as it's typed and show errors and warnings.

Known issues and feature requests

Please go here to see the currently known issues and feature request, or to file a new.

Prerequisites

  1. To use the clang static analyzer you need to have clang installed and in your path. The other functionality should work without having the clang binaries installed.

Additional Prerequisites (Linux Only)

  1. ctypes can't be imported in the Linux version of Sublime Text 2 right now. This can however be worked around easily with the help of pythonbrew:
    1. curl -kL http://xrl.us/pythonbrewinstall | bash
    2. source "$HOME/.pythonbrew/etc/bashrc"
    3. pythonbrew install --configure="--enable-unicode=ucs4" 2.6
    4. ln -s $HOME/.pythonbrew/pythons/Python-2.6/lib/python2.6/ <your Sublime Text 2 folder>/lib/python2.6
  2. If you install SublimeClang via Package Control, it seems libcache and libclang will be deleted when the package is updated, so it's recommended that you manually install the plugin by using the git commands listed in the Installation section.
  3. Once SublimeClang has been installed, libcache will have to be compiled:
    1. cd src
    2. mkdir build
    3. cd build
    4. cmake ..
    5. make
  • Note that if a usable libclang library isn't found, it will be downloaded and built as part of the build process.

If you run into any issues, please have a look at issue #35 for additional notes or to ask for help.

Installation

  1. The easiest way to install SublimeClang is via the excellent Package Control Plugin. Note that SublimeClang doesn't install correctly with version v1.6.3 of Package Control; either use the latest testing version or (if it exists) a newer stable version of Package Control.
    1. See http://wbond.net/sublime_packages/package_control#Installation
      1. Once package control has been installed, bring up the command palette (cmd+shift+P or ctrl+shift+P)
      2. Type Install and select "Package Control: Install Package"
      3. Select SublimeClang from the list. Package Control will keep it automatically updated for you
    2. If you don't want to use package control, you can manually install it
      1. Go to your packages directory and type:
        1. git clone --recursive https://github.com/quarnster/SublimeClang SublimeClang
        2. After this you'll have to Compile libcache as described in the Additional Prerequisites (Linux Only) section
      2. To update run the following command:
        1. git pull && git submodule foreach --recursive git pull origin master
  2. Back in the editor, open up the command palette by pressing cmd+shift+P or ctrl+shift+P
  3. Type SublimeClang and open up the settings file you want to modify with any include directories or other options you want to provide to clang.

Usage

After installation, suggestions from clang should be provided when triggering the autocomplete operation in Sublime Text 2. By default it'll inhibit the Sublime Text 2 built in word completion, but the inhibition can be disabled by setting the configuration option "inhibit_sublime_completions" to false.

If you modify a file that clang can compile and if there are any errors or warnings in that file, you should see the output in the output panel, as well as having the warnings and errors marked in the source file.

There's also the following key-bindings (tweak Default.sublime-keymaps to change):

alt+d,alt+d Go to the parent reference of whatever is under the current cursor position
alt+d,alt+i Go to the implementation
alt+d,alt+b Go back to where you were before hitting alt+d,alt+d or alt+d,alt+i
alt+d,alt+c Clear the cache. Will force all files to be reparsed when needed
alt+d,alt+w Manually warm up the cache
alt+d,alt+r Manually reparse the current file
alt+d,alt+t Toggle whether Clang completion is enabled or not. Useful if the complete operation is slow and you only want to use it selectively
alt+d,alt+p Toggle the Clang output panel
alt+d,alt+e Go to next error or warning in the file
alt+shift+d,alt+shift+e Go to the previous error or warning in the file
alt+d,alt+s Run the Clang static analyzer on the current file
alt+d,alt+o Run the Clang static analyzer on the current project
alt+d,alt+f Toggle whether fast (but possibly inaccurate) completions are used or not

Show your support

Donate

License

This plugin is using the zlib license

Copyright (c) 2011-2012 Fredrik Ehnbom

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

   1. The origin of this software must not be misrepresented; you must not
   claim that you wrote the original software. If you use this software
   in a product, an acknowledgment in the product documentation would be
   appreciated but is not required.

   2. Altered source versions must be plainly marked as such, and must not be
   misrepresented as being the original software.

   3. This notice may not be removed or altered from any source
   distribution.

And in addition to this, clang itself is using the following license:

University of Illinois/NCSA
Open Source License

Copyright (c) 2003-2012 University of Illinois at Urbana-Champaign.
All rights reserved.

Developed by:

    LLVM Team

    University of Illinois at Urbana-Champaign

    http://llvm.org

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal with
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimers.

    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimers in the
      documentation and/or other materials provided with the distribution.

    * Neither the names of the LLVM Team, University of Illinois at
      Urbana-Champaign, nor the names of its contributors may be used to
      endorse or promote products derived from this Software without specific
      prior written permission.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
SOFTWARE.
Something went wrong with that request. Please try again.