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

Does not work flawlessly if used in conjunction w/ smartindent #126

Closed cvwillegen closed 11 years ago

cvwillegen commented 11 years ago

If autoindent is enabled, too much whitespace is inserted

Example:

  private function test()
  |

Press { and [Enter] on the place where the | indicates the cursor

Expected result:

  private function test()
  {
  |
  }

Actual result:

  private function test()
  {
  |
    }
cvwillegen commented 11 years ago

Please see the source of the bug report to see where the whitespace is, the editor keeps stripping it!!

qstrahl commented 11 years ago

Please see http://github.github.com/github-flavored-markdown/ for how to post code blocks.

cvwillegen commented 11 years ago

Thanks, that did the trick!

Raimondi commented 11 years ago

What filetype is that? could you paste the output of :DelimitMateTest?

cvwillegen commented 11 years ago

Filetype is PHP.

  1 delimitMate Report
  2 ==================
  3
  4 * Options: ( ) default, (g) global, (b) buffer
  5
  6 ( ) delimitMate_apostrophes = ''
  7 ( ) delimitMate_autoclose = 1
  8 ( ) delimitMate_balance_matchpairs = 0
  9 ( ) delimitMate_excluded_ft = ''
 10 ( ) delimitMate_excluded_regions = 'Comment'
 11 (g) delimitMate_expand_cr = 1
 12 (g) delimitMate_expand_space = 1
 13 ( ) delimitMate_matchpairs = '(:),{:},[:]'
 14 ( ) delimitMate_nesting_quotes = []
 15 ( ) delimitMate_quotes = '" '' `'
 16 ( ) delimitMate_smart_matchpairs = '^\%(\w\|\!\|£\|\$\|_\|["'']\s*\S\)'
 17 ( ) delimitMate_smart_quotes = 1
 18 --------------------
 19
 20 * Mappings:
 21
 22 All mappings were set-up.
 23 --------------------
 24
 25
 26 * Showcase:
 27
 28 Open: (|)
 29 Delete: |
 30 Exit: ()|
 31 Space: ( | )
 32 Delete space: (|)
 33 Car return: (
 34 |
 35 )
 36 Delete car return: (|)
 37
 38 Open: {|}
 39 Delete: |
 40 Exit: {}|
 41 Space: { | }
 42 Delete space: {|}
 43 Car return: {
 44   |
 45   }
 46 Delete car return: {|
 47   }
 48
 49 Open: [|]
 50 Delete: |
 51 Exit: []|
 52 Space: [ | ]
 53 Delete space: [|]
 54 Car return: [
 55 |
 56 ]
 57 Delete car return: [|]
 58
 59 Open: "|"
 60 Delete: |
 61 Exit: ""|
 62 Space: " | "
 63 Delete space: "|"
 64 Car return: "
 65 |
 66 "
 67 Delete car return: "|"
 68
 69 Open: '|'
 70 Delete: |
 71 Exit: ''|
 72 Space: ' | '
 73 Delete space: '|'
 74 Car return: '
 75 |
 76 '
 77 Delete car return: '|'
 78
 79 Open: `|`
 80 Delete: |
 81 Exit: ``|
 82 Space: ` | `
 83 Delete space: `|`
 84 Car return: `
 85 |
 86 `
 87 Delete car return: `|`
 88
 89 --- Options ---
 90   autoindent          ignorecase          modified            shiftwidth=2      nostartofline         t_Co=256
 91   background=dark     incsearch           number              shortmess=atI       tabstop=2           t_Sb=^[[4%p1%dm
 92   backspace=2         laststatus=2        ruler               showcmd             title               t_Sf=^[[3%p1%dm
 93   expandtab           list                scroll=8            smartindent         ttyfast             t_vb=
 94   hlsearch            modelines=3         scrolloff=999       softtabstop=2       ttymouse=xterm2
 95   listchars=tab:>-,trail:.,extends:>,precedes:<
 96   whichwrap=b,s,h,l,<,>,[,]
 97 filetype detection:ON  plugin:OFF  indent:OFF
 98 --------------------
Raimondi commented 11 years ago

I don't see filetype set to anything there, does it happen on any buffer or just on a specific filetype?

cvwillegen commented 11 years ago

Ah, I wasn't aware that I should run it in a buffer set to a definite type... It happens on PHP files, but also on CSS files. Line 44 in my 'report' may point to the issue? I have Vim 7.3 up to patch level 918.

Raimondi commented 11 years ago

I can't reproduce this issue. Try starting from a bare vimrc and find the steps to reproduce it. Let me know when you do.

cvwillegen commented 11 years ago

My bug report title is slightly off... it happens when using smartindent! I editted the subject to reflect this.

Here's my .vimrc:

set nocompatible    " use vim defaults
set backspace=2

let delimitMate_expand_space=1
let delimitMate_expand_cr=1

set ts=2 sw=2 ai expandtab sts=2
set smartindent

After that:

vim test.php
i
function test()<CR>
{<CR>

will show an indent before the closing brace. Commenting out the line setting 'smartindent' gives the correct formatting.

Hope this helps to pinpoint the problem, either in my work flow or in the plugin.

Raimondi commented 11 years ago

This seems to be fixed, I can't reproduce the issue.

cvwillegen commented 11 years ago

I can still reproduce it with:

$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jun 17 2013 12:34:46)
Included patches: 1-1214
Compiled by christ@....
Huge version without GUI.  Features included (+) or not (-):
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
-balloon_eval    +float           +mouse_urxvt     -tag_any_white
-browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
-clientserver    -hangul_input    +netbeans_intg   +title
-clipboard       +iconv           +path_extra      -toolbar
+cmdline_compl   +insert_expand   -perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       -python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             +rightleft       +windows
+diff            +menu            -ruby            +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
+emacs_tags      -mouseshape      -sniff           -xsmp
+eval            +mouse_dec       +startuptime     -xterm_clipboard
+ex_extra        +mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    
+farsi           +mouse_netterm   +syntax          
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim        -lm -lncurses -lnsl  -lacl -lattr -lgpm -ldl          

(this is just './configure --with-features=huge; make; sudo make install')

My .vimrc is as above

I started vim like this:

vim --noplugin
:source ~/.vim/plugin/delimitMate.vim
ifunction test()<CR>
{<CR>

With the smartindent setting on, I get an extra indent. With the smartindent setting off, I get the correct behaviour.

Is this enough info to reproduce the issue?