Skip to content

Commit 916085d

Browse files
authored
Merge pull request #88 from neocryses/shiftwidth_fix
Fix shiftwidth=0 being ignored
2 parents 1d045ca + 492ed20 commit 916085d

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

indent/html.vim

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,13 @@ fun! <SID>HtmlIndentSum(lnum, style)
317317
endfun
318318

319319
fun! HtmlIndentGet(lnum)
320+
" Get shiftwidth value.
321+
if exists('*shiftwidth')
322+
let sw = shiftwidth()
323+
else
324+
let sw = &sw
325+
endif
326+
320327
" Find a non-empty line above the current line.
321328
let lnum = prevnonblank(a:lnum - 1)
322329

@@ -403,7 +410,7 @@ fun! HtmlIndentGet(lnum)
403410
endif
404411

405412
if 0 == match(getline(a:lnum), '^\s*</')
406-
return indent(preline) - (1*&sw)
413+
return indent(preline) - (1*sw)
407414
else
408415
return indent(preline)
409416
endif
@@ -424,7 +431,7 @@ fun! HtmlIndentGet(lnum)
424431
" let tags_exp = '<\(' . join(tags, '\|') . '\)>'
425432
" let close_tags_exp = '</\(' . join(tags, '\|') . '\)>'
426433
" if getline(a:lnum) =~ tags_exp
427-
" let block_start = search('^'.repeat(' ', lind + (&sw * ind - 1)).'\S' , 'bnW')
434+
" let block_start = search('^'.repeat(' ', lind + (sw * ind - 1)).'\S' , 'bnW')
428435
" let prev_tag = search(tags_exp, 'bW', block_start)
429436
" let prev_closetag = search(close_tags_exp, 'W', a:lnum)
430437
" if prev_tag && !prev_closetag
@@ -433,7 +440,7 @@ fun! HtmlIndentGet(lnum)
433440
" endif
434441

435442
" if getline(a:lnum) =~ '</\w\+>'
436-
" let block_start = search('^'.repeat(' ', lind + (&sw * ind - 1)).'\S' , 'bnW')
443+
" let block_start = search('^'.repeat(' ', lind + (sw * ind - 1)).'\S' , 'bnW')
437444
" let prev_tag = search(tags_exp, 'bW', block_start)
438445
" let prev_closetag = search(close_tags_exp, 'W', a:lnum)
439446
" if prev_tag && !prev_closetag
@@ -446,7 +453,7 @@ fun! HtmlIndentGet(lnum)
446453
setlocal noic
447454
endif
448455

449-
return lind + (&sw * ind)
456+
return lind + (sw * ind)
450457
endfun
451458

452459
let &cpo = s:cpo_save

0 commit comments

Comments
 (0)