Spacevim: DelimitMate shortcuts are overwritten

Created on 22 Nov 2018  路  10Comments  路  Source: SpaceVim/SpaceVim

Expected behavior

delimitMate working correctly

The reproduce ways from Vim starting

Just open a .java file, probably others too. delimitMate maps are overwritten by ones from autocomplete.vim and it makes using delimitMate annoying. It seems like this has been accounted for in imap (, but not the others.

DelimitMateTest output

i  )            @<Plug>delimitMate)
    Last set from ~/.cache/vimfiles/repos/github.com/Raimondi/delimitMate/plugin/delimitMate.vim
i  }            @<Plug>delimitMate}
    Last set from ~/.cache/vimfiles/repos/github.com/Raimondi/delimitMate/plugin/delimitMate.vim
i  ]            @<Plug>delimitMate]
    Last set from ~/.cache/vimfiles/repos/github.com/Raimondi/delimitMate/plugin/delimitMate.vim
i  (             pumvisible() ? complete_parameter#pre_complete("()") : (len(maparg('<Plug>delimitMate(', 'i')) == 0) ? "\<Plug>delimitMate(" : '('
    Last set from ~/.SpaceVim/autoload/SpaceVim/layers/autocomplete.vim
i  {            @<Plug>delimitMate{
    Last set from ~/.cache/vimfiles/repos/github.com/Raimondi/delimitMate/plugin/delimitMate.vim
i  [            @<Plug>delimitMate[
    Last set from ~/.cache/vimfiles/repos/github.com/Raimondi/delimitMate/plugin/delimitMate.vim
i  "            @<Plug>delimitMate"
    Last set from ~/.cache/vimfiles/repos/github.com/Raimondi/delimitMate/plugin/delimitMate.vim
i  '            @<Plug>delimitMate'
    Last set from ~/.cache/vimfiles/repos/github.com/Raimondi/delimitMate/plugin/delimitMate.vim
i  `            @<Plug>delimitMate`
    Last set from ~/.cache/vimfiles/repos/github.com/Raimondi/delimitMate/plugin/delimitMate.vim
i  <BS>         @<Plug>delimitMateBS
    Last set from ~/.cache/vimfiles/repos/github.com/Raimondi/delimitMate/plugin/delimitMate.vim
i  <S-BS>       @<Plug>delimitMateS-BS
    Last set from ~/.cache/vimfiles/repos/github.com/Raimondi/delimitMate/plugin/delimitMate.vim
i  <S-Tab>       SpaceVim#mapping#shift_tab()
    Last set from ~/.SpaceVim/autoload/SpaceVim/layers/autocomplete.vim
i  <C-G>g       @<Plug>delimitMateJumpMany
    Last set from ~/.cache/vimfiles/repos/github.com/Raimondi/delimitMate/plugin/delimitMate.vim
i  <CR>          pumvisible() ? "\<C-Y>" : "\<CR>"
    Last set from ~/.SpaceVim/autoload/SpaceVim/layers/autocomplete.vim
i  <Space>      @<Plug>delimitMateSpace
    Last set from ~/.cache/vimfiles/repos/github.com/Raimondi/delimitMate/plugin/delimitMate.vim

Debug info

+ VersionControl:           loaded          https://spacevim.org/layers/VersionControl
+ autocomplete:             loaded          https://spacevim.org/layers/autocomplete
- chat:                 not loaded          https://spacevim.org/layers/chat
+ checkers:                 loaded          https://spacevim.org/layers/checkers
- chinese:              not loaded          https://spacevim.org/layers/chinese
+ colorscheme:              loaded          https://spacevim.org/layers/colorscheme
+ core/banner:              loaded          https://spacevim.org/layers/core/banner
+ core/statusline:          loaded          https://spacevim.org/layers/core/statusline
+ core/tabline:             loaded          https://spacevim.org/layers/core/tabline
+ core:                     loaded          https://spacevim.org/layers/core
- cscope:               not loaded          https://spacevim.org/layers/cscope
- ctrlp:                not loaded          https://spacevim.org/layers/ctrlp
+ debug:                    loaded          https://spacevim.org/layers/debug
+ denite:                   loaded          https://spacevim.org/layers/denite
+ edit:                     loaded          https://spacevim.org/layers/edit
- exprfold:             not loaded          no exists
- floobits:             not loaded          https://spacevim.org/layers/floobits
+ format:                   loaded          https://spacevim.org/layers/format
- fzf:                  not loaded          https://spacevim.org/layers/fzf
- games:                not loaded          no exists
- git:                  not loaded          https://spacevim.org/layers/git
- github:               not loaded          https://spacevim.org/layers/github
- incsearch:            not loaded          no exists
- indentmove:           not loaded          no exists
- japanese:             not loaded          https://spacevim.org/layers/japanese
- lang/WebAssembly:     not loaded          https://spacevim.org/layers/lang/WebAssembly
- lang/agda:            not loaded          https://spacevim.org/layers/lang/agda
- lang/asciidoc:        not loaded          https://spacevim.org/layers/lang/asciidoc
- lang/autohotkey:      not loaded          https://spacevim.org/layers/lang/autohotkey
+ lang/c:                   loaded          https://spacevim.org/layers/lang/c
- lang/clojure:         not loaded          https://spacevim.org/layers/lang/clojure
- lang/crystal:         not loaded          no exists
- lang/csharp:          not loaded          https://spacevim.org/layers/lang/csharp
- lang/dart:            not loaded          https://spacevim.org/layers/lang/dart
- lang/dockerfile:      not loaded          https://spacevim.org/layers/lang/dockerfile
- lang/elixir:          not loaded          https://spacevim.org/layers/lang/elixir
- lang/elm:             not loaded          https://spacevim.org/layers/lang/elm
- lang/erlang:          not loaded          https://spacevim.org/layers/lang/erlang
- lang/extra:           not loaded          https://spacevim.org/layers/lang/extra
- lang/fsharp:          not loaded          https://spacevim.org/layers/lang/fsharp
- lang/go:              not loaded          https://spacevim.org/layers/lang/go
- lang/haskell:         not loaded          https://spacevim.org/layers/lang/haskell
- lang/html:            not loaded          https://spacevim.org/layers/lang/html
+ lang/java:                loaded          https://spacevim.org/layers/lang/java
- lang/javascript:      not loaded          https://spacevim.org/layers/lang/javascript
- lang/json:            not loaded          no exists
- lang/julia:           not loaded          https://spacevim.org/layers/lang/julia
- lang/kotlin:          not loaded          https://spacevim.org/layers/lang/kotlin
+ lang/latex:               loaded          https://spacevim.org/layers/lang/latex
- lang/lisp:            not loaded          https://spacevim.org/layers/lang/lisp
- lang/lua:             not loaded          https://spacevim.org/layers/lang/lua
- lang/markdown:        not loaded          https://spacevim.org/layers/lang/markdown
- lang/nim:             not loaded          https://spacevim.org/layers/lang/nim
- lang/ocaml:           not loaded          https://spacevim.org/layers/lang/ocaml
- lang/perl:            not loaded          https://spacevim.org/layers/lang/perl
- lang/php:             not loaded          https://spacevim.org/layers/lang/php
- lang/plantuml:        not loaded          https://spacevim.org/layers/lang/plantuml
- lang/pony:            not loaded          no exists
- lang/ps1:             not loaded          no exists
- lang/puppet:          not loaded          https://spacevim.org/layers/lang/puppet
- lang/purescript:      not loaded          https://spacevim.org/layers/lang/purescript
+ lang/python:              loaded          https://spacevim.org/layers/lang/python
- lang/r:               not loaded          no exists
- lang/ruby:            not loaded          https://spacevim.org/layers/lang/ruby
- lang/rust:            not loaded          https://spacevim.org/layers/lang/rust
- lang/scala:           not loaded          https://spacevim.org/layers/lang/scala
- lang/scheme:          not loaded          https://spacevim.org/layers/lang/scheme
+ lang/sh:                  loaded          https://spacevim.org/layers/lang/sh
- lang/solidity:        not loaded          no exists
- lang/swift:           not loaded          https://spacevim.org/layers/lang/swift
- lang/swig:            not loaded          no exists
- lang/toml:            not loaded          no exists
- lang/typescript:      not loaded          https://spacevim.org/layers/lang/typescript
+ lang/vim:                 loaded          https://spacevim.org/layers/lang/vim
- lang/vue:             not loaded          https://spacevim.org/layers/lang/vue
- lang/xml:             not loaded          no exists
- leaderf:              not loaded          https://spacevim.org/layers/leaderf
- lsp:                  not loaded          no exists
- mail:                 not loaded          no exists
- operator:             not loaded          no exists
- org:                  not loaded          no exists
+ shell:                    loaded          https://spacevim.org/layers/shell
+ sudo:                     loaded          https://spacevim.org/layers/sudo
- tags:                 not loaded          https://spacevim.org/layers/tags
- tmux:                 not loaded          https://spacevim.org/layers/tmux
- tools/dash:           not loaded          https://spacevim.org/layers/tools/dash
- tools/screensaver:    not loaded          no exists
- tools:                not loaded          https://spacevim.org/layers/tools
+ ui:                       loaded          https://spacevim.org/layers/ui
- unite:                not loaded          https://spacevim.org/layers/unite
- vim:                  not loaded          no exists
help wanted

All 10 comments

I will check it, do you mean you can not complete pairs when edit java file?

Typing an opening bracket automatically creates its pair, but pressing backspace when between a pair, only the opening one gets deleted

hmm, I can not find how to fix it, because I can not reproduce it.

Here is a recording of it, if that helps. It seems like backspace is overwritten by another plugin (deoplete.vim): in this one it doesn't work, but it does work here.
As you can see, in the first one, it shows two mappings for <BS>, and it seems only the second one takes effect.

Hope that helps!

I cannot reproduce it either.

The problem for me is I have add this two lines below to my bootstrap function.

    let g:delimitMate_expand_space = 1
    let g:delimitMate_expand_cr    = 1

However I can only get

Expand <Space> to: >

                    You start with  |  You get
                  ==============================
                        (|)         |    ( | )

while I cannot get

Expand <CR> to: >

                   You start with   |  You get
                  ==============================
                        (|)         |    (
                                    |      |
                                    |    )

It seems that the option let g:delimitMate_expand_space = 1 works very well.
but the option let g:delimitMate_expand_cr = 1 doesn't work.

Well, my main problem is not with expanding <CR>, but unexpanding with <BS>. Pressing <BS> at ( | ) should result in (|), and pressing it again: |.

NOTE that this will not usually work when using Vim from the
terminal, see 'delimitMate#JumpAny()' below to see how to fix it.
https://github.com/Raimondi/delimitMate/blob/728b57a6564c1d2bdfb9b9e0f2f8c5ba3d7e0c5c/doc/delimitMate.txt#L456

Do you use Vim from the terminal?

@ssfjhh It does the same thing both on a terminal and a terminal emulator

@baltitenger I have fixed this issue, please update spacevim

@wsdjeg expand_cr wasn't fixed for me in 1.3.0 or 1.4.0. I was able to resolve it with the following steps though.

User's bootstrap (set either pre or post) for let g:delimitMate_expand_cr = 1 is overwritten when autocomplete layer is changed from default, as shown in the Spacevim quickstart @ https://github.com/SpaceVim/SpaceVim/blob/master/docs/quick-start-guide.md.

...
# Enable autocomplete layer
[[layers]]
    name = "autocomplete"
    auto-completion-return-key-behavior = "complete"

Specifically setting auto-completion-return-key-behavior = "complete" prevents delimitMate from expanding 's due to:
autocomplete.vim

elseif s:return_key_behavior ==# 'complete'
    imap <silent><expr><CR> pumvisible() ? "\<C-y>" : "\<CR>"

which can be verifed with :DelimitMateTest in vim/nvim.

i  <CR>          pumvisible() ? "\<C-Y>" : "\<CR>"
        Last set from ~/.SpaceVim/autoload/SpaceVim/layers/autocomplete.vim line 159

nil and smart options do not have the imap statement that complete does, so either work when combined with let g:delimitMate_expand_cr = 1 to get the desired behavior.

I don't know if you actually want to change anything in the docs/code, but to me expand_cr is a highly desirable option to have enabled. So at the very least maybe this will help someone if they they are digging through issues.

Was this page helpful?
0 / 5 - 0 ratings