annotate runtime/indent/cmake.vim @ 2069:63613d8d7e4d v7.2.354

updated for version 7.2.354 Problem: Japanese single-width double-byte characters not handled correctly. Solution: Put 0x8e in ScreenLines[] and the second byte in ScreenLines2[]. (partly by Kikuchan)
author Bram Moolenaar <bram@zimbu.org>
date Wed, 03 Feb 2010 15:48:04 +0100
parents 7bc41231fbc7
children 6d3d35ff2c2b
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 " =============================================================================
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 856
diff changeset
2 "
836
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
3 " Program: CMake - Cross-Platform Makefile Generator
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1621
diff changeset
4 " Module: $RCSfile: cmake-indent.vim,v $
836
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
5 " Language: VIM
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1621
diff changeset
6 " Date: $Date: 2006/09/23 21:09:08 $
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1621
diff changeset
7 " Version: $Revision: 1.7 $
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 856
diff changeset
8 "
836
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>
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1621
diff changeset
15 " Last Change: $Date: 2006/09/23 21:09:08 $
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1621
diff changeset
16 " Version: $Revision: 1.7 $
836
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
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 856
diff changeset
68 let cmake_indent_begin_regex = '^\s*\(IF\|MACRO\|FOREACH\|ELSE\|ELSEIF\|WHILE\)\s*('
82b5078be2dd updated for version 7.2a
vimboss
parents: 856
diff changeset
69 let cmake_indent_end_regex = '^\s*\(ENDIF\|ENDFOREACH\|ENDMACRO\|ELSE\|ELSEIF\|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