Can I fix Groovy padding in Vim?

I am trying to use Vim for some Groovy code at work. Apparently, it does not cope with auto-indicators when semicolons are not used. I found several Ruby and JavaScript related issues with the same problems, but none of the fixes that I find work for me. I have a filetype plugin indent on in my .vimrc and do not install cindent , autoindent or smartindent . I tried to run setlocal nocindent nosmartindent in the Groovy buffer and re-specify the file with ggVG= in case the plugin installs it behind the scenes and it always fails anyway.

For example, I get this in a small sample (from the personal libGDX sandbox application that I write in Groovy)

 @Override void render () { Gdx.gl.glClearColor(0.75f, 0.75f, 0.75f, 1) Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT) batch.begin() batch.draw(img, 0, 0) font.draw(batch, "Testing", 300, 400) batch.end() } 

Note the extra indentation after the annotation, opening brackets, and the first line of the function. My .vimrc is pretty complicated, but I can post a link to my dotfiles if anyone thinks this helps.

+6
source share
1 answer

Vim has no indent script for groovy. Therefore, he tries to use standard indentation rules that are based on C. These rules use semicolons to determine if a line has ended, so you get indentation to continue the line in the second line of the function.

Since vim does not include an indent script, you can use the groovyindent plugin. Posted in ~/.vim/indent . You also need to run dos2unix in groovy.vim, as it contains incorrect line endings.

+6
source

All Articles