rust-lang / rust.vim

Vim configuration for Rust.
Apache License 2.0
3.9k stars 297 forks source link

Indentation for closing parentheses is incorrect #443

Open yorickpeterse opened 3 years ago

yorickpeterse commented 3 years ago

When entering a newline inside parentheses, the closing parentheses is indented one level too far. Consider this example (| is the cursor position):

foo(|)

When pressing enter, the result is this:

foo(
    |)

But the expected result was this:

foo(
|)

In other words: the closing ) has the same indent level as the first non-space character of the line that contains the ( it belongs to.

Steps to reproduce

First, install vim-plug. Next, create /tmp/mini.vim with the following contents:

call plug#begin('/tmp/plugged')

Plug 'rust-lang/rust.vim'

call plug#end()

filetype plugin indent on
syntax on

Then start Vim and run :PlugInstall, then reopen Vim. Next, run set ft=rust.

In the buffer, type foo(), then move the cursor inside the parentheses like so:

foo(|)

Now press enter and observe how the closing ) is indented one level, instead of not being indented at all.

Debug info

rust.vim Global Variables:

let g:ftplugin_rust_source_path = v:null
let g:loaded_syntastic_rust_cargo_checker = v:null
let g:loaded_syntastic_rust_filetype = v:null
let g:loaded_syntastic_rust_rustc_checker = v:null
let g:rust_bang_comment_leader = v:null
let g:rust_cargo_avoid_whole_workspace = v:null
let g:rust_clip_command = v:null
let g:rust_conceal = v:null
let g:rust_conceal_mod_path = v:null
let g:rust_conceal_pub = v:null
let g:rust_fold = v:null
let g:rust_last_args = v:null
let b:rust_last_args = []
let g:rust_last_rustc_args = v:null
let b:rust_last_rustc_args = []
let g:rust_original_delimitMate_excluded_regions = v:null
let g:rust_playpen_url = v:null
let g:rust_prev_delimitMate_quotes = v:null
let g:rust_recent_nearest_cargo_tol = v:null
let g:rust_recent_root_cargo_toml = v:null
let g:rust_recommended_style = v:null
let g:rust_set_conceallevel = v:null
let g:rust_set_conceallevel=1 = v:null
let g:rust_set_foldmethod = v:null
let g:rust_set_foldmethod=1 = v:null
let g:rust_shortener_url = v:null
let g:rustc_makeprg_no_percent = v:null
let g:rustc_path = v:null
let g:rustfmt_autosave = 0
let g:rustfmt_autosave_if_config_present = v:null
let g:rustfmt_command = 'rustfmt'
let g:rustfmt_emit_files = 1
let g:rustfmt_fail_silently = 0
let g:rustfmt_options = ''
let g:syntastic_extra_filetypes = ['rust']
let g:syntastic_rust_cargo_fname = v:null
rustfmt 1.4.36-stable (7de6968 2021-02-07)

rustc 1.52.1 (9bc8c42bb 2021-05-09)

cargo 1.52.0 (69767412a 2021-04-21)

NVIM v0.5.0-dev+1315-g133351cbf
Build type: RelWithDebInfo
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions     -Wp,-D_FORTIFY_SOURCE=2,-D_GLIBCXX_ASSERTIONS     -Wformat -Werror=format-security     -fstack-clash-protection -fcf-protection -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/yorickpeterse/.cache/yay/neovim-git/src/build/config -I/home/yorickpeterse/.cache/yay/neovim-git/src/neovim-git/src -I/usr/include -I/home/yorickpeterse/.cache/yay/neovim-git/src/build/src/nvim/auto -I/home/yorickpeterse/.cache/yay/neovim-git/src/build/include
Compiled by yorickpeterse@roach

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info
yorickpeterse commented 3 years ago

Related issue/probably a duplicate (though with less info): https://github.com/rust-lang/rust.vim/issues/442