comparison runtime/indent/mma.vim @ 856:8cd729851562 v7.0g

updated for version 7.0g
author vimboss
date Sun, 30 Apr 2006 18:54:39 +0000
parents 8d34af900bae
children 63b0b7b79b25
comparison
equal deleted inserted replaced
855:d2a4f08396fe 856:8cd729851562
10 " unless you have the following in your .vimrc: 10 " unless you have the following in your .vimrc:
11 " 11 "
12 " let filetype_m="mma" 12 " let filetype_m="mma"
13 " 13 "
14 " Credits: 14 " Credits:
15 " o steve hacked this out of a random indent file in the Vim 6.1 15 " o steve hacked this out of a random indent file in the Vim 6.1
16 " distribution that he no longer remembers...sh.vim? Thanks! 16 " distribution that he no longer remembers...sh.vim? Thanks!
17 17
18 " Only load this indent file when no other was loaded. 18 " Only load this indent file when no other was loaded.
19 if exists("b:did_indent") 19 if exists("b:did_indent")
20 finish 20 finish
28 if exists("*GetMmaIndent") 28 if exists("*GetMmaIndent")
29 finish 29 finish
30 endif 30 endif
31 31
32 function GetMmaIndent() 32 function GetMmaIndent()
33 33
34 " Hit the start of the file, use zero indent. 34 " Hit the start of the file, use zero indent.
35 if v:lnum == 0 35 if v:lnum == 0
36 return 0 36 return 0
37 endif 37 endif
38 38
39 " Find a non-blank line above the current line. 39 " Find a non-blank line above the current line.
40 let lnum = prevnonblank(v:lnum - 1) 40 let lnum = prevnonblank(v:lnum - 1)
41 41
42 " use indenting as a base 42 " use indenting as a base
43 let ind = indent(v:lnum) 43 let ind = indent(v:lnum)
44 let lnum = v:lnum 44 let lnum = v:lnum
45 45
46 " if previous line has an unmatched bracket, or ( indent. 46 " if previous line has an unmatched bracket, or ( indent.
47 " doesn't do multiple parens/blocks/etc... 47 " doesn't do multiple parens/blocks/etc...
48 48
49 " also, indent only if this line if this line isn't starting a new 49 " also, indent only if this line if this line isn't starting a new
50 " block... TODO - fix this with indentkeys? 50 " block... TODO - fix this with indentkeys?
51 if getline(v:lnum-1) =~ '\\\@<!\%(\[[^\]]*\|([^)]*\|{[^}]*\)$' && getline(v:lnum) !~ '\s\+[\[({]' 51 if getline(v:lnum-1) =~ '\\\@<!\%(\[[^\]]*\|([^)]*\|{[^}]*\)$' && getline(v:lnum) !~ '\s\+[\[({]'
52 let ind = ind+&sw 52 let ind = ind+&sw
53 endif 53 endif
54 54
55 " if this line had unmatched closing block, 55 " if this line had unmatched closing block,
56 " indent to the matching opening block 56 " indent to the matching opening block
57 if getline(v:lnum) =~ '[^[]*]\s*$' 57 if getline(v:lnum) =~ '[^[]*]\s*$'
58 " move to the closing bracket 58 " move to the closing bracket
59 call search(']','bW') 59 call search(']','bW')
60 " and find it's partner's indent 60 " and find it's partner's indent