1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 23:20:04 +08:00

Improve lang#c layer (#2440)

* Enhance c/c++ layer

* Update c/c++ layer documentation
This commit is contained in:
Chen Lijun 2019-01-08 17:37:42 +01:00 committed by Wang Shidong
parent 1b019977b9
commit e01c97049e
2 changed files with 17 additions and 0 deletions

View File

@ -88,6 +88,10 @@ function! SpaceVim#layers#lang#c#plugins() abort
endfunction
function! SpaceVim#layers#lang#c#config() abort
call SpaceVim#mapping#gd#add('c',
\ function('s:go_to_def'))
call SpaceVim#mapping#gd#add('cpp',
\ function('s:go_to_def'))
call SpaceVim#plugins#runner#reg_runner('c', ['gcc -o #TEMP# %s', '#TEMP#'])
call SpaceVim#mapping#space#regesit_lang_mappings('c', function('s:language_specified_mappings'))
call SpaceVim#plugins#runner#reg_runner('cpp', ['g++ -o #TEMP# %s', '#TEMP#'])
@ -130,6 +134,8 @@ function! s:language_specified_mappings() abort
\ 'call SpaceVim#lsp#show_doc()', 'show_document', 1)
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'],
\ 'call SpaceVim#lsp#rename()', 'rename symbol', 1)
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'f'],
\ 'call SpaceVim#lsp#references()', 'references', 1)
endif
endfunction
@ -194,3 +200,10 @@ function! s:update_neoinclude(argv, fts) abort
let b:neoinclude_paths = path
endfunction
function! s:go_to_def() abort
if !SpaceVim#layers#lsp#check_filetype(&ft)
execute "norm! g\<c-]>"
else
call SpaceVim#lsp#go_to_def()
endif
endfunction

View File

@ -80,4 +80,8 @@ here is an example how to use above options:
| key binding | description |
| ----------- | ---------------------------- |
| `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 |