summaryrefslogtreecommitdiffstats
path: root/runtime/indent
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-11-02 14:09:23 +0100
committerBram Moolenaar <Bram@vim.org>2019-11-02 14:09:23 +0100
commit1ff14ba24c4d85c008d7abe5e140dbb497ffea8d (patch)
treedb40390c4e458598c59ef087d6a377ce0d5a332f /runtime/indent
parent757bd2ea49585ea9896d6df707c68b4793017039 (diff)
Update runtime files.
Diffstat (limited to 'runtime/indent')
-rw-r--r--runtime/indent/testdir/vim.in15
-rw-r--r--runtime/indent/testdir/vim.ok15
-rw-r--r--runtime/indent/vim.vim27
3 files changed, 56 insertions, 1 deletions
diff --git a/runtime/indent/testdir/vim.in b/runtime/indent/testdir/vim.in
index ca105f6eda..235f31d061 100644
--- a/runtime/indent/testdir/vim.in
+++ b/runtime/indent/testdir/vim.in
@@ -44,3 +44,18 @@ let f = x
" prev-line
endfunc
" END_INDENT
+
+" START_INDENT
+let a =<< END
+nothing
+END
+" END_INDENT
+
+" START_INDENT
+" INDENT_AT this-line
+let a=<< trim END
+ blah
+ blah
+ blah this-line
+END
+" END_INDENT
diff --git a/runtime/indent/testdir/vim.ok b/runtime/indent/testdir/vim.ok
index 542861ec9c..61369d4b93 100644
--- a/runtime/indent/testdir/vim.ok
+++ b/runtime/indent/testdir/vim.ok
@@ -44,3 +44,18 @@ func Some()
" prev-line
endfunc
" END_INDENT
+
+" START_INDENT
+let a =<< END
+ nothing
+END
+" END_INDENT
+
+" START_INDENT
+" INDENT_AT this-line
+let a=<< trim END
+ blah
+ blah
+ blah this-line
+END
+" END_INDENT
diff --git a/runtime/indent/vim.vim b/runtime/indent/vim.vim
index cd735c3a3c..db27f19714 100644
--- a/runtime/indent/vim.vim
+++ b/runtime/indent/vim.vim
@@ -1,7 +1,7 @@
" Vim indent file
" Language: Vim script
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2016 Jun 27
+" Last Change: 2019 Oct 31
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
@@ -56,6 +56,31 @@ function GetVimIndentIntern()
" and :else. Add it three times for a line that starts with '\' or '"\ '
" after a line that doesn't (or g:vim_indent_cont if it exists).
let ind = indent(lnum)
+
+ " In heredoc indenting works completely differently.
+ if has('syntax_items')
+ let syn_here = synIDattr(synID(v:lnum, 1, 1), "name")
+ if syn_here =~ 'vimLetHereDocStop'
+ " End of heredoc: use indent of matching start line
+ let lnum = v:lnum - 1
+ while lnum > 0
+ if synIDattr(synID(lnum, 1, 1), "name") !~ 'vimLetHereDoc'
+ return indent(lnum)
+ endif
+ let lnum -= 1
+ endwhile
+ return 0
+ endif
+ if syn_here =~ 'vimLetHereDoc'
+ if synIDattr(synID(lnum, 1, 1), "name") !~ 'vimLetHereDoc'
+ " First line in heredoc: increase indent
+ return ind + shiftwidth()
+ endif
+ " Heredoc continues: no change in indent
+ return ind
+ endif
+ endif
+
if cur_text =~ s:lineContPat && v:lnum > 1 && prev_text !~ s:lineContPat
if exists("g:vim_indent_cont")
let ind = ind + g:vim_indent_cont