From 4a4b5e8fb6487353cd9e53b5e04286eb264b6700 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 3 Dec 2017 23:21:00 +0800 Subject: [PATCH 1/4] Update lang#c layer --- autoload/SpaceVim/layers/lang/c.vim | 15 ++++++++++++++- docs/layers/lang/c.md | 26 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 docs/layers/lang/c.md diff --git a/autoload/SpaceVim/layers/lang/c.vim b/autoload/SpaceVim/layers/lang/c.vim index 652c891bb..d0103ac9c 100644 --- a/autoload/SpaceVim/layers/lang/c.vim +++ b/autoload/SpaceVim/layers/lang/c.vim @@ -40,10 +40,16 @@ +let s:use_libclang = 0 + function! SpaceVim#layers#lang#c#plugins() abort let plugins = [] if has('nvim') - call add(plugins, ['tweekmonster/deoplete-clang2']) + if s:use_libclang + call add(plugins, ['zchee/deoplete-clang']) + else + call add(plugins, ['tweekmonster/deoplete-clang2']) + endif else call add(plugins, ['Rip-Rip/clang_complete']) endif @@ -56,6 +62,13 @@ function! SpaceVim#layers#lang#c#config() abort call SpaceVim#mapping#space#regesit_lang_mappings('c', funcref('s:language_specified_mappings')) endfunction +function! SpaceVim#layers#lang#c#set_variable(var) abort + " use clang or libclang + let s:use_libclang = get(a:var, + \ 'use_libclang', + \ 'clang') +endfunction + function! s:language_specified_mappings() abort call SpaceVim#mapping#space#langSPC('nmap', ['l','r'], diff --git a/docs/layers/lang/c.md b/docs/layers/lang/c.md new file mode 100644 index 000000000..91a8ef9dd --- /dev/null +++ b/docs/layers/lang/c.md @@ -0,0 +1,26 @@ +--- +title: "SpaceVim lang#c layer" +description: "This layer is for c/c++/object-c development" +--- + +# [Layers](https://spacevim.org/layers) > lang#c + + + + +- [Description](#description) +- [Layer Installation](#layer-installation) +- [Key bindings](#key-bindings) + + + +## Description + +This layer is for c/c++/object-c development. + +## Layer Installation + +To use this configuration layer, add `SPLayer 'lang#java'` to your custom configuration file. + +## Key bindings + From e6c36a21466a01124fd2b6cbb288db0794271c5f Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 3 Dec 2017 23:42:37 +0800 Subject: [PATCH 2/4] Update doc --- docs/layers/lang/c.md | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/docs/layers/lang/c.md b/docs/layers/lang/c.md index 91a8ef9dd..c839c6211 100644 --- a/docs/layers/lang/c.md +++ b/docs/layers/lang/c.md @@ -10,7 +10,7 @@ description: "This layer is for c/c++/object-c development" - [Description](#description) - [Layer Installation](#layer-installation) -- [Key bindings](#key-bindings) +- [Configuration](#configuration) @@ -20,7 +20,39 @@ This layer is for c/c++/object-c development. ## Layer Installation -To use this configuration layer, add `SPLayer 'lang#java'` to your custom configuration file. +To use this configuration layer, add `SPLayer 'lang#c'` to your custom configuration file or load layer with custom options. -## Key bindings +```vim +call SpaceVim#layers#load('lang#c', + \ { + \ 'enable_libclang' : 1, + \ } + \ ) +``` +## Configuration + +- `clang_executable` (string) + +set the path to the clang executable + +- `enable_libclang` (boolean) + +use libclang instead of `clang -cc1`, by default it is 0. + +- `libclang_path` (string) + +The libclang shared object (dynamic library) file path. by default it is empty. + +- `clang_std` (dict) + +```json +{ + "c": "c11", + "cpp": "c++1z", + "objc": "c11", + "objcpp": "c++1z", +} +``` + +- `clang_flag` From 148649b669f8666807cdcfd4d2a570290e16c429 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Mon, 4 Dec 2017 00:28:21 +0800 Subject: [PATCH 3/4] Update doc --- docs/layers/lang/c.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/layers/lang/c.md b/docs/layers/lang/c.md index c839c6211..97025cb40 100644 --- a/docs/layers/lang/c.md +++ b/docs/layers/lang/c.md @@ -56,3 +56,5 @@ The libclang shared object (dynamic library) file path. by default it is empty. ``` - `clang_flag` + +Create a `.clang` file at your project root. You should be able to just paste most of your compile flags in there. You can also use a list ['-Iwhatever', ...] when loadding this layer. From cb3e340ec7c12fb8fef47006ef7f69ae591883f0 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Mon, 4 Dec 2017 00:32:46 +0800 Subject: [PATCH 4/4] Add config for completor and clang2 --- autoload/SpaceVim/layers/lang/c.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/autoload/SpaceVim/layers/lang/c.vim b/autoload/SpaceVim/layers/lang/c.vim index d0103ac9c..f37595254 100644 --- a/autoload/SpaceVim/layers/lang/c.vim +++ b/autoload/SpaceVim/layers/lang/c.vim @@ -67,6 +67,11 @@ function! SpaceVim#layers#lang#c#set_variable(var) abort let s:use_libclang = get(a:var, \ 'use_libclang', \ 'clang') + + if has_key(a:var, 'clang_executable') + let g:completor_clang_binary = a:var.clang_executable + let g:deoplete#sources#clang#executable = a:var.clang_executable + endif endfunction function! s:language_specified_mappings() abort