annotate runtime/indent/mma.vim @ 26248:36361f080ffd v8.2.3655

patch 8.2.3655: compiler warning for using size_t for int Commit: https://github.com/vim/vim/commit/cc9d725bbb515baf172c2be21de12d35a961e4ee Author: Mike Williams <mikew@globalgraphics.com> Date: Tue Nov 23 12:35:57 2021 +0000 patch 8.2.3655: compiler warning for using size_t for int Problem: Compiler warning for using size_t for int. Solution: Add a type cast. (Mike Williams, closes https://github.com/vim/vim/issues/9199)
author Bram Moolenaar <Bram@vim.org>
date Tue, 23 Nov 2021 13:45:03 +0100
parents 9c221ad9634a
children 6dd88e45d47d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
271
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
1 " Vim indent file
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
2 " Language: Mathematica
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
3 " Maintainer: Steve Layland <layland@wolfram.com> (Invalid email address)
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
4 " Doug Kearns <dougkearns@gmail.com>
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
5 " Last Change: Sat May 10 18:56:22 CDT 2005
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
6 " Source: http://vim.sourceforge.net/scripts/script.php?script_id=1274
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16610
diff changeset
7 " http://members.wolfram.com/layland/vim/indent/mma.vim
271
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
8 "
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
9 " NOTE:
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
10 " Empty .m files will automatically be presumed to be Matlab files
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
11 " unless you have the following in your .vimrc:
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
12 "
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
13 " let filetype_m="mma"
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
14 "
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
15 " Credits:
856
8cd729851562 updated for version 7.0g
vimboss
parents: 271
diff changeset
16 " o steve hacked this out of a random indent file in the Vim 6.1
271
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
17 " distribution that he no longer remembers...sh.vim? Thanks!
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
18
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
19 " Only load this indent file when no other was loaded.
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
20 if exists("b:did_indent")
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
21 finish
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
22 endif
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
23 let b:did_indent = 1
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
24
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
25 setlocal indentexpr=GetMmaIndent()
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
26 setlocal indentkeys+=0[,0],0(,0)
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
27 setlocal nosi "turn off smart indent so we don't over analyze } blocks
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
28
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
29 if exists("*GetMmaIndent")
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
30 finish
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
31 endif
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
32
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
33 function GetMmaIndent()
856
8cd729851562 updated for version 7.0g
vimboss
parents: 271
diff changeset
34
271
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
35 " Hit the start of the file, use zero indent.
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
36 if v:lnum == 0
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
37 return 0
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
38 endif
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
39
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
40 " Find a non-blank line above the current line.
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
41 let lnum = prevnonblank(v:lnum - 1)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 271
diff changeset
42
8cd729851562 updated for version 7.0g
vimboss
parents: 271
diff changeset
43 " use indenting as a base
271
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
44 let ind = indent(v:lnum)
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
45 let lnum = v:lnum
856
8cd729851562 updated for version 7.0g
vimboss
parents: 271
diff changeset
46
271
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
47 " if previous line has an unmatched bracket, or ( indent.
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
48 " doesn't do multiple parens/blocks/etc...
856
8cd729851562 updated for version 7.0g
vimboss
parents: 271
diff changeset
49
271
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
50 " also, indent only if this line if this line isn't starting a new
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
51 " block... TODO - fix this with indentkeys?
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
52 if getline(v:lnum-1) =~ '\\\@<!\%(\[[^\]]*\|([^)]*\|{[^}]*\)$' && getline(v:lnum) !~ '\s\+[\[({]'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 856
diff changeset
53 let ind = ind+shiftwidth()
271
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
54 endif
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
55
856
8cd729851562 updated for version 7.0g
vimboss
parents: 271
diff changeset
56 " if this line had unmatched closing block,
271
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
57 " indent to the matching opening block
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
58 if getline(v:lnum) =~ '[^[]*]\s*$'
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
59 " move to the closing bracket
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
60 call search(']','bW')
16610
1eaf34420bb3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
61 " and find its partner's indent
271
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
62 let ind = indent(searchpair('\[','',']','bWn'))
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
63 " same for ( blocks
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
64 elseif getline(v:lnum) =~ '[^(]*)$'
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
65 call search(')','bW')
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
66 let ind = indent(searchpair('(','',')','bWn'))
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
67
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
68 " and finally, close { blocks if si ain't already set
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
69 elseif getline(v:lnum) =~ '[^{]*}'
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
70 call search('}','bW')
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
71 let ind = indent(searchpair('{','','}','bWn'))
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
72 endif
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
73
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
74 return ind
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
75 endfunction
8d34af900bae updated for version 7.0072
vimboss
parents:
diff changeset
76