JuliaDiff / BlueStyle

A Julia style guide that lives in a blue world
Creative Commons Zero v1.0 Universal
487 stars 34 forks source link

Vim Settings to make new line after opening bracket only indent once #29

Open oxinabox opened 4 years ago

oxinabox commented 4 years ago

By default if one writes the following, pressing enter after the opening ( then the next character pressed will be where the x is:

function my_long_function_name(
                               x

but what the style-guide recommends is:

function my_long_function_name(
    x
oxinabox commented 4 years ago

I suspect the answer is super fiddly https://www.vim.org/scripts/script.php?script_id=754

nickrobinson251 commented 4 years ago

will probably need to look at :help indentexpr and :help indent-expression

nickrobinson251 commented 4 years ago

examples at https://github.com/vim/vim/tree/master/runtime/indent and https://github.com/JuliaEditorSupport/julia-vim/blob/master/indent/julia.vim

sdl1 commented 3 years ago

I've been using this fork of julia-vim which fixes the above problem for me. I guess the relevant changes are in this file.

nickrobinson251 commented 3 years ago

OMG that's amazing! @sdl1 you're a hero. @tom--lee is a hero.

(@ararslan, does this fix your biggest gripe about BlueStyle?)

Plug 'tom--lee/julia-vim' (using vim-plug) was enough to solve this problem for me 💙

I guess the relevant changes are in this file.

Seems the relevant changes are https://github.com/tom--lee/julia-vim/commit/40649c9cab3fb95ca7104f17882483ba53b74197

tom--lee commented 3 years ago

Happy others have found this useful! But be aware my changes were a bit of a hack-job and the fork is well behind the upstream master. That said, I have been using it for a couple of years with no trouble.

oxinabox commented 3 years ago

There are now options for this in the main julia-vim plugin

https://github.com/JuliaEditorSupport/julia-vim/blob/b437dae505b0fbb6aac92a9aad8f4fb68ea1259b/doc/julia-vim.txt#L389-L472

It would be useful if someone can workout exactly what we want to set them to and add it the section of the instructions on configuring vim.