Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indentation for closing parentheses is incorrect #443

Open
yorickpeterse opened this issue May 20, 2021 · 1 comment · May be fixed by #444
Open

Indentation for closing parentheses is incorrect #443

yorickpeterse opened this issue May 20, 2021 · 1 comment · May be fixed by #444

Comments

@yorickpeterse
Copy link

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.

  • rust.vim version: I'm using vim-plug. The commit I'm using for rust.vim is 87c745d

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
Copy link
Author

Related issue/probably a duplicate (though with less info): #442

yorickpeterse added a commit to yorickpeterse/rust.vim that referenced this issue May 20, 2021
To help explain this problem, consider this input (where | is the
cursor):

    foo(|)

Prior to this commit, pressing Enter would result in the following:

    foo(
        |)

That is, the closing parenthesis is indented by one level. This is the
case regardless of the cindent options/keys chosen.

To fix this, we manually indent lines that start with a ")" (ignoring
leading whitespace). Such lines are indented according to the
indentation of the line that contained the opening parenthesis.

Fixes rust-lang#443
@yorickpeterse yorickpeterse linked a pull request May 20, 2021 that will close this issue
yorickpeterse added a commit to yorickpeterse/rust.vim that referenced this issue May 20, 2021
To help explain this problem, consider this input (where | is the
cursor):

    foo(|)

Prior to this commit, pressing Enter would result in the following:

    foo(
        |)

That is, the closing parenthesis is indented by one level. This is the
case regardless of the cindent options/keys chosen.

To fix this, we manually indent lines that start with a ")" (ignoring
leading whitespace). Such lines are indented according to the
indentation of the line that contained the opening parenthesis.

Fixes rust-lang#443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant