2017-12-03 23:21:00 +08:00
|
|
|
---
|
|
|
|
title: "SpaceVim lang#c layer"
|
2019-02-03 20:51:01 +08:00
|
|
|
description: "C/C++/Object-C language support for SpaceVim, include code completion, jump to definition, quick runner."
|
2017-12-03 23:21:00 +08:00
|
|
|
---
|
|
|
|
|
2018-06-23 14:37:41 +08:00
|
|
|
# [Available Layers](../../) >> lang#c
|
2017-12-03 23:21:00 +08:00
|
|
|
|
|
|
|
<!-- vim-markdown-toc GFM -->
|
|
|
|
|
|
|
|
- [Description](#description)
|
2018-05-12 19:01:00 +08:00
|
|
|
- [Install](#install)
|
2017-12-24 20:43:20 +08:00
|
|
|
- [Features](#features)
|
2017-12-03 23:42:37 +08:00
|
|
|
- [Configuration](#configuration)
|
2018-05-12 19:01:00 +08:00
|
|
|
- [Key bindings](#key-bindings)
|
2017-12-03 23:21:00 +08:00
|
|
|
|
|
|
|
<!-- vim-markdown-toc -->
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
2018-05-12 19:01:00 +08:00
|
|
|
`lang#c` layer provides c/c++/object-c language support for SpaceVim.
|
2017-12-03 23:21:00 +08:00
|
|
|
|
2018-05-12 19:01:00 +08:00
|
|
|
## Install
|
2017-12-03 23:21:00 +08:00
|
|
|
|
2020-04-10 19:11:25 +08:00
|
|
|
To use this configuration layer, update the custom configuration file with:
|
2018-06-23 14:37:41 +08:00
|
|
|
|
|
|
|
```toml
|
|
|
|
[[layers]]
|
|
|
|
name = "lang#c"
|
|
|
|
```
|
2017-12-03 23:21:00 +08:00
|
|
|
|
2017-12-24 20:43:20 +08:00
|
|
|
## Features
|
|
|
|
|
|
|
|
- code completion
|
|
|
|
- syntax checking
|
|
|
|
- formatting
|
|
|
|
|
2017-12-03 23:42:37 +08:00
|
|
|
## Configuration
|
|
|
|
|
2019-04-13 13:56:41 +08:00
|
|
|
- `enable_clang_syntax_highlight` (boolean)
|
|
|
|
|
|
|
|
Enable/Disable clang based syntax highlighting.
|
|
|
|
|
2017-12-03 23:42:37 +08:00
|
|
|
- `clang_executable` (string)
|
|
|
|
|
2018-06-23 14:37:41 +08:00
|
|
|
Set the path to the clang executable
|
2017-12-03 23:42:37 +08:00
|
|
|
|
|
|
|
- `libclang_path` (string)
|
|
|
|
|
2019-02-03 20:51:01 +08:00
|
|
|
The libclang shared object (dynamic library) file path. By default it is empty.
|
2017-12-03 23:42:37 +08:00
|
|
|
|
|
|
|
- `clang_std` (dict)
|
|
|
|
|
2018-06-23 14:37:41 +08:00
|
|
|
A dict containing the standards you want to use. The default is:
|
|
|
|
|
2017-12-03 23:42:37 +08:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"c": "c11",
|
|
|
|
"cpp": "c++1z",
|
|
|
|
"objc": "c11",
|
|
|
|
"objcpp": "c++1z",
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2020-09-29 00:35:18 +08:00
|
|
|
- `clang_flag` (list)
|
2017-12-04 00:28:21 +08:00
|
|
|
|
2020-09-29 00:35:18 +08:00
|
|
|
You should be able to just paste most of your compile flags in there.
|
|
|
|
You can also use a list ['-Iwhatever', ...] when loading this layer.
|
2018-05-12 19:01:00 +08:00
|
|
|
|
2019-02-03 20:51:01 +08:00
|
|
|
Here is an example how to use above options:
|
2018-06-23 14:37:41 +08:00
|
|
|
|
|
|
|
```toml
|
|
|
|
[[layers]]
|
|
|
|
name = "lang#c"
|
|
|
|
clang_executable = "/usr/bin/clang"
|
2020-09-29 00:35:18 +08:00
|
|
|
clang_flag = ['-I/user/include']
|
2018-06-23 14:37:41 +08:00
|
|
|
[layer.clang_std]
|
|
|
|
c = "c11"
|
|
|
|
cpp = "c++1z"
|
|
|
|
objc = "c11"
|
|
|
|
objcpp = "c++1z"
|
|
|
|
```
|
|
|
|
|
2020-09-29 00:35:18 +08:00
|
|
|
Instead of using `clang_flag` options, You can also create a `.clang` file
|
|
|
|
in the root directory of your project. SpaceVim will load the options
|
|
|
|
defined in `.clang` file. For example:
|
|
|
|
|
|
|
|
```
|
|
|
|
-std=c11
|
|
|
|
-I/home/test
|
|
|
|
```
|
|
|
|
|
|
|
|
Note: If `.clang` file contains std configuration, it will override
|
|
|
|
`clang_std` layer option.
|
2018-06-23 14:37:41 +08:00
|
|
|
|
2018-05-12 19:01:00 +08:00
|
|
|
## Key bindings
|
|
|
|
|
2019-02-03 20:51:01 +08:00
|
|
|
| key bindings | Descriptions |
|
|
|
|
| ------------ | ---------------------------- |
|
|
|
|
| `SPC l d` | show documentation |
|
|
|
|
| `SPC l e` | rename symbol |
|
|
|
|
| `SPC l f` | references |
|
|
|
|
| `SPC l r` | compile and run current file |
|
|
|
|
| `g d` | defintion preview |
|