mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-13 02:05:40 +08:00
Add doc for complete layer
This commit is contained in:
parent
b29d5639e1
commit
bfe54b9af2
@ -165,17 +165,6 @@ endfunction
|
||||
|
||||
function! SpaceVim#default#SetMappings() abort
|
||||
|
||||
"mapping
|
||||
imap <silent><expr><TAB> SpaceVim#mapping#tab#i_tab()
|
||||
imap <expr><S-TAB> pumvisible() ? "\<C-p>" : ""
|
||||
imap <silent><expr><S-TAB> SpaceVim#mapping#shift_tab()
|
||||
smap <expr><TAB> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : (complete_parameter#jumpable(1) ? "\<plug>(complete_parameter#goto_next_parameter)" : "\<TAB>")
|
||||
imap <silent><expr><CR> SpaceVim#mapping#enter#i_enter()
|
||||
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
|
||||
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
|
||||
inoremap <expr> <PageDown> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<PageDown>"
|
||||
inoremap <expr> <PageUp> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<PageUp>"
|
||||
smap <expr><S-TAB> pumvisible() ? "\<C-p>" : ""
|
||||
" Save a file with sudo
|
||||
" http://forrst.com/posts/Use_w_to_sudo_write_a_file_with_Vim-uAN
|
||||
cnoremap w!! %!sudo tee > /dev/null %
|
||||
|
@ -19,7 +19,6 @@
|
||||
" SpaceVim will not append `./.SpaceVim/snippets` as default snippets directory.
|
||||
|
||||
|
||||
|
||||
function! SpaceVim#layers#autocomplete#plugins() abort
|
||||
let plugins = [
|
||||
\ ['honza/vim-snippets', { 'on_event' : 'InsertEnter', 'loadconf_before' : 1}],
|
||||
@ -72,6 +71,36 @@ function! SpaceVim#layers#autocomplete#config() abort
|
||||
endif
|
||||
let g:delimitMate_matchpairs = '[:],{:},<:>'
|
||||
inoremap <silent><expr> ( complete_parameter#pre_complete("()")
|
||||
"mapping
|
||||
imap <silent><expr><TAB> SpaceVim#mapping#tab#i_tab()
|
||||
imap <expr><S-TAB> pumvisible() ? "\<C-p>" : ""
|
||||
imap <silent><expr><S-TAB> SpaceVim#mapping#shift_tab()
|
||||
smap <expr><TAB> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : (complete_parameter#jumpable(1) ? "\<plug>(complete_parameter#goto_next_parameter)" : "\<TAB>")
|
||||
imap <silent><expr><CR> SpaceVim#mapping#enter#i_enter()
|
||||
smap <expr><S-TAB> pumvisible() ? "\<C-p>" : ""
|
||||
|
||||
|
||||
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
|
||||
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
|
||||
inoremap <expr> <PageDown> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<PageDown>"
|
||||
inoremap <expr> <PageUp> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<PageUp>"
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#autocomplete#set_variable(var)
|
||||
|
||||
let s:return_key_behavior = get(a:var,
|
||||
\ 'auto-completion-return-key-behavior',
|
||||
\ 'nil')
|
||||
let s:tab_key_behavior = get(a:var,
|
||||
\ 'auto-completion-tab-key-behavior',
|
||||
\ 'smart')
|
||||
let s:key_sequence = get(a:var,
|
||||
\ 'auto-completion-complete-with-key-sequence',
|
||||
\ 'nil')
|
||||
let s:key_sequence_delay = get(a:var,
|
||||
\ 'auto-completion-complete-with-key-sequence-delay',
|
||||
\ 0.1)
|
||||
|
||||
endfunction
|
||||
|
||||
|
||||
|
@ -9,6 +9,11 @@ title: "SpaceVim autocomplete layer"
|
||||
* [Install](#install)
|
||||
* [Configuration](#configuration)
|
||||
* [Key bindings](#key-bindings)
|
||||
* [Snippets directories](#snippets-directories)
|
||||
* [Show snippets in auto-completion popup](#show-snippets-in-auto-completion-popup)
|
||||
* [Key bindings](#key-bindings-1)
|
||||
* [auto-complete](#auto-complete)
|
||||
* [Neosnippet](#neosnippet)
|
||||
|
||||
<!-- vim-markdown-toc -->
|
||||
|
||||
@ -39,16 +44,72 @@ call SpaceVim#layers#load('autocomplete')
|
||||
|
||||
You can customize the user experience of auto-completion with the following layer variables:
|
||||
|
||||
1. `auto-completion-return-key-behavior` set the action to perform when the `RET` key is pressed, the possible values are:
|
||||
- `complete` completes with the current selection
|
||||
- `nil` does nothing
|
||||
2. `auto-completion-tab-key-behavior` set the action to perform when the `TAB` key is pressed, the possible values are:
|
||||
- `smart` cycle candidates, expand snippets, jump parameters
|
||||
- `complete` completes with the current selection
|
||||
- `cycle` completes the common prefix and cycle between candidates
|
||||
- `nil` does nothing
|
||||
3. `auto-completion-complete-with-key-sequence` is a string of two characters denoting a key sequence that will perform a `complete` action if the sequence as been entered quickly enough. If its value is `nil` then the feature is disabled.
|
||||
4. `auto-completion-complete-with-key-sequence-delay` is the number of seconds to wait for the auto-completion key sequence to be entered. The default value is 0.1 seconds.
|
||||
1. `auto-completion-return-key-behavior` set the action to perform when the `RET` key is pressed, the possible values are:
|
||||
|
||||
- `complete` completes with the current selection
|
||||
- `nil` does nothing
|
||||
|
||||
2. `auto-completion-tab-key-behavior` set the action to perform when the `TAB` key is pressed, the possible values are:
|
||||
|
||||
- `smart` cycle candidates, expand snippets, jump parameters
|
||||
- `complete` completes with the current selection
|
||||
- `cycle` completes the common prefix and cycle between candidates
|
||||
- `nil` does nothing
|
||||
|
||||
3. `auto-completion-complete-with-key-sequence` is a string of two characters denoting a key sequence that will perform a `complete` action if the sequence as been entered quickly enough. If its value is `nil` then the feature is disabled.
|
||||
4. `auto-completion-complete-with-key-sequence-delay` is the number of seconds to wait for the auto-completion key sequence to be entered. The default value is 0.1 seconds.
|
||||
|
||||
The default configuration of the layer is:
|
||||
|
||||
```vim
|
||||
call SpaceVim#layers#load('autocomplete', {
|
||||
\ 'auto-completion-return-key-behavior' : 'nil',
|
||||
\ 'auto-completion-tab-key-behavior' : 'smart',
|
||||
\ 'auto-completion-complete-with-key-sequence' : 'nil',
|
||||
\ 'auto-completion-complete-with-key-sequence-delay' : 0.1,
|
||||
\ })
|
||||
```
|
||||
|
||||
`jk` is a good candidate for `auto-completion-complete-with-key-sequence` if you don’t use it already.
|
||||
|
||||
### Snippets directories
|
||||
|
||||
The following snippets or directories are added by default:
|
||||
|
||||
- [Shougo/neosnippet-snippets](https://github.com/Shougo/neosnippet-snippets) : neosnippet's default snippets.
|
||||
- [honza/vim-snippets](https://github.com/honza/vim-snippets) : extra snippets
|
||||
- `~/.SpaceVim/snippets/` : SpaceVim runtime snippets.
|
||||
- `~/.SpaceVim.d/snippets/` : custom global snippets.
|
||||
- `./.SpaceVim.d/snippets/` : custom local snippets (project's snippets)
|
||||
|
||||
You can provide additional directories by setting the variable `g:neosnippet#snippets_directory` which can take a string in case of a single path or a list of paths.
|
||||
|
||||
### Show snippets in auto-completion popup
|
||||
|
||||
By default, snippets are shown in the auto-completion popup. To disable this feature, set the variable `auto-completion-enable-snippets-in-popup` to 0.
|
||||
|
||||
```vim
|
||||
call SpaceVim#layers#load('autocomplete', {
|
||||
\ 'auto-completion-enable-snippets-in-popup' : 0
|
||||
\ })
|
||||
```
|
||||
|
||||
## Key bindings
|
||||
|
||||
### auto-complete
|
||||
|
||||
| Key bindings | Description |
|
||||
| ------------ | -------------------------------------------------------------------- |
|
||||
| `<C-n>` | select next candidate |
|
||||
| `<C-p>` | select previous candidate |
|
||||
| `<Tab>` | expand selection or select next candidate |
|
||||
| `<S-Tab>` | select previous candidate |
|
||||
| `<Return>` | complete word, if word is already completed insert a carriage return |
|
||||
|
||||
### Neosnippet
|
||||
|
||||
| Key Binding | Description |
|
||||
| ----------- | -------------------------------------------------------------- |
|
||||
| `M-/` | Expand a snippet if text before point is a prefix of a snippet |
|
||||
| `SPC i s` | List all current yasnippets for inserting |
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user