1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 06:30:03 +08:00
SpaceVim/docs/layers/lang/c.md

104 lines
2.2 KiB
Markdown
Raw Normal View History

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)
- [Install](#install)
2017-12-24 20:43:20 +08:00
- [Features](#features)
2017-12-03 23:42:37 +08:00
- [Configuration](#configuration)
- [Key bindings](#key-bindings)
2017-12-03 23:21:00 +08:00
<!-- vim-markdown-toc -->
## Description
`lang#c` layer provides c/c++/object-c language support for SpaceVim.
2017-12-03 23:21: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
- `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",
}
```
- `clang_flag` (list)
2017-12-04 00:28:21 +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.
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"
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"
```
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
## 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 |