Shougo / deoplete.nvim

:stars: Dark powered asynchronous completion framework for neovim/Vim8
Other
5.93k stars 295 forks source link

Conflicts with vim-stabs #1180

Closed d0u9 closed 3 years ago

d0u9 commented 3 years ago

Warning: I will close the issue without the minimal init.vim and the reproduction instructions.

Problems summary

I want to indent code with tab, and align with space. https://github.com/Thyrum/vim-stabs is a handy plugin for this purpose. However, both deoplete and vim-stabs content spacebar when completion and alignment happen same time.

Expected

  1. Coexistence between deoplete and vim-stabs; OR
  2. some other compatible methods to use space and tab for alignment and identation.

Environment Information

Provide a minimal init.vim/vimrc with less than 50 lines (Required!)

if &compatible
  set nocompatible
endif
execute 'set runtimepath+='.g:dein_path

if dein#load_state(expand(g:plugin_path))
    call dein#add('Shougo/deoplete.nvim',
            \ { 'name': 'deoplete' })
    call dein#add('Thyrum/vim-stabs')
    call dein#end()
    call dein#save_state()
endif

How to reproduce the problem from neovim/Vim startup (Required!)

  1. Edit any file which may trigger autocompletion menu;
  2. Hit tab.
  3. Menu closes, and a space is inserted.
Shougo commented 3 years ago

I don't understand it. But you want to select the candidates when popup is visible.

inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? StabsTab() :
\ deoplete#manual_complete()
function! s:check_back_space() abort "{{{
  let col = col('.') - 1
  return !col || getline('.')[col - 1]  =~ '\s'
endfunction"}}}

You should read the documentation though... https://github.com/Thyrum/vim-stabs#cocnvim

Note: We don't have ESP skills. You need to describe the problem more clearly.

d0u9 commented 3 years ago

vim-stab and deoplete both relay on tab key to take actions. vim-stab inserts <space> instead of <tab> if it is not for indentation. It works fine until a mix use of deoplete and vim-stab.

For example, if we have a simple Golang code snippet like this:

package main

import "fmt"

func main() {
    fmt.Print```HIT TAB HERE```
}

Once the t character is inputed deoplete pops a menu of candidate words for user to select. Hitting tab key here intuitively walks through the menu in normal scenario. BUT, due to the interference of vim-stab, tab key does noting but insert spaces after the fmt.Print.

 inoremap <silent><expr> <TAB>
             \ pumvisible() ? "\<C-n>" :
             \ <SID>check_back_space() ? StabsTab():
             \ deoplete#manual_complete()

 function! s:check_back_space() abort "{{{
     let col = col('.') - 1
     return !col || getline('.')[col - 1]  =~ '\s'
 endfunction"}}}

This configuration seems disable vim-stab totally. Only single space is inserted afterwards, and a trail of tab follows.

›   fmt.Printf(•›   ›   ›   ›   ›

What I want is something like this

›   fmt.Printf(•••••••••••••

Note: == space, == tab

Shougo commented 3 years ago

Really??? It is deoplete problem? OK, I need to check the behavior. Please wait.

Shougo commented 3 years ago

Please use this configuration instead.

let g:stabs_maps = 'boOc='
inoremap <silent><expr> <TAB>
             \ pumvisible() ? "\<C-n>" : StabsTab()

function! s:check_back_space() abort "{{{
     let col = col('.') - 1
     return !col || getline('.')[col - 1]  =~ '\s'
 endfunction"}}}
d0u9 commented 3 years ago

It is my fault. I remapped key twice in two separate vim config files and that is the root of this problem.

Comment here for reference.

Fixed, thank you. Please close this issue.