Mercurial > vim
annotate runtime/indent/cmake.vim @ 10093:7598d04404af
Added tag v7.4.2317 for changeset d7846e9fbf653eab1e4c425a901c1636363e7bcd
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 03 Sep 2016 19:15:06 +0200 |
parents | dd6c2497c997 |
children | 63b0b7b79b25 |
rev | line source |
---|---|
836 | 1 " Vim indent file |
2249
6d3d35ff2c2b
Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
2 " Program: CMake - Cross-Platform Makefile Generator |
6d3d35ff2c2b
Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
3 " Module: $RCSfile: cmake-indent.vim,v $ |
836 | 4 " Language: CMake (ft=cmake) |
5 " Author: Andy Cedilnik <andy.cedilnik@kitware.com> | |
2249
6d3d35ff2c2b
Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
6 " Maintainer: Karthik Krishnan <karthik.krishnan@kitware.com> |
6d3d35ff2c2b
Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
7 " Last Change: $Date: 2008-01-16 16:53:53 $ |
6d3d35ff2c2b
Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
8 " Version: $Revision: 1.9 $ |
836 | 9 " |
10 " Licence: The CMake license applies to this file. See | |
11 " http://www.cmake.org/HTML/Copyright.html | |
12 " This implies that distribution with Vim is allowed | |
13 | |
14 if exists("b:did_indent") | |
15 finish | |
16 endif | |
17 let b:did_indent = 1 | |
18 | |
19 setlocal indentexpr=CMakeGetIndent(v:lnum) | |
2249
6d3d35ff2c2b
Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
20 setlocal indentkeys+==ENDIF(,ENDFOREACH(,ENDMACRO(,ELSE(,ELSEIF(,ENDWHILE( |
836 | 21 |
22 " Only define the function once. | |
23 if exists("*CMakeGetIndent") | |
24 finish | |
25 endif | |
3526
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2249
diff
changeset
|
26 let s:keepcpo= &cpo |
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2249
diff
changeset
|
27 set cpo&vim |
836 | 28 |
29 fun! CMakeGetIndent(lnum) | |
30 let this_line = getline(a:lnum) | |
31 | |
32 " Find a non-blank line above the current line. | |
33 let lnum = a:lnum | |
34 let lnum = prevnonblank(lnum - 1) | |
35 let previous_line = getline(lnum) | |
36 | |
37 " Hit the start of the file, use zero indent. | |
38 if lnum == 0 | |
39 return 0 | |
40 endif | |
41 | |
42 let ind = indent(lnum) | |
43 | |
44 let or = '\|' | |
45 " Regular expressions used by line indentation function. | |
46 let cmake_regex_comment = '#.*' | |
47 let cmake_regex_identifier = '[A-Za-z][A-Za-z0-9_]*' | |
48 let cmake_regex_quoted = '"\([^"\\]\|\\.\)*"' | |
49 let cmake_regex_arguments = '\(' . cmake_regex_quoted . | |
50 \ or . '\$(' . cmake_regex_identifier . ')' . | |
51 \ or . '[^()\\#"]' . or . '\\.' . '\)*' | |
52 | |
53 let cmake_indent_comment_line = '^\s*' . cmake_regex_comment | |
839 | 54 let cmake_indent_blank_regex = '^\s*$' |
836 | 55 let cmake_indent_open_regex = '^\s*' . cmake_regex_identifier . |
56 \ '\s*(' . cmake_regex_arguments . | |
57 \ '\(' . cmake_regex_comment . '\)\?$' | |
58 | |
59 let cmake_indent_close_regex = '^' . cmake_regex_arguments . | |
60 \ ')\s*' . | |
61 \ '\(' . cmake_regex_comment . '\)\?$' | |
62 | |
2249
6d3d35ff2c2b
Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
63 let cmake_indent_begin_regex = '^\s*\(IF\|MACRO\|FOREACH\|ELSE\|ELSEIF\|WHILE\|FUNCTION\)\s*(' |
6d3d35ff2c2b
Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
64 let cmake_indent_end_regex = '^\s*\(ENDIF\|ENDFOREACH\|ENDMACRO\|ELSE\|ELSEIF\|ENDWHILE\|ENDFUNCTION\)\s*(' |
836 | 65 |
66 " Add | |
67 if previous_line =~? cmake_indent_comment_line " Handle comments | |
68 let ind = ind | |
69 else | |
70 if previous_line =~? cmake_indent_begin_regex | |
71 let ind = ind + &sw | |
72 endif | |
73 if previous_line =~? cmake_indent_open_regex | |
74 let ind = ind + &sw | |
75 endif | |
76 endif | |
77 | |
78 " Subtract | |
79 if this_line =~? cmake_indent_end_regex | |
80 let ind = ind - &sw | |
81 endif | |
82 if previous_line =~? cmake_indent_close_regex | |
83 let ind = ind - &sw | |
84 endif | |
85 | |
86 return ind | |
87 endfun | |
3526
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2249
diff
changeset
|
88 |
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2249
diff
changeset
|
89 let &cpo = s:keepcpo |
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2249
diff
changeset
|
90 unlet s:keepcpo |