0

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)?

Lone Learner
  • 18,088
  • 20
  • 102
  • 200
  • 1
    If Slimv is coded properly, it shouldn’t affect non-Lisp files at all. You may want to dig into it’s code a bit and see if it is setting indent-related options, and how – D. Ben Knoble Jun 03 '19 at 12:39
  • @D.BenKnoble Thanks! Reported this as an issue to Slimv author: https://github.com/kovisoft/slimv/issues/72 – Lone Learner Jun 04 '19 at 02:58

2 Answers2

2

The issue is caused by this line in paredit.vim:

filetype indent on

I added the option g:paredit_disable_ftindent to paredit.vim to disable the loading of indent files, please add this line to your .vimrc when using paredit.vim (or slimv that also contains paredit.vim):

let g:paredit_disable_ftindent=1
Tamas Kovacs
  • 1,495
  • 7
  • 9
0

First, add to your vimrc file the following two lines:

filetype indent off
filetype plugin indent off

Then you have to hope that it’ll work! But there is a large probability that it won’t…

If the solution doesn’t work, you may have to make quite complicated actions to solve the trouble.

The problem is that many of your vim options are constantly changed by a lot of triggers and auto commands. The only way I found is to mark the important options (the options I don’t want to be changed) with a special symbol, and then to restore them forcibly after any possible impact. So, I did the following in my vimrc:

augroup MyVimrc
    autocmd!
augroup END

"The options I want to keep unchanged, I mark with the “❗” symbol.
"The usual exclamation sign “!” will work as well.
"Of course, you’re free using any other symbol you like, 
"but don’t forget the lambda-function in the hack below.

"These are the options that may influence on the indent.
set formatoptions=j    "❗
set autoindent    "❗
set nosmartindent    "❗
set indentexpr=    "❗
set copyindent      "❗
set preserveindent     "❗

"And I marked with the same way a number of other 
"important (for me) options… (not shown here)

"At the bottom of the vimrc file, I wrote this dirty hack.

function! s:keep_options()
    for line in filter(readfile($MYVIMRC), 'v:val =~ ''\v\".*(!|❗)\s*$''')
        exe line
    endfor
endfunction

command! KeepOptions call <SID>keep_options()

"Note, the “OptionSet” trigger doesn’t work always, so that I preferred “BufEnter”.
autocmd MyVimrc BufEnter * KeepOptions

And all the troubles with unpredictable changes in my settings, at last, have gone.

oneastok
  • 323
  • 1
  • 11