Closed ashiklom closed 4 years ago
I haven't done extensive testing, but it seems like something like this in the GetRIndent()
function does the trick:
" Unindent a closing parenthesis. For example:
" list(
" a = 5,
" b = 8
" ) <--- Line this up with the beginning of `list`
if cline =~ '^\s*)'
let indline = s:Get_matching_brace(clnum, '(', ')', 1)
return indent(indline)
endif
This also requires adding 0)
to the indentkeys
at the top of the indent file.
The procedure that I follow to test changes in indent/r.vim
is:
tests/indent_test_noalign.R
and tests/indent_test.R
into /tmp
./tmp
directory do in normal mode gg=G
to indent the whole buffer, save it and quit Vim/Neovim. (But do this after setting the options in your vimrc
as described at the top of the files)nvim -d /path/to/R-Vim-runtime/tests/indent_test_noalign.R indent_test_noalign.R
nvim -d /path/to/R-Vim-runtime/tests/indent_test.R indent_test.R
In both cases, the changes in indent/r.vim
should improve the indentation without introducing any new bug.
Actually, your suggestion fixes the issue without introducing any new bug. I'm sorry for not testing it earlier.
The RStudio way of indenting code is like this:
This should be achievable by setting
g:r_indent_align_args = 0
andset cinoptions = (0,W2,m1
. However, this combination produces the following:Is there a way to make vim respect the
m1
cindent option, at least wheng:r_indent_align_args = 0
?