Skip to content

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

Notifications You must be signed in to change notification settings

jfaust/SublimeClang

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 (solution provided by mnus):
    1. Install python2.6 via apt-get or synpactic.
    2. Backup python26.zip in sublime2's lib directory (just for safe measure). I did mv "python26.zip backup.python26.zip"
    3. Symlink /usr/lib/python2.6/ to sublime2's lib/python2.6 directory.
    4. If you run into issues with this step, issue #35 contains additional notes.
  2. The Linux libclang.so is not part of the plugin by default:
    1. Download and compile clang.
      • You can probably get away with installing clang from the ubuntu repos (note that this plugin relies on features from clang 3.0) or
      • Downloading a binary that matches your distribution
    2. Make sure libclang.so is in your path. Putting it in ~/.config/sublime-text-2/Packages/SublimeClang/ should work but if that fails, /usr/lib is probably a good choice to try as an alternative. It's also been reported that "libLLVM-3.0.so" could be a dependency of libclang.so, so you might have to copy that file as well.

Installation

  1. The easiest way to install SublimeClang is via the excellent Package Control Plugin
    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 https://github.com/quarnster/SublimeClang SublimeClang
  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+dGo to the parent reference of whatever is under the current cursor position
alt+d,alt+iGo to the implementation
alt+d,alt+bGo back to where you were before hitting alt+d,alt+d or alt+d,alt+i
alt+d,alt+cClear the cache. Will force all files to be reparsed when needed
alt+d,alt+wManually warm up the cache
alt+d,alt+rManually reparse the current file
alt+d,alt+tToggle 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+pToggle the Clang output panel
alt+d,alt+eGo to next error or warning in the file
alt+shift+d,alt+shift+eGo to the previous error or warning in the file
alt+d,alt+sRun the Clang static analyzer on the current file
alt+d,alt+oRun the Clang static analyzer on the current project
alt+d,alt+fToggle 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) 2007-2010 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.

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 49.3%
  • C 41.8%
  • C++ 8.9%