annotate runtime/indent/cmake.vim @ 844:d3bbb5dd3913 v7.0f02

updated for version 7.0f02
author vimboss
date Thu, 27 Apr 2006 00:02:13 +0000
parents 1f3b1021f002
children 8cd729851562
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
836
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
1 " =============================================================================
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
2 "
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
3 " Program: CMake - Cross-Platform Makefile Generator
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
4 " Module: $RCSfile$
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
5 " Language: VIM
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
6 " Date: $Date$
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
7 " Version: $Revision$
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
8 "
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
9 " =============================================================================
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
10
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
11 " Vim indent file
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
12 " Language: CMake (ft=cmake)
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
13 " Author: Andy Cedilnik <andy.cedilnik@kitware.com>
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
14 " Maintainer: Andy Cedilnik <andy.cedilnik@kitware.com>
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
15 " Last Change: $Date$
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
16 " Version: $Revision$
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
17 "
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
18 " Licence: The CMake license applies to this file. See
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
19 " http://www.cmake.org/HTML/Copyright.html
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
20 " This implies that distribution with Vim is allowed
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
21
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
22 if exists("b:did_indent")
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
23 finish
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
24 endif
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
25 let b:did_indent = 1
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
26
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
27 setlocal indentexpr=CMakeGetIndent(v:lnum)
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
28
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
29 " Only define the function once.
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
30 if exists("*CMakeGetIndent")
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
31 finish
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
32 endif
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
33
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
34 fun! CMakeGetIndent(lnum)
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
35 let this_line = getline(a:lnum)
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
36
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
37 " Find a non-blank line above the current line.
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
38 let lnum = a:lnum
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
39 let lnum = prevnonblank(lnum - 1)
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
40 let previous_line = getline(lnum)
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
41
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
42 " Hit the start of the file, use zero indent.
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
43 if lnum == 0
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
44 return 0
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
45 endif
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
46
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
47 let ind = indent(lnum)
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
48
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
49 let or = '\|'
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
50 " Regular expressions used by line indentation function.
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
51 let cmake_regex_comment = '#.*'
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
52 let cmake_regex_identifier = '[A-Za-z][A-Za-z0-9_]*'
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
53 let cmake_regex_quoted = '"\([^"\\]\|\\.\)*"'
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
54 let cmake_regex_arguments = '\(' . cmake_regex_quoted .
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
55 \ or . '\$(' . cmake_regex_identifier . ')' .
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
56 \ or . '[^()\\#"]' . or . '\\.' . '\)*'
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
57
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
58 let cmake_indent_comment_line = '^\s*' . cmake_regex_comment
839
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 836
diff changeset
59 let cmake_indent_blank_regex = '^\s*$'
836
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
60 let cmake_indent_open_regex = '^\s*' . cmake_regex_identifier .
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
61 \ '\s*(' . cmake_regex_arguments .
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
62 \ '\(' . cmake_regex_comment . '\)\?$'
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
63
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
64 let cmake_indent_close_regex = '^' . cmake_regex_arguments .
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
65 \ ')\s*' .
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
66 \ '\(' . cmake_regex_comment . '\)\?$'
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
67
839
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 836
diff changeset
68 let cmake_indent_begin_regex = '^\s*\(IF\|MACRO\|FOREACH\|ELSE\|WHILE\)\s*('
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 836
diff changeset
69 let cmake_indent_end_regex = '^\s*\(ENDIF\|ENDFOREACH\|ENDMACRO\|ELSE\|ENDWHILE\)\s*('
836
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
70
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
71 " Add
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
72 if previous_line =~? cmake_indent_comment_line " Handle comments
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
73 let ind = ind
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
74 else
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
75 if previous_line =~? cmake_indent_begin_regex
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
76 let ind = ind + &sw
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
77 endif
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
78 if previous_line =~? cmake_indent_open_regex
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
79 let ind = ind + &sw
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
80 endif
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
81 endif
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
82
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
83 " Subtract
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
84 if this_line =~? cmake_indent_end_regex
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
85 let ind = ind - &sw
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
86 endif
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
87 if previous_line =~? cmake_indent_close_regex
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
88 let ind = ind - &sw
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
89 endif
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
90
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
91 return ind
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
92 endfun