{"id":13418126,"url":"https://github.com/jeaye/color_coded","last_synced_at":"2025-10-04T05:31:57.802Z","repository":{"id":21360758,"uuid":"24677959","full_name":"jeaye/color_coded","owner":"jeaye","description":"A vim plugin for libclang-based highlighting of C, C++, ObjC","archived":true,"fork":false,"pushed_at":"2024-02-08T06:02:35.000Z","size":8397,"stargazers_count":870,"open_issues_count":41,"forks_count":53,"subscribers_count":39,"default_branch":"master","last_synced_at":"2024-09-29T23:23:41.105Z","etag":null,"topics":["c","clang","cplusplus","highlighting","libclang","objective-c","vim"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeaye.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2014-10-01T12:42:28.000Z","updated_at":"2024-09-12T09:54:55.000Z","dependencies_parsed_at":"2024-02-17T18:45:39.406Z","dependency_job_id":null,"html_url":"https://github.com/jeaye/color_coded","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeaye%2Fcolor_coded","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeaye%2Fcolor_coded/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeaye%2Fcolor_coded/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeaye%2Fcolor_coded/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeaye","download_url":"https://codeload.github.com/jeaye/color_coded/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235222543,"owners_count":18955327,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","clang","cplusplus","highlighting","libclang","objective-c","vim"],"created_at":"2024-07-30T22:00:58.729Z","updated_at":"2025-10-04T05:31:51.765Z","avatar_url":"https://github.com/jeaye.png","language":"C++","readme":"color_coded: semantic highlighting with vim [![Build Status](https://travis-ci.org/jeaye/color_coded.svg?branch=master)](https://travis-ci.org/jeaye/color_coded)\n---\n**NOTE: This project is archived and has been superseded by LSP-based\nhighlighting, which is less clunky and less resource intensive. color_coded\nno doubt pioneered this space and I'm grateful for all of the tokens which have\nbeen colored in our editors ever since.**\n\n---\ncolor_coded is a vim plugin that provides realtime (fast), tagless code highlighting for C++, C, and Objective C using libclang.\n\n  * Environmentally friendly\n  * Lua binding for VimL -\u003e C++\n  * Exhaustive customization possibilities\n  * Unintrusive highlighting; self-contained\n  * Utilizes self-contained clang\n\nBefore color_coded | After color_coded\n:------------------:|:------------------:\n\u003cimg src=\"https://raw.githubusercontent.com/jeaye/color_coded/master/pics/trimmed_cc_t_no_3.png\" width=\"100%\"/\u003e | \u003cimg src=\"https://raw.githubusercontent.com/jeaye/color_coded/master/pics/trimmed_cc_t_yes_3.png\" width=\"100%\"/\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/jeaye/color_coded/master/pics/trimmed_cc_t_no_1.png\" width=\"100%\"/\u003e | \u003cimg src=\"https://raw.githubusercontent.com/jeaye/color_coded/master/pics/trimmed_cc_t_yes_1.png\" width=\"100%\"/\u003e\n\nInstallation\n---\n#### OS X\nBefore installing color_coded on OS X, please read the following. The vim that ships with (even the latest) OS X is not new enough to support color_coded. Furthermore, the default macvim from [homebrew](http://brew.sh/) doesn't have lua enabled. To ensure you have a valid macvim install on OS X, please do the following:\n```bash\nbrew update\nbrew install macvim --with-lua --with-override-system-vim\nbrew linkapps macvim\nbrew install xz cmake\n# Spawn a new shell to use the new system vim\n```\n\nTo get proper highlighting, you'll also want the Xcode command line tools, which\nwill give you the appropriate system headers:\n```bash\nxcode-select --install\n```\n\n#### Ubuntu/Debian\nFirst, install all required dependencies.\n```bash\n[sudo] apt-get install build-essential libclang-3.9-dev libncurses-dev libz-dev cmake xz-utils libpthread-workqueue-dev libtinfo-5\n```\n\nFor lua, you must install the version that your version of vim is compiled for.\n```bash\nvim --version | grep lua\n```\nFind your version number `-llua5.x` and use it to install the correct version.\n```bash\n[sudo] apt-get install liblua5.x-dev lua5.x\n```\n\nYou also need to ensure you have GCC 4.9 (or higher). If you don't, you can try the following (tested on Ubuntu 14.04).\n```bash\n# Install GCC 4.9\n[sudo] add-apt-repository ppa:ubuntu-toolchain-r/test\n[sudo] apt-get update\n[sudo] apt-get install g++-4.9\n\n# Prefer 4.9 to other versions\n[sudo] update-alternatives --remove-all g++\n[sudo] update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 50\n```\n\n#### FreeBSD / PCBSD\n\n(Tested in FreeBSD 11.1)\n\n```bash\n$ [sudo] pkg install llvm40 cmake\n```\n\n```bash\n$ cd ~/.vim/bundle/color_coded\n$ mkdir build \u0026\u0026 cd build\n$ cmake -DCUSTOM_CLANG=1 -DLLVM_ROOT_DIR=/usr/local/llvm40  ..\n$ make \u0026\u0026 make install\n```\n\n#### Vundle and Pathogen\nInstallation has been tested using [vundle](https://github.com/gmarik/Vundle.vim), but should also be compatible with [pathogen](https://github.com/tpope/vim-pathogen). To install using vundle (add the line to your `~/.vimrc`, restart vim, run `:PluginInstall`):\n\n```viml\nPlugin 'jeaye/color_coded'\n```\n\n#### NeoBundle\n\nInstallation with [NeoBundle](https://github.com/Shougo/neobundle.vim) supports automatically building and lazy-loading the plugin:\n\n```viml\nNeoBundleLazy 'jeaye/color_coded', {\n  \\ 'build': {\n    \\   'unix': 'rm -f CMakeCache.txt \u0026\u0026 cmake . \u0026\u0026 make \u0026\u0026 make install',\n  \\ },\n  \\ 'autoload': { 'filetypes' : ['c', 'cpp', 'objc', 'objcpp'] },\n  \\ 'build_commands' : ['cmake', 'make']\n\\}\n```\n\n#### All\n\nSince color_coded has a compiled component, you'll need to manually compile when installing and updating (unless your vim package manager does it for you). Compilation works as follows, assuming usage of vundle (see the [dependencies](https://github.com/jeaye/color_coded#dependencies) section to ensure you can `make` properly):\n\n```bash\ncd ~/.vim/bundle/color_coded\nrm -f CMakeCache.txt\nmkdir build \u0026\u0026 cd build\ncmake ..\nmake \u0026\u0026 make install # Compiling with GCC is preferred, ironically\n# Clang works on OS X, but has mixed success on Linux and the BSDs\n\n# Cleanup afterward; frees several hundred megabytes\nmake clean \u0026\u0026 make clean_clang\n```\n\nFor various compatibility reasons, color_coded will attempt to download a known version of clang. This may add time to your configuration process, but it offers more stability across multiple platforms. Avoiding this is not officially supported, but documented [here](https://github.com/jeaye/color_coded#how-can-i-use-a-custom-llvmclang-setup).\n\n**ANOTHER NOTE:** color_coded doesn't reliably support luajit. More informatively, [luajit doesn't reliably support being embedded in shared libraries](https://www.freelists.org/post/luajit/OSx-load-luajit-64bit-from-plugin).\n\nUsage\n---\nOnce color_coded is installed and compiled, it will automatically begin working the next time you start vim. In order for color_coded to know how your code must be compiled, you _may_ need to create a file describing the required compiler options. Note, color_coded assumes sane defaults and tries to allow for immediate usage.\n\nThat said, in any non-trivial case, you'll find yourself needing to supply a `.color_coded` file for your project. For each file, color_coded will search from the file's directory all the way up to the root of the filesystem looking for a `.color_coded` file or a `.color_coded_foo` file (where `foo` is the filetype; i.e. `c`, `cpp`, etc). This makes it possible for you to have one in your home directory, for example, and then in each of your projects' directories. If you don't specify one in a project directory, the one in your home directory is used. It also makes it possible to provide different flags for differen file types (C, C++, etc) and also work in subprojects with different flags. Again, if no such files are found, sane defaults will be applied.\n\n**color_coded will try its hardest to highlight your code for you, even if there are errors in the translation unit.** This allows for better highlighting while typing and highlighting of valid code when color_coded doesn't know everything about your project.\n\n### .color_coded file contents\nThe contents of a `.color_coded` or `.color_coded_foo` file is simply a line-separated list of compiler options. For example, the `.color_coded` file for color_coded is (color_coded puts the rest in by default when it detects C or C++ files):\n\n```\n-Iinclude\n-Ilib/jest/include\n```\n\nThe `.color_coded` file can be automatically generated using [YCM-Generator](https://github.com/rdnetto/YCM-Generator).\n\n**NOTE:** Out of simplicity, no other data is permitted in the `.color_coded` file. That is to say, comments are not supported.\n\nOptions\n---\n\n#### `g:color_coded_enabled`\nThis option controls whether or not color_coded will function. Invoking the `:CCtoggle` command will modify this option to achieve its results. You may also specify it as `0` in your `~/.vimrc` to globally disable color_coded.\n\nDefault:\n```viml\nlet g:color_coded_enabled = 1\n```\n\n#### `g:color_coded_filetypes`\nThis option controls the filetypes which color_coded will try to compile.\n\nDefault:\n```viml\nlet g:color_coded_filetypes = ['c', 'cpp', 'objc']\n```\n\nHighlighting\n---\nThere are many new highlighting groups which color_coded adds. They are designed to follow [libclang's internals](http://clang.llvm.org/doxygen/group__CINDEX.html#gaaccc432245b4cd9f2d470913f9ef0013) as closely as possible. To tie things together, some wrapper groups have been created that will allow more sweeping changes. The clang groups, by default, are mapped to use these, along with vim's normal groups (`Function`, `Macro`, `Number`, etc).\n\n#### Generic groups\n```viml\n\" To get full highlighting, specify these in your colorscheme.\n\" See colors/twilighted.vim for example usage\n\nhi Member \" Any non-static member variable\nhi Variable \" Any non-member variable\nhi Namespace\nhi EnumConstant\n```\n\n#### Example of clang groups\n```viml\nhi link StructDecl Type\nhi link UnionDecl Type\nhi link ClassDecl Type\nhi link EnumDecl Type\n```\n\n#### Sample colorscheme\ncolor_coded ships with a sample color scheme demonstrating support for the extended groups. To use it, invoke `:colorscheme twilighted`. As the name may suggest, the colorscheme is forked from vim's own twilight theme and has been appropriately punned into that which you'll see in the repo. To examine the implementation, visit `colors/twilighted.vim`. Note that color_coded can work with any colorscheme; this is just a sample.\n\nFor more information on all of the supported groups, see `after/syntax/color_coded.vim` and the [clang documentation](http://clang.llvm.org/doxygen/group__CINDEX.html#gaaccc432245b4cd9f2d470913f9ef0013).\n\nCommands\n---\n\n#### `:CCerror`\nThis command outputs the last compilation error message from libclang. If your highlighting is not working properly, you may have a misconfigured `.color_coded` file or you may have syntax errors in your source. When in doubt, check here first.\n\n#### `:CCtoggle`\nThis command enables color_coded, if it's currently disabled, or disables it, if it's currently enabled. This enable/disabling is done via the `g:color_coded_enabled` option.\n\nDependencies\n---\nCompilation of color_coded requires:\n  * GCC ≥ 4.9\n  * Lua ≥ 5.1.x (using the version with which vim was compiled)\n\nUsage of color_coded requires vim:\n  * Version: 7.4p330+\n  * Compiled with Lua support (+lua)\n\nTroubleshooting/FAQ\n---\n\n#### As I type, the highlighting becomes messed up\ncolor_coded tries to compile your coded as you type it. Due to how vim works, color_coded can only update the highlighting once you do something (move the cursor, make a change, etc). When you're done typing and the highlighting has not finished updating, assuming your `.color_coded` file is sufficient, moving the cursor (or causing events some other way) will allow color_coded to finish.\n\nNote, there is a hold event in vim which triggers *after* you stop typing and *after* some delay. color_coded also hooks into this and will use it to apply highlighting if possible.\n\n#### Some bits aren't highlighted or are highlighted incorrectly\nYup. Believe it or not, these are almost certainly libclang bugs. I've been sorting out a few of them and I'm maintaining my own fork of libclang. If you would like to report such an issue, check out [this ticket](https://github.com/jeaye/color_coded/issues/2).\n\n#### The highlighting isn't refreshed in a new buffer until I move the cursor\nThis is intentional. The first time you open a buffer, color_coded doesn't know if it's going to compile properly and it doesn't want you to wait while it tries to figure this out. color_coded will always compile in the background and events like moving the cursor or changing text will poll for updates. **Note, however,** that, once a buffer has highlighting, leaving that buffer and coming back to it will synchronously apply the previous highlighting.\n\n#### \"color_coded unavailable: you need to compile it\"\nWhen you install color_coded, you need to manually compile it before you can successfully use it. See [Installation](https://github.com/jeaye/color_coded#installation) for instructions.\n\n#### \"color_coded has been updated: you need to recompile it\"\nAssuming you've updated a working installation of color_coded, you'll get this error if the update requires you to recompile color_coded (i.e. there have been changes to the native API). To recompile, follow the [same exact steps](https://github.com/jeaye/color_coded#installation) you took to compile initially.\n\n#### Does color_coded work with neovim?\nFor now, at least, color_coded is not supporting neovim. There is [chromatica.vim](https://github.com/arakashic/chromatica.nvim), however, which aims to provide similar highlighting, specifically for neovim.\n\n#### 'stdarg.h' file not found\nThis happens on certain operating systems which require additional include\npaths; the solution is to just make sure these paths are in your `.color_coded`\nfile, prefixed with `-isystem`. To find out those paths, run the following:\n\n```bash\necho | clang -v -E -x c++ -\n```\n\nSee [this issue comment](https://github.com/jeaye/color_coded/issues/140#issuecomment-255614113) for details. color_coded tries to help by assuming some of these, as shown in `post_constants()` [here](https://github.com/jeaye/color_coded/blob/master/include/conf/defaults.hpp).\n\n#### color_coded crashes on startup?!?!\nYou're likely using luajit, which doesn't embed well in shared libraries. If you aren't sure, see if this turns up anything:\n```bash\nvim --version | grep jit\n```\n[More information is here](https://www.freelists.org/post/luajit/OSx-load-luajit-64bit-from-plugin).\n\n#### How can I disable color_coded in diff mode?\nYou can use this in your `.vimrc`:\n\n```viml\n\" Disable color_coded in diff mode\nif \u0026diff\n  let g:color_coded_enabled = 0\nendif\n```\n\n#### How can I use a custom LLVM/Clang setup?\nYou may specify `DOWNLOAD_CLANG=0` to `cmake`. Depending on your platform, you\nmay also need to specify the path to your llvm-config binary using\n`LLVM_CONFIG=`. This can also allow you to use different versions of Clang/LLVM.\n\nExample:\n```bash\ncmake . -DDOWNLOAD_CLANG=0\n```\n\n#### \"no version information available (required by gvim)\"\nYou may run into this on Debian-based systems. [The solution](https://github.com/jeaye/color_coded/issues/83) has been to install `liblua-5.x-0-dbg`.\n\n#### \"E315: ml_get: invalid lnum: 32\"\nThis is caused by a bug in vim; you can work around it by using a vim with at\nleast patch 1691. See [this issue](https://github.com/jeaye/color_coded/issues/112) for details.\n\n#### How can I get support?\nFeel free to make an issue on Github or email me or catch me on IRC: Freenode @ `#color_coded`\n\nLicense\n---\ncolor_coded is under the MIT open-source license.  \nSee the `LICENSE` file or http://opensource.org/licenses/MIT\n","funding_links":[],"categories":["TODO scan for Android support in followings","Integrated Development Environment","C++","排序"],"sub_categories":["集成开发环境"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeaye%2Fcolor_coded","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeaye%2Fcolor_coded","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeaye%2Fcolor_coded/lists"}