From 5af5b0d5081bc9493744f9f31ac17cdc23ad412c Mon Sep 17 00:00:00 2001 From: Ben Anson Date: Thu, 11 Mar 2021 13:16:37 +0000 Subject: [PATCH] feat: add autocomplete toggle for deoplete (#4125) Signed-off-by: Ben Anson --- autoload/SpaceVim/layers/autocomplete.vim | 8 +++++ autoload/SpaceVim/layers/ui.vim | 4 +++ docs/documentation.md | 39 ++++++++++++----------- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/autoload/SpaceVim/layers/autocomplete.vim b/autoload/SpaceVim/layers/autocomplete.vim index 2f04041f0..93ac4bf45 100644 --- a/autoload/SpaceVim/layers/autocomplete.vim +++ b/autoload/SpaceVim/layers/autocomplete.vim @@ -249,6 +249,14 @@ function! SpaceVim#layers#autocomplete#getprfile() abort +endfunction + +function! SpaceVim#layers#autocomplete#toggle_deoplete() abort + if deoplete#custom#_get_option('auto_complete') + call deoplete#custom#option('auto_complete', v:false) + else + call deoplete#custom#option('auto_complete', v:true) + endif endfunction function! s:apply_sequence_delay() abort diff --git a/autoload/SpaceVim/layers/ui.vim b/autoload/SpaceVim/layers/ui.vim index c69321e66..87ab4863e 100644 --- a/autoload/SpaceVim/layers/ui.vim +++ b/autoload/SpaceVim/layers/ui.vim @@ -83,6 +83,10 @@ function! SpaceVim#layers#ui#config() abort call SpaceVim#mapping#space#def('nnoremap', ['t', '8'], 'call call(' \ . string(s:_function('s:toggle_fill_column')) . ', [])', \ 'highlight-long-lines', 1) + if g:spacevim_autocomplete_method ==# 'deoplete' + call SpaceVim#mapping#space#def('nnoremap', ['t', 'a'], 'call SpaceVim#layers#autocomplete#toggle_deoplete()', + \ 'toggle autocomplete', 1) + endif call SpaceVim#mapping#space#def('nnoremap', ['t', 'b'], 'call call(' \ . string(s:_function('s:toggle_background')) . ', [])', \ 'toggle background', 1) diff --git a/docs/documentation.md b/docs/documentation.md index b892bf100..3fce24f5e 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -528,25 +528,26 @@ Also note that changing this value has no effect if you are running Vim/Neovim i Some UI indicators can be toggled on and off (toggles start with t and T): -| Key Bindings | Descriptions | -| ------------ | -------------------------------------------------------- | -| `SPC t 8` | highlight any character past the 80th column | -| `SPC t f` | display the fill column (by default `max_column` is 120) | -| `SPC t h h` | toggle highlight of the current line | -| `SPC t h i` | toggle highlight indentation levels (TODO) | -| `SPC t h c` | toggle highlight indentation current column | -| `SPC t h s` | toggle syntax highlighting | -| `SPC t i` | toggle indentation guide at point | -| `SPC t n` | toggle line numbers | -| `SPC t b` | toggle background | -| `SPC t c` | toggle conceal | -| `SPC t p` | toggle paste mode | -| `SPC t t` | open tabs manager | -| `SPC T ~` | display ~ in the fringe on empty lines | -| `SPC T F` | toggle frame fullscreen | -| `SPC T f` | toggle display of the fringe | -| `SPC T m` | toggle menu bar | -| `SPC T t` | toggle tool bar | +| Key Bindings | Descriptions | +| ------------ | -------------------------------------------------------------------------- | +| `SPC t 8` | highlight any character past the 80th column | +| `SPC t a` | toggle autocomplete (only available with `autocomplete_method = deoplete`) | +| `SPC t f` | display the fill column (by default `max_column` is 120) | +| `SPC t h h` | toggle highlight of the current line | +| `SPC t h i` | toggle highlight indentation levels (TODO) | +| `SPC t h c` | toggle highlight indentation current column | +| `SPC t h s` | toggle syntax highlighting | +| `SPC t i` | toggle indentation guide at point | +| `SPC t n` | toggle line numbers | +| `SPC t b` | toggle background | +| `SPC t c` | toggle conceal | +| `SPC t p` | toggle paste mode | +| `SPC t t` | open tabs manager | +| `SPC T ~` | display ~ in the fringe on empty lines | +| `SPC T F` | toggle frame fullscreen | +| `SPC T f` | toggle display of the fringe | +| `SPC T m` | toggle menu bar | +| `SPC T t` | toggle tool bar | ### Statusline