Raimondi / delimitMate

Vim plugin, provides insert mode auto-completion for quotes, parens, brackets, etc.
http://www.vim.org/scripts/script.php?script_id=2754
1.98k stars 117 forks source link

Expand CR not working #236

Closed apeduru closed 7 years ago

apeduru commented 8 years ago

delimitMate_expand_cr does not indent on newline when hit carriage return on creation of new bracket/brace

Currently using workound inoremap { {} O

vimrc snippet

let g:delimitMate_autoclose = 1
let g:delimitMate_matchpairs = "(:),[:],{:},<:>"
let g:delimitMate_jump_expansion = 1
let g:delimitMate_expand_space = 1
let g:delimitMate_expand_cr = 2
let g:delimitMate_expand_inside_quotes = 1

inoremap {<CR> {<CR>} <C-o>O

Specs Ubuntu 15.10 VIM 7.4

HybridEidolon commented 8 years ago

Confirming this bug on MacVim 7.4-1054.

enali commented 8 years ago

I have same issue. expect:

int main() {<cr>

to expand to

int main(){
    |
}

but I get the error result

int main() {
|}

the option cr set to 1, and space to 1, and jump to 1.

Ubuntu14.04.3 LTS, vim 7.4

willdurney commented 8 years ago

I'm having this same issue: latest version of DelimitMate and vim 7.4.1257 via Homebrew on OSX.

Edit: I fixed my issue by disabling tpope/vim-endwise

pbogut commented 8 years ago

Same problem, is not working even with tpope/vim-endwise disabled, but I would prefer to have both anyway.

SenZhangAI commented 8 years ago

I had the same issue, then I run :DelimitMateTest and found that the<CR> had been used by neocomplete,so I change my config, and then it work.

So, I think if something wrong with DelimitMate and vim-endwise, maybe :DelimitMateTest will help to find the solution.

jonathan-soifer commented 7 years ago

Any news?

gavocanov commented 7 years ago

I do not have tpope/vim-endwise and it's still not working.

Raimondi commented 7 years ago

Run :DelimitMateTest from a buffer with the issue and paste the output here.

gavocanov commented 7 years ago

hey, sorry for such a late reply :/

delimitMate Report
==================

* Options: ( ) default, (g) global, (b) buffer

( ) delimitMate_apostrophes = ''
( ) delimitMate_apostrophes_list = []
( ) delimitMate_autoclose = 1
(g) delimitMate_balance_matchpairs = 1
( ) delimitMate_eol_marker = ''
( ) delimitMate_excluded_regions = 'Comment'
( ) delimitMate_excluded_regions_enabled = 1
( ) delimitMate_excluded_regions_list = ['Comment']
(g) delimitMate_expand_cr = 2
( ) delimitMate_expand_inside_quotes = 0
(g) delimitMate_expand_space = 1
( ) delimitMate_insert_eol_marker = 1
(g) delimitMate_jump_expansion = 1
( ) delimitMate_left_delims = ['(', '{', '[']
( ) delimitMate_matchpairs = '(:),{:},[:]'
( ) delimitMate_matchpairs_list = [['(', ')'], ['{', '}'], ['[', ']']]
( ) delimitMate_nesting_quotes = []
( ) delimitMate_quotes = '" '' `'
( ) delimitMate_quotes_list = ['"', '''', '`']
( ) delimitMate_right_delims = [')', '}', ']']
( ) delimitMate_smart_matchpairs = '^\%(\w\|\!\|[£$]\|[^[:punct:][:space:]]\)'
( ) delimitMate_smart_quotes = '\%(\w\|[^[:punct:][:space:]"''`]\|\%(\\\\\)*\\\)\%#\|\%#\%(\w\|[^[:space:][:punct:]"''`]\)'
( ) delimitMate_tab2exit = 1

( ) g:delimitMate_excluded_ft = ''
--------------------

* Mappings:

i  )            @<Plug>delimitMate)
    Last set from ~/.vim/plugged/delimitMate/plugin/delimitMate.vim
i  }            @<Plug>delimitMate}
    Last set from ~/.vim/plugged/delimitMate/plugin/delimitMate.vim
i  ]            @<Plug>delimitMate]
    Last set from ~/.vim/plugged/delimitMate/plugin/delimitMate.vim
i  (            @<Plug>delimitMate(
    Last set from ~/.vim/plugged/delimitMate/plugin/delimitMate.vim
i  {            @<Plug>delimitMate{
    Last set from ~/.vim/plugged/delimitMate/plugin/delimitMate.vim
i  [            @<Plug>delimitMate[
    Last set from ~/.vim/plugged/delimitMate/plugin/delimitMate.vim
i  "            @<Plug>delimitMate"
    Last set from ~/.vim/plugged/delimitMate/plugin/delimitMate.vim
i  '            @<Plug>delimitMate'
    Last set from ~/.vim/plugged/delimitMate/plugin/delimitMate.vim
i  `            @<Plug>delimitMate`
    Last set from ~/.vim/plugged/delimitMate/plugin/delimitMate.vim
i  <BS>         @<Plug>delimitMateBS
    Last set from ~/.vim/plugged/delimitMate/plugin/delimitMate.vim
i  <S-BS>       @<Plug>delimitMateS-BS
    Last set from ~/.vim/plugged/delimitMate/plugin/delimitMate.vim
i  <S-Tab>       <Plug>(MUcompleteBwd)
    Last set from ~/.vim/plugged/vim-mucomplete/plugin/mucomplete.vim
i  <C-G>g       @<Plug>delimitMateJumpMany
    Last set from ~/.vim/plugged/delimitMate/plugin/delimitMate.vim
i  <CR>        * <CR>x<BS>
    Last set from ~/.vimrc
i  <Space>      @<Plug>delimitMateSpace
    Last set from ~/.vim/plugged/delimitMate/plugin/delimitMate.vim
--------------------

* Showcase:

Open: (|)
Delete: |
Exit: ()|
Space: ( | )
Delete space: (|)
Car return: (
    |)
Delete car return: (|)

Open: {|}
Delete: |
Exit: {}|
Space: { | }
Delete space: {|}
Car return: {
|}
Delete car return: {|}

Open: [|]
Delete: |
Exit: []|
Space: [ | ]
Delete space: [|]
Car return: [
|]
Delete car return: [|]

Open: "|"
Delete: |
Exit: ""|

Open: '|'
Delete: |
Exit: ''|

Open: `|`
Delete: |
Exit: ``|

 * Vim configuration:

filetype detection:ON  plugin:ON  indent:ON

--- Options ---
  autoindent          cscopeverbose       guioptions=gmrL   nojoinspaces          number              showmatch           softtabstop=4       tags=./tags;,tags   ttyfast             wildmenu
  autoread            cursorline          helplang=en         langmenu=none       ruler               showtabline=2       splitright          termguicolors       ttymouse=xterm2   nowrap
  background=dark     display=lastline    hidden              laststatus=2        scroll=41           sidescroll=1      nostartofline         textwidth=120       ttyscroll=3
  backup              expandtab           history=1000        lazyredraw          scrolloff=2         sidescrolloff=5     suffixesadd=.js     title               undofile
  cindent             foldlevel=99        ignorecase          modified            shiftwidth=4        smartcase           tabpagemax=50       ttimeout            updatetime=750
  cscopetag           foldmethod=marker   incsearch           nrformats=bin,hex   showcmd             smarttab            tabstop=4           ttimeoutlen=100     visualbell
  backspace=indent,eol,start
  backupdir=~/.vim/bkp//
  comments=sO:* -,mO:*  ,exO:*/,s1:/*,mb:*,ex:*/,://
  commentstring=//%s
  complete=.,w,b,u,t
  completeopt=menuone,noinsert,noselect
  directory=~/.vim/swp//
  fileencoding=utf-8
  fileencodings=ucs-bom,utf-8,default,latin1
  fileformats=unix,mac,dos
  filetype=javascript.jsx
  foldopen=hor,insert,jump,mark,percent,quickfix,search,tag,undo
  formatoptions=njcroql
  indentexpr=GetJsxIndent()
  indentkeys=0{,0},0),0],0,,!^F,o,O,e,*<Return>,<>>,<<>,/
  iskeyword=@,48-57,_,192-255,$
  listchars=extends:⇒
  omnifunc=tern#Complete
  runtimepath=~/.vim,~/.vim/plugged/vim-sensible/,~/.vim/plugged/vim-gita/,~/.vim/plugged/vim-repeat/,~/.vim/plugged/vim-surround/,~/.vim/plugged/vim-unimpaired/,~/.vim/plugged/vim-commentary/,~/.vim/plugged/vim-git/,~/.vim/plugged/vim-obsession/,~/.vim/plugged/vim-eunuch/,~/.vim/plugged/vim-abolish/,~/.vim/plugged/vim-polyglot/,~/.vim/plugged/vim-lion/,~/.fzf/,~/.vim/plugged/fzf.vim/,~/.vim/plugged/incbool.vim/,~/.vim/plugged/vim-grepper/,~/.vim/plugged/targets.vim/,~/.vim/plugged/vim-cool/,~/.vim/plugged/delimitMate/,~/.vim/plugged/vim-gitgutter/,~/.vim/plugged/editorconfig-vim/,~/.vim/plugged/vim-buftabline/,~/.vim/plugged/vim-qf/,~/.vim/plugged/vimwiki/,~/.vim/plugged/vim-wakatime/,~/.vim/plugged/vim-xmark/,~/.vim/plugged/vim-dasht/,~/.vim/plugged/codi.vim/,~/.vim/plugged/ale/,~/.vim/plugged/vim-mucomplete/,~/.vim/plugged/gruvbox/,~/.vim/plugged/vim-javascript/,~/.vim/plugged/vim-jsx-improve/,~/.vim/plugged/vimproc.vim/,~/.vim/plugged/emmet-vim/,~/.vim/plugged/tern_for_vim/,~/.vim/plugged/vim-jsdoc/,~/.vim/plugged/neo
  sessionoptions=blank,buffers,curdir,folds,help,tabpages,winsize
  shell=/usr/local/bin/bash
  shortmess=filnxtToOcaI
  statusline= %r%y %{gita#statusline#preset('branch_fancy')} %{gita#statusline#preset('status')} %=%-14.(%l,%c%V%) %-4P %{ObsessionStatus()}
  switchbuf=useopen,usetab
  syntax=javascript.jsx
  tabline=%!buftabline#render()
  undodir=~/.vim/undo//
  viminfo=!,'100,<50,s10,h
  t_EI=^[]50;CursorShape=0^G
  t_SI=^[]50;CursorShape=1^G
  t_SR=^[]50;CursorShape=2^G

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jan 13 2017 08:46:35)
MacOS X (unix) version
Included patches: 1-176
Compiled by Homebrew
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl             +clipboard       +dialog_con_gui  +file_in_path    +insert_expand   +localmap        +mouse_netterm   +odbeditor       +quickfix        +syntax          +title           +wildignore      -xterm_save
+arabic          +cmdline_compl   +diff            +find_in_path    +job             +lua             +mouse_sgr       +packages        +reltime         +tag_binary      +toolbar         +wildmenu        
+autocmd         +cmdline_hist    +digraphs        +float           +jumplist        +menu            -mouse_sysmouse  +path_extra      +rightleft       +tag_old_static  +transparency    +windows         
+balloon_eval    +cmdline_info    +dnd             +folding         +keymap          +mksession       +mouse_urxvt     +perl            +ruby            -tag_any_white   +user_commands   +writebackup     
+browse          +comments        -ebcdic          -footer          +lambda          +modify_fname    +mouse_xterm     +persistent_undo +scrollbind      -tcl             +vertsplit       -X11             
++builtin_terms  +conceal         +emacs_tags      +fork()          +langmap         +mouse           +multi_byte      +postscript      +signs           +termguicolors   +virtualedit     -xfontset        
+byte_offset     +cryptv          +eval            +fullscreen      +libcall         +mouseshape      +multi_lang      +printer         +smartindent     +terminfo        +visual          +xim             
+channel         +cscope          +ex_extra        -gettext         +linebreak       +mouse_dec       -mzscheme        +profile         +startuptime     +termresponse    +visualextra     -xpm             
+cindent         +cursorbind      +extra_search    -hangul_input    +lispindent      -mouse_gpm       +netbeans_intg   -python          +statusline      +textobjects     +viminfo         -xsmp            
+clientserver    +cursorshape     +farsi           +iconv           +listcmds        -mouse_jsbterm   +num64           +python3         -sun_workshop    +timers          +vreplace        -xterm_clipboard 
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: clang   -L. -L/usr/local/lib -L. -L/usr/local/lib  -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -liconv -framework Cocoa  -pagezero_size 10000 -image_base 100000000 -L/usr/local/opt/luajit/lib -lluajit-5.1 -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl  -L/usr/local/opt/python3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin -lpython3.6m -framework CoreFoundation  -framework Ruby    
--------------------

Behaves exactly the same both in Vim and Neovim.

Thnx for your time.

gavocanov commented 7 years ago

found the problem: http://stackoverflow.com/questions/7413036/stopping-vim-from-removing-indentation-on-empty-lines

Had

" do not remove indent when switching to normal mode
inoremap <CR> <CR>x<BS>
nnoremap o ox<BS>
nnoremap O Ox<BS>

set in my .vimrc, without it delimitmate works fine.

This is not detected by :DelimitMateTest, would be nice for it to cover user mappings also, I guess it would eliminate much more false positives.

Sorry for the trouble and thnx anyway.

Raimondi commented 7 years ago

That mapping was listed in :DelimitMateTest's output:

i  <CR>        * <CR>x<BS>
    Last set from ~/.vimrc
TheBabu commented 6 years ago

I was wondering how to do inoremap {<CR> {<CR>} <C-o>O But add a Tab between those parentheses, how would I do that?

mroavi commented 3 years ago

I had the same issue, then I run :DelimitMateTest and found that the<CR> had been used by neocomplete,so I change my config, and then it work.

So, I think if something wrong with DelimitMate and vim-endwise, maybe :DelimitMateTest will help to find the solution.

I was having this problem. completion-nvim and delmitMate were conflicting. Here is how I configured completion-nvim to fix the problem:

" Fixes delimitmate's 'delimitMate_expand_cr' option
let g:completion_confirm_key = ""
imap <expr> <cr>  pumvisible() ? complete_info()["selected"] != "-1" ?
                 \ "\<Plug>(completion_confirm_completion)" : "\<c-e>\<CR>" : "\<Plug>delimitMateCR"