summaryrefslogtreecommitdiff
path: root/runtime/indent
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-10-11 08:57:33 +0200
committerBram Moolenaar <Bram@vim.org>2016-10-11 08:57:33 +0200
commitdc08328821a2c11e33dfb1980332e4923ec64fca (patch)
tree237125b7b303f9fdae53f8dfefe26d9ee99a8285 /runtime/indent
parentdc0ccaee68ca24d10050117fbec757ad33590a17 (diff)
downloadvim-dc08328821a2c11e33dfb1980332e4923ec64fca.zip
Updated runtime files.
Diffstat (limited to 'runtime/indent')
-rw-r--r--runtime/indent/mp.vim35
1 files changed, 20 insertions, 15 deletions
diff --git a/runtime/indent/mp.vim b/runtime/indent/mp.vim
index c9639efed..86fa2539c 100644
--- a/runtime/indent/mp.vim
+++ b/runtime/indent/mp.vim
@@ -2,7 +2,7 @@
" Language: MetaPost
" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
" Former Maintainers: Eugene Minkovskii <emin@mccme.ru>
-" Last Change: 2016 Oct 01
+" Last Change: 2016 Oct 2, 4:13pm
" Version: 0.2
if exists("b:did_indent")
@@ -57,7 +57,7 @@ let g:mp_open_tag = ''
let g:mp_close_tag = ''
\ . '\<fi\>'
\ . '\|\<else\%[if]\>'
- \ . '\|\<end\%(\|for\|group\|def\|fig\|char\|logochar\|glyph\|graph\)\>'
+ \ . '\|\<end\%(\|for\|group\|def\|fig\|char\|glyph\|graph\)\>'
\ . '\|[)\]}]'
" Statements that may span multiple lines and are ended by a semicolon. To
@@ -118,12 +118,10 @@ function! s:CommentOrString(line, pos)
return in_string || (c >= 0 && c <= a:pos)
endfunction
-" Find the first non-comment non-blank line before the current line. Skip also
-" verbatimtex/btex... etex blocks.
+" Find the first non-comment non-blank line before the current line.
function! s:PrevNonBlankNonComment(lnum)
let l:lnum = prevnonblank(a:lnum - 1)
- while getline(l:lnum) =~# '^\s*%' ||
- \ synIDattr(synID(a:lnum, 1, 1), "name") =~# '^mpTeXinsert$\|^tex\|^Delimiter'
+ while getline(l:lnum) =~# '^\s*%'
let l:lnum = prevnonblank(l:lnum - 1)
endwhile
return l:lnum
@@ -220,25 +218,32 @@ endfunction
"
" Example:
"
-" shiftwidth=4
" def foo =
-" makepen(subpath(T-n,t) of r %>
-" shifted .5down %>
-" --subpath(t,T) of r shifted .5up -- cycle) %<<
+" makepen(
+" subpath(T-n,t) of r %>
+" shifted .5down %>
+" --subpath(t,T) of r shifted .5up -- cycle %<<<
+" )
" withcolor black
" enddef
"
" The default indentation of the previous example would be:
"
" def foo =
-" makepen(subpath(T-n,t) of r
-" shifted .5down
-" --subpath(t,T) of r shifted .5up -- cycle)
+" makepen(
+" subpath(T-n,t) of r
+" shifted .5down
+" --subpath(t,T) of r shifted .5up -- cycle
+" )
" withcolor black
" enddef
"
" Personally, I prefer the latter, but anyway...
function! GetMetaPostIndentIntern()
+ " Do not touch indentation inside verbatimtex/btex.. etex blocks.
+ if synIDattr(synID(v:lnum, 1, 1), "name") =~# '^mpTeXinsert$\|^tex\|^Delimiter'
+ return -1
+ endif
" This is the reference line relative to which the current line is indented
" (but see below).
@@ -327,8 +332,8 @@ function! GetMetaPostIndentIntern()
"
" for i = 1 upto 3: % <-- Current line: this gets the same indent as `draw ...`
"
- " NOTE: we get here if and only if L does not contain a statement (among
- " those listed in g:mp_statement).
+ " NOTE: we get here only if L does not contain a statement (among those
+ " listed in g:mp_statement).
if s:ValidMatchEnd(prev_text, ';'.s:eol, 0) >= 0 " L ends with a semicolon
let stm_lnum = s:PrevNonBlankNonComment(lnum)
while stm_lnum > 0