kovisoft / slimv

Official mirror of Slimv versions released on vim.org
454 stars 60 forks source link

How to disable automatic indentation by Slimv for non-Lisp files? #72

Open lonelearner opened 5 years ago

lonelearner commented 5 years ago

(Cross-posted from https://stackoverflow.com/q/56425273/1175080)

Non-Slimv Behavior

At first, let me show the normal Vim behavior when Slimv is not enabled.

  1. Create a new file: vim foo.c.
  2. Enter insert mode: i
  3. Enter this code: void f()
  4. Press enter

The cursor is now at position 2,1 (2nd row, 1st column).

Slimv Behavior

After installing Slimv, if I perform the steps above, at the end, I find the cursor at position 2,5 (2nd row, 5th column) with four spaces inserted as indentation before the 5th column automatically.

How can I disable this Slimv behavior for non-Lisp files (such as .c files)?

kovisoft commented 5 years ago

I guess that the behavior you described is caused by the cindent option of vim. You can check it by entering :set cindent? with and without enabling Slimv. I suppose that without enabling Slimv you have nocindent, and with enabling Slimv you have cindent. I think that's because of this line in plugin/paredit.vim:

filetype indent on

This line enables indent plugins, so it also enables the C indent plugin for .c files (indent/c.vim). If that's the case and you don't want that paredit.vim loads indent plugins, then maybe I can add an option for disabling that line. Is that okay?

lonelearner commented 5 years ago

Thanks for the fast response. Yes, without enabling Slimv, I have nocindent and after enabling Slimv I have cindent. Yes, it is due to filetype indent on. Commenting out that line in plugin/paredit.vim fixes this issue.

An option to disable that line would be great.

kovisoft commented 5 years ago

Before doing this please make sure that this is really what you want. I think disabling the line filetype indent on will completely disable indenting for all languages, including lisp. Is this what you want? Also for .c files cindent is the default indenting and if we take a look at your example (with void f()) you can see that even if the cursor is at column 5 in line 2 after pressing Enter, but when next you type { then the cursor will automatically move back to column 1:

void f()
{
kovisoft commented 5 years ago

Added option g:paredit_disable_ftindent in commit https://github.com/kovisoft/slimv/commit/e6ff1943efe7fe5fab34503f1efd05ee5795a496 .