mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 17:20:04 +08:00
feat(lang#c): update lsp key binding for lang#c
layer
This commit is contained in:
parent
a5b08d26ca
commit
29dcb31e47
@ -65,10 +65,12 @@
|
|||||||
" `clang_std` layer option.
|
" `clang_std` layer option.
|
||||||
"
|
"
|
||||||
" @subsection Key bindings
|
" @subsection Key bindings
|
||||||
|
"
|
||||||
" >
|
" >
|
||||||
" Mode Key Function
|
" Key Function
|
||||||
" ---------------------------------------------
|
" --------------------------------
|
||||||
" normal SPC l r run current file
|
" SPC l r run current file
|
||||||
|
" g d jump to definition
|
||||||
" <
|
" <
|
||||||
"
|
"
|
||||||
" This layer also provides REPL support for c, the key bindings are:
|
" This layer also provides REPL support for c, the key bindings are:
|
||||||
@ -81,6 +83,22 @@
|
|||||||
" SPC l s s send selection text
|
" SPC l s s send selection text
|
||||||
" <
|
" <
|
||||||
"
|
"
|
||||||
|
" If the lsp layer is enabled for c/c++, the following key bindings can
|
||||||
|
" be used:
|
||||||
|
" >
|
||||||
|
" key binding Description
|
||||||
|
" --------------------------------
|
||||||
|
" g D jump to declaration
|
||||||
|
" SPC l e rename symbol
|
||||||
|
" SPC l x show references
|
||||||
|
" SPC l h show line diagnostics
|
||||||
|
" SPC l d show document
|
||||||
|
" K show document
|
||||||
|
" SPC l w l list workspace folder
|
||||||
|
" SPC l w a add workspace folder
|
||||||
|
" SPC l w r remove workspace folder
|
||||||
|
" <
|
||||||
|
"
|
||||||
" Known issue:
|
" Known issue:
|
||||||
"
|
"
|
||||||
" You need to use `flush(stdout)` before `scanf()` when run code in code
|
" You need to use `flush(stdout)` before `scanf()` when run code in code
|
||||||
@ -301,25 +319,26 @@ function! s:language_specified_mappings() abort
|
|||||||
\ 'call SpaceVim#plugins#runner#open()',
|
\ 'call SpaceVim#plugins#runner#open()',
|
||||||
\ 'execute current file', 1)
|
\ 'execute current file', 1)
|
||||||
if SpaceVim#layers#lsp#check_filetype('c')
|
if SpaceVim#layers#lsp#check_filetype('c')
|
||||||
|
\ || SpaceVim#layers#lsp#check_server('clangd')
|
||||||
nnoremap <silent><buffer> K :call SpaceVim#lsp#show_doc()<CR>
|
nnoremap <silent><buffer> K :call SpaceVim#lsp#show_doc()<CR>
|
||||||
|
|
||||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'],
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'],
|
||||||
\ 'call SpaceVim#lsp#show_doc()', 'show_document', 1)
|
\ 'call SpaceVim#lsp#show_doc()', 'show_document', 1)
|
||||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'],
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'],
|
||||||
\ 'call SpaceVim#lsp#rename()', 'rename symbol', 1)
|
\ 'call SpaceVim#lsp#rename()', 'rename symbol', 1)
|
||||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'f'],
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'x'],
|
||||||
\ 'call SpaceVim#lsp#references()', 'references', 1)
|
\ 'call SpaceVim#lsp#references()', 'show-references', 1)
|
||||||
|
|
||||||
" these work for now with coc.nvim only
|
|
||||||
|
|
||||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'i'],
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'i'],
|
||||||
\ 'call SpaceVim#lsp#go_to_impl()', 'implementation', 1)
|
\ 'call SpaceVim#lsp#go_to_impl()', 'implementation', 1)
|
||||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 't'],
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'h'],
|
||||||
\ 'call SpaceVim#lsp#go_to_typedef()', 'type definition', 1)
|
\ 'call SpaceVim#lsp#show_line_diagnostics()', 'show-line-diagnostics', 1)
|
||||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'R'],
|
let g:_spacevim_mappings_space.l.w = {'name' : '+Workspace'}
|
||||||
\ 'call SpaceVim#lsp#refactor()', 'refactor', 1)
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'w', 'l'],
|
||||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'D'],
|
\ 'call SpaceVim#lsp#list_workspace_folder()', 'list-workspace-folder', 1)
|
||||||
\ 'call SpaceVim#lsp#go_to_declaration()', 'declaration', 1)
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'w', 'a'],
|
||||||
|
\ 'call SpaceVim#lsp#add_workspace_folder()', 'add-workspace-folder', 1)
|
||||||
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'w', 'r'],
|
||||||
|
\ 'call SpaceVim#lsp#remove_workspace_folder()', 'remove-workspace-folder', 1)
|
||||||
|
|
||||||
endif
|
endif
|
||||||
let g:_spacevim_mappings_space.l.s = {'name' : '+Send'}
|
let g:_spacevim_mappings_space.l.s = {'name' : '+Send'}
|
||||||
@ -463,6 +482,7 @@ endfunction
|
|||||||
" local function: go_to_declaration {{{
|
" local function: go_to_declaration {{{
|
||||||
function! s:go_to_declaration() abort
|
function! s:go_to_declaration() abort
|
||||||
if !SpaceVim#layers#lsp#check_filetype(&ft)
|
if !SpaceVim#layers#lsp#check_filetype(&ft)
|
||||||
|
\ && !SpaceVim#layers#lsp#check_server('clangd')
|
||||||
try
|
try
|
||||||
exe 'ts' expand('<cword>')
|
exe 'ts' expand('<cword>')
|
||||||
catch /^Vim\%((\a\+)\)\=:E426/
|
catch /^Vim\%((\a\+)\)\=:E426/
|
||||||
@ -479,6 +499,7 @@ endfunction
|
|||||||
" local function: go_to_def {{{
|
" local function: go_to_def {{{
|
||||||
function! s:go_to_def() abort
|
function! s:go_to_def() abort
|
||||||
if !SpaceVim#layers#lsp#check_filetype(&ft)
|
if !SpaceVim#layers#lsp#check_filetype(&ft)
|
||||||
|
\ && !SpaceVim#layers#lsp#check_server('clangd')
|
||||||
try
|
try
|
||||||
exe 'ts' expand('<cword>')
|
exe 'ts' expand('<cword>')
|
||||||
catch /^Vim\%((\a\+)\)\=:E426/
|
catch /^Vim\%((\a\+)\)\=:E426/
|
||||||
|
@ -2394,10 +2394,12 @@ Note: If `.clang` file contains std configuration, it will override
|
|||||||
|
|
||||||
KEY BINDINGS
|
KEY BINDINGS
|
||||||
|
|
||||||
|
|
||||||
>
|
>
|
||||||
Mode Key Function
|
Key Function
|
||||||
---------------------------------------------
|
--------------------------------
|
||||||
normal SPC l r run current file
|
SPC l r run current file
|
||||||
|
g d jump to definition
|
||||||
<
|
<
|
||||||
|
|
||||||
This layer also provides REPL support for c, the key bindings are:
|
This layer also provides REPL support for c, the key bindings are:
|
||||||
@ -2410,6 +2412,21 @@ This layer also provides REPL support for c, the key bindings are:
|
|||||||
SPC l s s send selection text
|
SPC l s s send selection text
|
||||||
<
|
<
|
||||||
|
|
||||||
|
If the lsp layer is enabled for c/c++, the following key bindings can be used:
|
||||||
|
>
|
||||||
|
key binding Description
|
||||||
|
--------------------------------
|
||||||
|
g D jump to declaration
|
||||||
|
SPC l e rename symbol
|
||||||
|
SPC l x show references
|
||||||
|
SPC l h show line diagnostics
|
||||||
|
SPC l d show document
|
||||||
|
K show document
|
||||||
|
SPC l w l list workspace folder
|
||||||
|
SPC l w a add workspace folder
|
||||||
|
SPC l w r remove workspace folder
|
||||||
|
<
|
||||||
|
|
||||||
Known issue:
|
Known issue:
|
||||||
|
|
||||||
You need to use `flush(stdout)` before `scanf()` when run code in code runner.
|
You need to use `flush(stdout)` before `scanf()` when run code in code runner.
|
||||||
|
@ -12,6 +12,10 @@ description: "C/C++/Object-C language support for SpaceVim, including code compl
|
|||||||
- [Features](#features)
|
- [Features](#features)
|
||||||
- [Configuration](#configuration)
|
- [Configuration](#configuration)
|
||||||
- [Key bindings](#key-bindings)
|
- [Key bindings](#key-bindings)
|
||||||
|
- [Jump to definition](#jump-to-definition)
|
||||||
|
- [Running current script](#running-current-script)
|
||||||
|
- [Inferior REPL process](#inferior-repl-process)
|
||||||
|
- [LSP key Bindings](#lsp-key-bindings)
|
||||||
|
|
||||||
<!-- vim-markdown-toc -->
|
<!-- vim-markdown-toc -->
|
||||||
|
|
||||||
@ -55,10 +59,10 @@ A dict containing the standards you want to use. The default is:
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"c": "c11",
|
"c": "c11",
|
||||||
"cpp": "c++1z",
|
"cpp": "c++1z",
|
||||||
"objc": "c11",
|
"objc": "c11",
|
||||||
"objcpp": "c++1z",
|
"objcpp": "c++1z"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -95,18 +99,51 @@ Note: If `.clang` file contains std configuration, it will override
|
|||||||
|
|
||||||
`format_on_save`: Enable/disable file formatting when saving current file. By default,
|
`format_on_save`: Enable/disable file formatting when saving current file. By default,
|
||||||
it is disabled, to enable it:
|
it is disabled, to enable it:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[[layers]]
|
[[layers]]
|
||||||
name = 'lang#c'
|
name = 'lang#c'
|
||||||
format_on_save = true
|
format_on_save = true
|
||||||
```
|
```
|
||||||
|
|
||||||
## Key bindings
|
## Key bindings
|
||||||
|
|
||||||
| key bindings | Descriptions |
|
### Jump to definition
|
||||||
| ------------ | -------------------------------- |
|
|
||||||
| `SPC l d` | show documentation |
|
| Mode | Key Bindings | Description |
|
||||||
| `SPC l e` | rename symbol |
|
| ------ | ------------ | ------------------------------------------------ |
|
||||||
| `SPC l f` | references |
|
| normal | `g d` | Jump to the definition position of cursor symbol |
|
||||||
| `SPC l r` | compile and run the current file |
|
|
||||||
| `g d` | defintion preview |
|
### Running current script
|
||||||
|
|
||||||
|
To run current file, you can press `SPC l r` to run the current file without losing focus,
|
||||||
|
and the result will be shown in a runner buffer.
|
||||||
|
|
||||||
|
### Inferior REPL process
|
||||||
|
|
||||||
|
Start a `igcc` inferior REPL process with `SPC l s i`.
|
||||||
|
|
||||||
|
Send code to inferior process commands:
|
||||||
|
|
||||||
|
| Key Bindings | Descriptions |
|
||||||
|
| ------------ | ------------------------------------------------ |
|
||||||
|
| `SPC l s b` | send buffer and keep code buffer focused |
|
||||||
|
| `SPC l s l` | send line and keep code buffer focused |
|
||||||
|
| `SPC l s s` | send selection text and keep code buffer focused |
|
||||||
|
|
||||||
|
### LSP key Bindings
|
||||||
|
|
||||||
|
If the lsp layer is enabled for C/C++, the following key bindings can
|
||||||
|
be used:
|
||||||
|
|
||||||
|
| key binding | Description |
|
||||||
|
| ----------- | ----------------------- |
|
||||||
|
| `g D` | jump to declaration |
|
||||||
|
| `SPC l e` | rename symbol |
|
||||||
|
| `SPC l x` | show references |
|
||||||
|
| `SPC l s` | show line diagnostics |
|
||||||
|
| `SPC l d` | show document |
|
||||||
|
| `K` | show document |
|
||||||
|
| `SPC l w l` | list workspace folder |
|
||||||
|
| `SPC l w a` | add workspace folder |
|
||||||
|
| `SPC l w r` | remove workspace folder |
|
||||||
|
Loading…
Reference in New Issue
Block a user