Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect indentation for block params with parenthesis #344

Open
ismailallocator opened this issue Apr 26, 2017 · 10 comments
Open

Incorrect indentation for block params with parenthesis #344

ismailallocator opened this issue Apr 26, 2017 · 10 comments
Labels

Comments

@ismailallocator
Copy link

hash.each_with_object({}) do |(key, value), new_hash|
  users.each do |user|
  puts user
end
end

instead of

hash.each_with_object({}) do |(key, value), new_hash|
  users.each do |user|
    puts user
  end
end

inner block end keyword is on same line as the first block end.

@AndrewRadev
Copy link
Member

I can't seem to reproduce the issue on the current master branch. Could you check if you've got the latest version from github? If you do, it might be something setting-related, or related to the Vim version. Could you post the output from vim --version, and any vim-ruby settings that you've set?

@klieth
Copy link

klieth commented Aug 31, 2017

I am also seeing this issue, on OS X 10.12.6 using both vim and neovim:

$ vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr  4 2017 18:14:54)
Included patches: 1-898, 8056
Compiled by root@apple.com
Normal version without GUI.  Features included (+) or not (-):
+acl             -farsi           -mouse_netterm   +syntax
-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/dyn      +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             -rightleft       +windows
+diff            +menu            +ruby/dyn        +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    -xpm
   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/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 -o vim        -lm -lncurses  -liconv
$ nvim --version
nvim --version
NVIM v0.2.1-313-gd3d0c9a7
Build type: RelWithDebInfo
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -O2 -g -DDISABLE_LOG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -I/tmp/neovim-20170607-69609-1iz5qrs/build/config -I/tmp/neovim-20170607-69609-1iz5qrs/src -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/opt/gettext/include -I/usr/include -I/usr/include -I/tmp/neovim-20170607-69609-1iz5qrs/build/src/nvim/auto -I/tmp/neovim-20170607-69609-1iz5qrs/build/include
Compiled by kai@kai.local

Optional features included (+) or not (-): +acl   +iconv    +jemalloc +tui
For differences from Vim, see :help vim-differences

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-d3d0c9a/share/nvim"

I just ran a :PluginUpdate, so I should have the latest from Github.

@AndrewRadev
Copy link
Member

@klieth Could you also post your .vimrc? The particular settings you have might give me a clue.

@klieth
Copy link

klieth commented Sep 1, 2017

@AndrewRadev I'm using a mostly vanilla install of maximum-awesome: https://github.com/square/maximum-awesome/blob/master/vimrc and https://github.com/square/maximum-awesome/blob/master/vimrc.local

The only addition I've made is to add set nohlsearch.

@AndrewRadev
Copy link
Member

Hmm, well, I tried installing this distribution. It was harder than it should be, since the authors seem to be building it exclusively for MacOS (relying on the presence of brew), but I digress. I still can't seem to reproduce the issue with this distribution.

Could you double-check that vim-ruby is at the latest version? I know you've run a PluginUpdate, but could you cd into ~/.vim/bundle/vim-ruby and run git show HEAD? For me, the latest commit is 074200ffa39b19baf9d9750d399d53d97f21ee07.

@matthewd
Copy link

matthewd commented Jul 3, 2018

FWIW, I just came here to report this same issue:

[].each do |(a, b)|
  it "x" do
  puts
end
end
VIM - Vi IMproved 8.1 (2018 May 17, compiled Jun 17 2018 23:04:26)
macOS version
Included patches: 1-72
Compiled by travis@Traviss-Mac-1044.local
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl               +farsi             +mouse_netterm     +tag_binary
+arabic            +file_in_path      +mouse_sgr         +tag_old_static
+autocmd           +find_in_path      -mouse_sysmouse    -tag_any_white
-autoservername    +float             +mouse_urxvt       -tcl
+balloon_eval      +folding           +mouse_xterm       +termguicolors
+balloon_eval_term -footer            +multi_byte        +terminal
+browse            +fork()            +multi_lang        +terminfo
++builtin_terms    +fullscreen        -mzscheme          +termresponse
+byte_offset       -gettext           +netbeans_intg     +textobjects
+channel           -hangul_input      +num64             +timers
+cindent           +iconv             +odbeditor         +title
+clientserver      +insert_expand     +packages          +toolbar
+clipboard         +job               +path_extra        +transparency
+cmdline_compl     +jumplist          +perl/dyn          +user_commands
+cmdline_hist      +keymap            +persistent_undo   +vertsplit
+cmdline_info      +lambda            +postscript        +virtualedit
+comments          +langmap           +printer           +visual
+conceal           +libcall           +profile           +visualextra
+cryptv            +linebreak         +python/dyn        +viminfo
+cscope            +lispindent        +python3/dyn       +vreplace
+cursorbind        +listcmds          +quickfix          +wildignore
+cursorshape       +localmap          +reltime           +wildmenu
+dialog_con_gui    +lua/dyn           +rightleft         +windows
+diff              +menu              +ruby/dyn          +writebackup
+digraphs          +mksession         +scrollbind        -X11
+dnd               +modify_fname      +signs             -xfontset
-ebcdic            +mouse             +smartindent       +xim
+emacs_tags        +mouseshape        +startuptime       -xpm
+eval              +mouse_dec         +statusline        -xsmp
+ex_extra          -mouse_gpm         -sun_workshop      -xterm_clipboard
+extra_search      -mouse_jsbterm     +syntax            -xterm_save
   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 -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -liconv -framework AppKit   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE
% grep ruby ~/.vimrc
/Users/matthew/.vimrc:let g:syntastic_ruby_checkers = ['mri', 'rubocop']
/Users/matthew/.vimrc:let g:ale_fixers = { 'ruby': ['rubocop'] }
/Users/matthew/.vimrc:  let g:gutentags_ctags_executable_ruby = $HOME.'/bin/ripper-tags'
/Users/matthew/.vimrc:let g:splitjoin_ruby_curly_braces = 0
/Users/matthew/.vimrc:let g:splitjoin_ruby_hanging_args = 0

My HEAD is 1e4c6fd.

@tpope
Copy link
Member

tpope commented Jul 6, 2018

Can't reproduce either. This is definitely a bug I've encountered in the past, so I'm inclined to think this is a case of the stock files included with Vim loading rather than the latest.

@matthewd
Copy link

matthewd commented Jul 6, 2018

Hrmm 😕

Here's my --startuptime... dirty laundry notwithstanding, I think it confirms it's loading in the right order. (~/.vim/ftplugin/ruby.vim is just setlocal ts=2 sts=2 sw=2 et)

Likewise:

  indentexpr=GetRubyIndent(v:lnum)
        Last set from ~/.common/.vim/bundle/vim-ruby/indent/ruby.vim
  indentkeys=0{,0},0),0],!^F,o,O,e,:,.,=end,=else,=elsif,=when,=ensure,=rescue,==begin,==end,=private,=protected,=public
        Last set from ~/.common/.vim/bundle/vim-ruby/indent/ruby.vim

(~/.vim is a symlink to ~/.common/.vim)

@tpope
Copy link
Member

tpope commented Jul 6, 2018

I concede your install looks correct.

@matthewd
Copy link

matthewd commented Jul 7, 2018

Thanks for confirming; from that, I dug in in hopes of finding some sort of cross-plugin interaction.

... but I didn't find one. I think (based on --startuptime and -V) this eliminates all local context:

vim -N -i NONE -u NONE --noplugin \
--cmd 'let &runtimepath="~/.vim/bundle/vim-ruby,$VIMRUNTIME"' \
--cmd 'filetype indent on' --cmd 'syntax on' \
-c 'setf ruby' -c 'normal =G' - <<EOF
[].each do |(a, b)|
it "x" do
puts
end
end
EOF

But that still leaves me looking at:

[].each do |(a, b)|
	it "x" do
	puts
end
end

(to be extra sure I also killed $VIMRUNTIME/*/ruby.vim, though they should all no-op because vim-ruby's versions were loaded first)

I also tried pointing at a fresh clone (now at 6959e10), just to eliminate any weirdness in my existing checkout; no luck there either.

@dkearns dkearns added the indent label Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants