LnL7 / vim-nix

Vim configuration files for Nix http://nixos.org/nix
MIT License
287 stars 26 forks source link

smartindent breaks indented comments #16

Closed gmarmstrong closed 6 years ago

gmarmstrong commented 6 years ago

Using set smartindent causes comments not indent. After using o to insert a new indented line, typing # causes the line to lose its indentation. Editing the line before inserting the # will work around this issue.

This is in Neovim v0.2.2, with the latest vim-nix and a minimal init.vim.

Likely culprit: https://github.com/LnL7/vim-nix/commit/1e32fe7265291723dc197fb05b28a5a61071a28b

LnL7 commented 6 years ago

Could you give an example?

gmarmstrong commented 6 years ago

:set smartindent causes this:

smartindent

LnL7 commented 6 years ago

Weird, that doesn't happen for me. I'll try to reproduce with a minimal vim_configurable.

gmarmstrong commented 6 years ago

I tried using the same minimal ~/.vimrc with Neovim and Vim 8.0. The issue only appears in Neovim.

Looks like Neovim usually interacts differently with smartindent (https://github.com/neovim/neovim/issues/7702), so I'll just disable that option in my config. Thanks!

peperunas commented 2 years ago

I have the same issue. I'm running neovim 0.4.4.

I have set noautoindent and set nosmartindent and the issue persists.

ryan4yin commented 1 year ago

@peperunas NVIM v0.9.1 here, and everything works fine after set nosmartindent.

According to https://github.com/LunarVim/LunarVim/issues/3219, smartindent is deprecated in favor of cindent and should not be set.

neovim's docs for indentation:

'autoindent'    uses the indent from the previous line.
'smartindent'   is like 'autoindent' but also recognizes some C syntax to
        increase/reduce the indent where appropriate.
'cindent'   Works more cleverly than the other two and is configurable to
        different indenting styles.

So just disable smartindent and autoindent.