From 0fe85bb423b1e3c62ae3ca65f7fba84ec026bc42 Mon Sep 17 00:00:00 2001 From: Greg Anders Date: Wed, 13 Nov 2019 11:31:46 -0700 Subject: [PATCH] Auto correct snippet indent after inserting --- autoload/minisnip.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/autoload/minisnip.vim b/autoload/minisnip.vim index 36dae0d..7b945ee 100644 --- a/autoload/minisnip.vim +++ b/autoload/minisnip.vim @@ -38,6 +38,7 @@ function! minisnip#Minisnip() abort " adjust the indentation, use the current line as reference let l:ws = matchstr(getline(line('.')), '^\s\+') let l:lns = map(readfile(s:snippetfile), 'empty(v:val)? v:val : l:ws.v:val') + let l:nlines = len(l:lns) " remove the snippet keyword " go to the position at the beginning of the snippet @@ -74,6 +75,9 @@ function! minisnip#Minisnip() abort " go to the beginning of the snippet execute ':normal! '.(s:begcol - strchars(s:cword)).'|' + " auto indent + execute ':normal! =' . l:nlines . 'j' + " select the first placeholder call s:SelectPlaceholder() else