mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 02:00:05 +08:00
Improve lang#c layer (#2440)
* Enhance c/c++ layer * Update c/c++ layer documentation
This commit is contained in:
parent
1b019977b9
commit
e01c97049e
@ -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
|
||||
|
@ -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 |
|
||||
|
Loading…
Reference in New Issue
Block a user