diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2019-09-27 19:47:32 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2019-09-27 19:47:32 +0200 |
commit | f95026252c5a31242903a98c741887696dfbb11f (patch) | |
tree | cd697cdc96c20a44f03ff3aacc67f78fdcc6ece5 /autoload/puppet/format.vim | |
parent | 4f3df59be709bf0d5c5c67dc804fde49abdc2700 (diff) | |
download | vim-polyglot-f95026252c5a31242903a98c741887696dfbb11f.tar.gz vim-polyglot-f95026252c5a31242903a98c741887696dfbb11f.zip |
Update everything, closes #435
Diffstat (limited to 'autoload/puppet/format.vim')
-rw-r--r-- | autoload/puppet/format.vim | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/autoload/puppet/format.vim b/autoload/puppet/format.vim index cfd48155..519fcc71 100644 --- a/autoload/puppet/format.vim +++ b/autoload/puppet/format.vim @@ -5,9 +5,16 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'puppet') == -1 function! puppet#format#Format() abort let l:start_lnum = v:lnum let l:end_lnum = v:lnum + v:count - 1 - call puppet#format#Indention(l:start_lnum, l:end_lnum) - call puppet#format#Hashrocket(l:start_lnum, l:end_lnum) + " Don't modify indentation or alignment if called by textwidth. We'll only + " let the fallback function do its thing in this case so that textwidth + " still performs the expected feature. + if mode() !~# '[iR]' + call puppet#format#Indention(l:start_lnum, l:end_lnum) + call puppet#format#Hashrocket(l:start_lnum, l:end_lnum) + endif call puppet#format#Fallback(l:start_lnum, l:end_lnum) + " explicitly avoid falling back to default formatting + return 0 endfunction "" @@ -37,10 +44,16 @@ endfunction " lines which exeed &widthline are formated " function! puppet#format#Fallback(start_lnum, end_lnum) abort + " We shouldn't wrap lines based on textwidth if it is disabled + if &textwidth == 0 + return + endif + " I'm using it to check if autoformat expand range let l:eof_lnum = line('$') let l:lnum = a:start_lnum let l:end_lnum = a:end_lnum + while l:lnum <= l:end_lnum if strlen(getline(l:lnum)) > &textwidth call cursor(l:lnum) |