vim-scala icon indicating copy to clipboard operation
vim-scala copied to clipboard

Indentation problem for `}`?

Open pengyu opened this issue 11 years ago • 22 comments

The following is what is indented by vim-scala. The last } is indented one level. Shouldn't it be unindented?

object HelloWorld {
  def main(args: Array[String]) {
    println("Hello, world!")
  }
  }

pengyu avatar Jun 24 '13 04:06 pengyu

I can't reproduce that.

derekwyatt avatar Jun 24 '13 09:06 derekwyatt

I can reproduce : vim version 7.4.16, very annoying issue !

Here is another example def method() = { List().map { _ + 1 } }

YannMoisan avatar Oct 10 '13 15:10 YannMoisan

I can reproduce this issue

package foo
import org.scalatest.FunSuite
class FooSuite extends FunSuite {
  test("foo") {
    println("foo")
  }
  }

I'm using vim on a centos 6.3 machine :version tells me

VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Apr  5 2012 10:17:30)
Inkluderade patchar: 1-411
Modifierad av <[email protected]>
Kompilerad av <[email protected]>
Enorm version utan GUI.  Funktioner inkluderade (+) eller inte (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent -clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info
+comments +cryptv +cscope +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path
+find_in_path +float +folding -footer +fork() +gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent
+listcmds +localmap +menu +mksession +modify_fname +mouse -mouseshape +mouse_dec +mouse_gpm -mouse_jsbterm +mouse_netterm -mouse_sysmouse +mouse_xterm
+multi_byte +multi_lang -mzscheme -netbeans_intg -osfiletype +path_extra +perl +postscript +printer +profile +python +quickfix +reltime +rightleft -ruby
+scrollbind +signs +smartindent -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white -tcl +terminfo
+termresponse +textobjects +title -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows
+writebackup -X11 -xfontset -xim -xsmp -xterm_clipboard -xterm_save
   system-vimrc-fil: "/etc/vimrc"
     användar-vimrc-fil: "$HOME/.vimrc"
      användar-exrc-fil: "$HOME/.exrc"
  reserv för $VIM: "/usr/share/vim"
Kompilering: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall  -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GN
U_SOURCE -D_FILE_OFFSET_BITS=64  -D_FORTIFY_SOURCE=1    -D_REENTRANT -D_GNU_SOURCE  -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFF
SET_BITS=64  -I/usr/lib64/perl5/CORE  -I/usr/include/python2.6 -pthread
Länkning: gcc   -Wl,-E -Wl,-rpath,/usr/lib64/perl5/CORE   -L/usr/local/lib -o vim       -lselinux  -lncurses -lacl -lgpm   -Wl,-E -Wl,-rpath,/usr/lib64/pe
rl5/CORE  -fstack-protector  -L/usr/lib64/perl5/CORE -lperl -lresolv -lutil -lc -L/usr/lib64/python2.6/config -lpython2.6 -lutil -lm -Xlinker -export-dyna
mic

How can I help with more info about this issue?

mblund avatar Nov 13 '13 16:11 mblund

I'm on 7.3 with patches 1-429 and can't reproduce.

First, upgrade, then try and reproduce it. If you can, then we'll dig into it, otherwise we'll close this off.

derekwyatt avatar Nov 13 '13 16:11 derekwyatt

sorry, I'm on centos 6.4 not 6.3, my mistake

cat /etc/*release*
CentOS release 6.4 (Final)

vim seems up to date with centos, but still on 7.2...

yum info vim-enhanced
Loaded plugins: fastestmirror, protectbase
Loading mirror speeds from cached hostfile
0 packages excluded due to repository protections
Installed Packages
Name        : vim-enhanced
Arch        : x86_64
Epoch       : 2
Version     : 7.2.411
Release     : 1.8.el6
Size        : 1.8 M
Repo        : installed
From repo   : base

mblund avatar Nov 13 '13 16:11 mblund

That doesn't really change anything :) The version of VIM is what's in question and yours is way out of date (hell, mine's pretty out of date too, but it works, and it's years ahead of the version you're using).

At this point, I'm inclined to close the ticket on the assumption that upgrading to a later version of VIM will solve the problem unless you can prove otherwise.

derekwyatt avatar Nov 13 '13 16:11 derekwyatt

As mentioned above, i can repoduce with Vim 7.4.16

YannMoisan avatar Nov 13 '13 16:11 YannMoisan

Ah, right... sorry, forgot about that. I'll try and update soon and see if I can reproduce it there.

derekwyatt avatar Nov 13 '13 16:11 derekwyatt

yeah, I know it's old as hell but you know, those unused cpu:s on our server is to tempting to use when I'm a mba right now.

I saw that I swedish language setting so I tried to update them to en_US instead. Also checked charcet. Still no luck

export LANG=en_US.utf8
export LC_CTYPE=en_US.utf8
export LC_COLLATE=C
vim foo.scala 
file -bi foo.scala 
text/x-java; charset=utf-8

I should mention that I installed vim-scala with Vundle. Copied the sample .vimrc and added vim-scala

mblund avatar Nov 13 '13 17:11 mblund

OK, I've now tried this on my Mac (7.4a Beta) and a build that I just created from the VIM source.

Can't reproduce. I have no idea why you guys are seeing this. My version of vim-scala is the same as what's in this repository so there's nothing special about my system. there's something more interesting going on here.

Have a look through your settings that have to do with indenting (e.g. indentkeys, autoindent, filetype indent, etc..).

I have:

filetype indent on
set autoindent

And the indentkeys is what's in the plugin file. Is your autoindent not set?

derekwyatt avatar Nov 13 '13 18:11 derekwyatt

I tried it on my mac now. I get the same error!

$ git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle

This is my .vimrc

set nocompatible              " be iMproved
filetype off                  " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
Bundle 'derekwyatt/vim-scala'
filetype plugin indent on     " required!

and then

:Bundleinstall

inside of vim

I tried to indent the sampleFile.scala and doesn't come out right

mblund avatar Nov 13 '13 19:11 mblund

Try set autoindent

derekwyatt avatar Nov 13 '13 19:11 derekwyatt

still no luck.

to indent i use

gg=G

or visual and then =

mblund avatar Nov 13 '13 19:11 mblund

Then I'm out of ideas. Every single VIM installation I use this on (and there are many) this all works just fine.

But, the beauty is that you've got the source and you're in a great position to figure it out. Since I can't see it, I can't figure it out... you're the man to do it.

derekwyatt avatar Nov 13 '13 19:11 derekwyatt

I will try to have a look at it tomorrow and maybe get some help from my vim-support at work. Probably a case of pebkac . Thanks for today anyway.

mblund avatar Nov 13 '13 20:11 mblund

I gave it a try but the indent/scala.vim file was over my head.

The indention problems only occurs for me when I run on the full file with gg=G or with visual. I works fine with single lines so I'm happy to get the correct indentions and syntax coloring when I write code. I maybe use a sbt plugin to format the hole file later on.

mblund avatar Nov 19 '13 13:11 mblund

K. I'm gonna close this one. I know it's a frustrating problem for people but unless I can see it, or unless someone else can see it and fix it (or at least tell me what's happening) there's jack-all that I can do about it.

I hope someone files a new bug later with more information.

derekwyatt avatar Nov 19 '13 13:11 derekwyatt

I think I figured it out. Not really sure how exactly it's related however when I set virtualedit to all (which is what @derekwyatt is using), the indentation seems to work fine. The default value is just an empty string so if you want to break it for the current session, type :set virtualedit=

jiripospisil avatar Nov 27 '13 13:11 jiripospisil

Hm, so changing the single virtualedit value fixes it for me, but doesn't for a friend of mine... Anyway, give it a shot.

jiripospisil avatar Nov 27 '13 14:11 jiripospisil

Reproduced! Thanks a lot!

derekwyatt avatar Nov 30 '13 10:11 derekwyatt

I had the same problem and virtual edit worked, so I am putting this in indent/scala.vim as a workaround for now:

setlocal virtualedit=all

Bekbolatov avatar Jul 24 '14 19:07 Bekbolatov

That worked it out for me. Thanks!

mblund avatar Jul 24 '14 21:07 mblund